The painter Vincent travelled through a city of skyscrapers and finished a painting of nothing but their silhouette. A week after he finished it, the painting burned. The architects gave him the exact dimensions of the skyscrapers again, so the painting can be reconstructed.
There are N skyscrapers. The i-th one is a rectangle with sides parallel to the coordinate axes, with its lower left corner at (Li,0) and its upper right corner at (Ri,Hi). The silhouette is the union of these N rectangles.
Let L=minLi, R=maxRi and H=maxHi. The picture is R−L cells wide, so its left edge is the left side of the leftmost skyscraper and its right edge is the right side of the rightmost skyscraper. The picture has H rows for the skyscrapers plus one row for the x axis, H+1 rows in total. The j-th cell from the left covers the interval [L+j−1,L+j] on the x axis, and the k-th row from the top covers the interval [H−k,H−k+1] on the y axis. The last row is the x axis and is filled with * across the whole width.
Every coordinate is an integer, so each cell above the x axis either lies completely inside the silhouette or shares no interior point with it. Call a cell that lies completely inside the silhouette a building cell. If at least one of the eight cells that share a side or a corner with a building cell is not a building cell, write # in that building cell. Write . in every other cell. A cell outside the horizontal range of the picture is not a building cell. Inside that range, the cells on the x axis row and below it count as building cells. What is left is the outline of the silhouette.
The value the mathematicians computed has to be checked, so report the perimeter of the silhouette as well. Sides that lie on the x axis do not count towards the perimeter.
The first line contains the number of skyscrapers N (1≤N≤10000).
Each of the next N lines contains three integers Li, Ri and Hi describing the i-th skyscraper (1≤Li,Ri,Hi≤1000, 3≤Ri−Li≤1000).
On the first line, print the perimeter of the silhouette. Sides lying on the x axis are not counted.
On the next H+1 lines, print the picture, where H is the height of the tallest skyscraper.