프로그램 명: coci_topovi
제한시간: 2 초

Mirko is a huge fan of chess and programming, but typical chess soon became boring for him, so he started having fun with rook pieces. He found a chessboard with N rows and N columns and placed K rooks on it. Mirko’s game is made of the following rules:

  1. Each rook’s power is determined by an integer.
  2. A rook sees all the fields that are in his row or column except its own field.
  3. We say that a field is attacked if the binary XOR of all the powers of the rooks that see the field is greater than 0.
Notice that the field a rook is at can be attacked or not. Initially, Mirko placed the rooks in a certain layout on the board and will make P moves. After each move, determine how many fields are attacked. Every rook can be moved to any free field on the whole board (not only across column and row).

입력

It is guaranteed that there will not be two rooks on one field at any point.

출력

The output must consist of P lines, the k-th line containing the total number of attacked fields after k moves.

입출력 예


input

2 2 2
1 1 1
2 2 1
2 2 2 1
1 1 1 2

output

4
0

input

2 2 2
1 1 1
2 2 2
2 2 2 1
1 1 1 2

output

4
2

input

3 3 4
1 1 1
2 2 2
2 3 3
2 3 3 3
3 3 3 1
1 1 1 2
3 1 3 2

output

6
7
7
9

Clarification of the first example: After the first move, every field on the board is attacked.
For example, field (1, 1) is seen by only one rook so the total XOR for that field is 1. After the second
move none of the fields are attacked. For example, field (1,1) is seen by both rooks so the total XOR
for that field is 0.
입력

출력

출처:coci/2015-2016/contest1 4/6

[질/답] [제출 현황] [푼 후(0)]
[ 채 점 ] [홈으로]  [뒤 로]