Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

G. Grand Hotel
time limit per test
8 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

The Grand Hotel, from commons.wikimedia.org, showing (nearly full) Nordic unity.

Four-Dimensional Grid World needs a new hotel to accommodate the next tourist season. Your task is to design the floor plan of this hotel. The hotel is to be built in a four-dimensional grid of $$$400 \times 400 \times 400 \times 400$$$ cells.

  • A cell is a quadruple $$$(x_1, x_2, x_3, x_4)$$$ of integers, each between $$$0$$$ and $$$399$$$ inclusive.
  • The distance between two cells $$$(x_1, x_2, x_3, x_4)$$$ and $$$(y_1, y_2, y_3, y_4)$$$ is $$$\sum_{i=1}^{4} |x_i - y_i|$$$ (sometimes called the Manhattan or $$$L_1$$$ distance).
  • Two cells are adjacent if the distance between them is $$$1$$$.
  • A set $$$H$$$ of cells is a hotel if the graph with vertex set $$$H$$$ and an edge between every pair of adjacent cells in $$$H$$$ is a tree. The rooms of the hotel are the leaves of this tree, that is, the cells of $$$H$$$ that are adjacent to exactly one other cell of $$$H$$$.

You are given a set $$$R$$$ of at least two cells, any two of which are at distance at least $$$15$$$. Construct a hotel with at most $$$10^6$$$ cells whose rooms are exactly the cells in $$$R$$$.

Input

The input consists of:

  • One line with an integer $$$n$$$ ($$$2 \leq n \leq 100$$$), the number of rooms.
  • $$$n$$$ lines, each with four integers $$$x_1$$$, $$$x_2$$$, $$$x_3$$$, $$$x_4$$$ ($$$0 \leq x_i \leq 399$$$), the coordinates of a room.
Any two rooms are at distance at least $$$15$$$.
Output

Output an integer $$$k$$$ ($$$1 \leq k \leq 10^6$$$), the number of cells of the hotel, followed by $$$k$$$ lines, each with four integers $$$x_1$$$, $$$x_2$$$, $$$x_3$$$, $$$x_4$$$ ($$$0 \leq x_i \leq 399$$$), the coordinates of a cell of the hotel. The cells must be distinct.

It can be shown that a solution always exists. If there are multiple valid solutions, you may output any one of them.

Example
Input
2
0 0 0 0
1 2 4 8
Output
16
0 0 0 0
1 0 0 0
1 1 0 0
1 2 0 0
1 2 1 0
1 2 2 0
1 2 3 0
1 2 4 0
1 2 4 1
1 2 4 2
1 2 4 3
1 2 4 4
1 2 4 5
1 2 4 6
1 2 4 7
1 2 4 8