waclaw
문제
Waclaw Sierpinski was a Polish mathematician who liked playing with triangles. One day he started drawing triangles using the following procedure:
- Draw an equilateral triangle T.
- Connect the midpoints of its sides with line segments. Denote the new equilateral triangles with T1, T2, T3 and T4, as illustrated in the first figure below.
- Repeat the previous step on triangles T1, T2 and T3. New triangles are: T11, T12, T13, T14, T21, T22, T23, T24, T31, T32, T33, T34.
- Continue the procedure on all triangles ending in 1, 2 or 3. The resulting fractal is called the Sierpinski triangle.
[이미지 1]
We say that a triangle A is leaning on the triangle B if B does not contain A and if one entire side of A is a part of some side of B. For example, the triangle T23 is leaning on T24 and T4, but not on T2 or T32. Note that A leaning on B does not imply that B is leaning on A.
Write a program that, given a triangle A, which is a part of the Sierpinski triangle, finds all triangles B such that A is leaning on B.
입력
The first and only line of input contains a sequence of characters representing the given triangle, as described above. The sequence will contain between 2 and 50 characters, inclusive.
출력
Output all triangles that the given triangle is leaning on, each on a separate line, in any order.
예제
예제 1
T4
T1 T2 T3
예제 2
T11
T14
예제 3
T312
T4 T314 T34