War

题目描述

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=13&page=show_problem&problem=1099 [PDF](https://uva.onlinejudge.org/external/101/p10158.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10158/2d26e76a53acdbc0ac3ce07f87fb23625ad5ff3b.png)

输入输出格式

输入格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10158/61868abd5fdb87a39d5ed7375f1e5975ee502d1c.png)

输出格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA10158/1390d40c96147f852a72b9199329a1aecf0ed4b7.png)

输入输出样例

输入样例 #1

10
1 0 1
1 1 2
2 0 5
3 0 2
3 8 9
4 1 5
4 1 2
4 8 9
1 8 9
1 5 2
3 5 2
0 0 0

输出样例 #1

1
0
1
0
0
-1
0