waclaw | 프로그래밍의 벗 PivotOJ
PivotOJ

waclaw

시간 제한: 1000ms메모리 제한: 128MB출처: CHC 2006 Regional Competition - SeniorsBOJ 3158
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

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
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.