不変量
#Problem_Solving_Technique
C - Traveling
https://atcoder.jp/contests/abc086/tasks/arc089_a