There are N seaside villages on X island, numbered from 1 to N. N roads are built to connect all of them, which are also numbered from 1 to N, and the road with number i connects the village i and i % N + 1. Sometimes, for some reasons, some roads ar…