欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1151B.Dima and a Bad XOR
Dima and a Bad XOR
Student Dima from Kremland has a matrix of size filled with non-negative integers.
He wants to select exactly one integer from each row of the matrix so that the bitwise exclusive OR of the selected integers is strictly greater than zero. Help him!
Formally, he wants to choose an integers sequence () so that the inequality $a_{1, c_1} \oplus a_{2, c_2} \oplus \ldots \oplus a_{n, c_n} \gt 0$ holds, where is the matrix element from the -th row and the -th column.
Here denotes the bitwise XOR operation of integers and .
Input
The first line contains two integers and () — the number of rows and the number of columns in the matrix .
Each of the next lines contains integers: the -th integer in the -th line is the -th element of the -th row of the matrix , i.e. ().
Output
If there is no way to choose one integer from each row so that their bitwise exclusive OR is strictly greater than zero, print "NIE".
Otherwise print "TAK" in the first line, in the next line print integers (), so that the inequality $a_{1, c_1} \oplus a_{2, c_2} \oplus \ldots \oplus a_{n, c_n} \gt 0$ holds.
If there is more than one possible answer, you may output any.
Note
In the first example, all the numbers in the matrix are , so it is impossible to select one number in each row of the table so that their bitwise exclusive OR is strictly greater than zero.
In the second example, the selected numbers are (the first number in the first line) and (the third number in the second line), , is more than , so the answer is found.
Samples
3 2
0 0
0 0
0 0
NIE
2 3
7 7 7
7 7 10
TAK
1 3
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |