This page is still under construction.

Parts of this page are still being built. What you see may change.

Grass Cutting

Time limit1sMemory limit512 MB

Summary
After each week every cell grows 1 cm, then cells in the chosen rows and columns are reset to 1 cm; report the final heights of the 10x10 grid.
Level

Easy2 of 10

Topics
Simulation, Implementation, Array
Solved
No attempts yet

Problem

Mowing the lawn means dragging the machine out and walking back and forth across the yard until every blade of grass is cut. To spend less time on it, I now cut only part of the lawn each week.

The lawn is a 10×1010 \times 10 grid of 100 sections. Each week I pick 3 rows and 3 columns, then cut the grass in every section that lies in one of them.

At the start every section is 1 cm high. Each week every section grows by 1 cm, and after that I cut the grass as described above. A section that is cut becomes 1 cm high.

You are given the rows and columns that were cut over the past few weeks. Report the height of every section immediately after the last cutting.

Input

The first line contains an integer kk (1≤k≤1001 \le k \le 100), the number of weeks this cutting method was used.

Each of the next kk lines describes one week and contains six integers. The first three are the rows picked that week, and the last three are the columns picked that week. Each of these numbers is between 1 and 10. The three rows are distinct, and the three columns are distinct.

Output

Print the grass heights immediately after the last cutting as a 10×1010 \times 10 grid. The top row is row 1 and the bottom row is row 10. The left column is column 1 and the right column is column 10. Print the 10 values of each row on one line, separated by single spaces.

Examples2

  1. Example 1

    Input
    1
    1 2 3 4 5 6
    
    Expected output
    1 1 1 1 1 1 1 1 1 1
    1 1 1 1 1 1 1 1 1 1
    1 1 1 1 1 1 1 1 1 1
    2 2 2 1 1 1 2 2 2 2
    2 2 2 1 1 1 2 2 2 2
    2 2 2 1 1 1 2 2 2 2
    2 2 2 1 1 1 2 2 2 2
    2 2 2 1 1 1 2 2 2 2
    2 2 2 1 1 1 2 2 2 2
    2 2 2 1 1 1 2 2 2 2
    
  2. Example 2

    Input
    2
    1 2 3 4 5 6
    1 3 5 4 8 10
    
    Expected output
    1 1 1 1 1 1 1 1 1 1
    2 2 2 1 2 2 2 1 2 1
    1 1 1 1 1 1 1 1 1 1
    3 3 3 1 2 2 3 1 3 1
    1 1 1 1 1 1 1 1 1 1
    3 3 3 1 2 2 3 1 3 1
    3 3 3 1 2 2 3 1 3 1
    3 3 3 1 2 2 3 1 3 1
    3 3 3 1 2 2 3 1 3 1
    3 3 3 1 2 2 3 1 3 1