The Byteland allotment garden (BOD) has grown only two vegetables for many years: carrots and parsley. The garden is a square with side length n and is divided into n×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.
The first line contains one integer n (1≤n≤1000), the size of the garden.
The next n lines describe the initial garden. Each line describes one horizontal strip (row) and contains n integers w1,w2,…,wn (0≤wi≤1). If wi is 0, a carrot grows in that cell; if wi is 1, parsley grows there. The i-th of these lines is row i, and its j-th number is the cell in column j.
The next line contains one integer m (1≤m≤106), the number of years in the owner's plan.
Each of the following m lines describes one year's flip, in chronological order. A line contains four integers x1,y1,x2,y2 (1≤x1≤x2≤n, 1≤y1≤y2≤n). It means that in that year the cultivation is flipped in every cell whose column index is between x1 and x2 and whose row index is between y1 and y2; that is, in the rectangle whose top-left corner is (column x1, row y1) and whose bottom-right corner is (column x2, row y2).
Print the state of the garden after m years on n lines. Each line describes one horizontal strip (row) and contains n integers w1,w2,…,wn. Here wi is 0 if a carrot grows in that cell and 1 if parsley grows there. Separate the numbers on a line with single spaces.
