the problem is here http://mirror.codeforces.com/problemset/problem/472/D the solution like 8041817(the first several solution onhttp://mirror.codeforces.com/problemset/status/472/problem/D ) can not pass follow test data
4
0 1 3 2
1 0 2 3
3 2 0 1
2 3 1 0
the test data is not strong enough 0.0