Flipping the Vegetable Garden

No attempts yetTime limit1sMemory limit128 MB

Problem

The Byteland allotment garden (BOD) has grown only two vegetables for many years: carrots and parsley. The garden is a square with side length nn and is divided into n×nn \times n unit cells. Exactly one carrot or one parsley plant grows in each cell.

A special cultivation routine gives the vegetables their taste and character. Every year the owner picks one rectangular region and flips the cultivation inside it. Flipping the cultivation means that, within that region, a carrot is planted wherever parsley used to grow and parsley is planted wherever a carrot used to grow. Every cell outside the region stays exactly as it was the year before.

The owner has written down a cultivation plan spanning many years. Determine what the garden will look like after the whole plan has been carried out.

Input

The first line contains one integer nn (1n10001 \le n \le 1000), the size of the garden.

The next nn lines describe the initial garden. Each line describes one horizontal strip (row) and contains nn integers w1,w2,,wnw_1, w_2, \dots, w_n (0wi10 \le w_i \le 1). If wiw_i is 00, a carrot grows in that cell; if wiw_i is 11, parsley grows there. The ii-th of these lines is row ii, and its jj-th number is the cell in column jj.

The next line contains one integer mm (1m1061 \le m \le 10^6), the number of years in the owner's plan.

Each of the following mm lines describes one year's flip, in chronological order. A line contains four integers x1,y1,x2,y2x_1, y_1, x_2, y_2 (1x1x2n1 \le x_1 \le x_2 \le n, 1y1y2n1 \le y_1 \le y_2 \le n). It means that in that year the cultivation is flipped in every cell whose column index is between x1x_1 and x2x_2 and whose row index is between y1y_1 and y2y_2; that is, in the rectangle whose top-left corner is (column x1x_1, row y1y_1) and whose bottom-right corner is (column x2x_2, row y2y_2).

Output

Print the state of the garden after mm years on nn lines. Each line describes one horizontal strip (row) and contains nn integers w1,w2,,wnw_1, w_2, \dots, w_n. Here wiw_i is 00 if a carrot grows in that cell and 11 if parsley grows there. Separate the numbers on a line with single spaces.

Hint