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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 */
/* 설명 : 바둑알이 깔려 있는 상황이 19×19 로 입력된다.
십자바꾸기 횟수(n)가 입력된다.
십자바꾸기 좌표가 횟수(n) 만큼 입력되고
십자 바꾸기 결과를 출력한다.
*/
#include <iostream>
using namespace std;
int main()
{
int badook[19][19] = { 0 };
int n, x, y;
// 바둑알이 깔려 있는 상황 입력받기
for (int i = 0; i < 19; i++) {
for (int k = 0; k < 19; k++) {
cin >> badook[i][k];
}
}
// 십자바꾸기 횟수 입력받기
cin >> n;
// 가로, 세로줄 흑백 변경
for (int s = 0; s < n; s++) {
cin >> x >> y;
for (int i = 0; i < 19; i++) {
badook[x - 1][i] == 0 ? badook[x - 1][i] = 1 : badook[x - 1][i] = 0;
badook[i][y - 1] == 0 ? badook[i][y - 1] = 1 : badook[i][y - 1] = 0;
}
}
// 십자 바꾸기 결과 출력
for (int i = 0; i < 19; i++) {
for (int k = 0; k < 19; k++) {
cout << badook[i][k] << " ";
}
cout << endl;
}
return 0;
}