ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1006. Square Frames

Time limit: 2.0 second
Memory limit: 64 MB
Frame consists of the following characters:
Character ASCII code Description
218 Left upper corner
191 Right upper corner
192 Left bottom corner
217 Right bottom corner
179 Vertical (left and right) border line
196 Horizontal (top and bottom) border line
N square frames (1 ≤ N ≤ 15) were sequentially drawn on screen 50 characters wide 20 lines tall. If parts of some frames intersect, only the part of the frame drawn latter remains visible. Each frame lies fully on the screen.
You need to write a program that builds a possible sequence of frames that (if drawn sequentially) would produce the same picture on the screen. Your sequence does not have to be the same with the original sequence used to build the picture on the screen. However, it should not contain more than 2000 frames.

Input

Problem illustration
The screen area was originally filled with dots (ASCII 46). Input contains the final picture on the screen after the sequence of frames is drawn.

Output

Your program should write to output the number of frames in the sequence built and the frames coordinates as follows:
K
X1 Y1 A1

Xk Yk Ak
Here K is the number of frames, Xi and Yi are coordinates of the upper left frame corner (0 ≤ Xi ≤ 49, 0 ≤ Yi ≤ 19) and Ai is the length of the frame side (2 ≤ Ai). All numbers must be delimited with one or more spaces and/or line breaks.

Sample

inputoutput
(see the figure above)
6
16 11 7
32 14 4
4 8 8
11 6 7
36 11 3
28 8 3
Problem Source: USU Championship 1997