Hobby

아직 제출이 없습니다시간 제한1초메모리 제한256 MB

문제

Maggy's frustration is reaching its peak lately. Johnny does not leave the house, it is hard to talk to him -- all day he sits with his books with logical puzzles. Sudoku, KenKen, Kakuro, Kuromasu, \ldots Maggy is no longer even able to remember those bizarre names. She finally came up with a bold idea. To demonstrate the futility and repetitiveness of filling charts with numbers, she will write a program that instantly solves such puzzles.

Johnny's current favourite puzzle is Suko. In this game you fill in a 3×33 \times 3 chart with distinct numbers from 11 to 99. Chart's fields are numbered from 11 to 99: the fields in the ii-th row from the top are 3i23i-2, 3i13i-1 and 3i3i, in the left-to-right order. In addition, each field has a colour: red, green or blue. The completed chart must meet the following conditions on subsquares 2×22 \times 2 and fields of each color:

  • In each field there is a number between 11 and 99, no number is repeated.
  • The sum of numbers in fields 11, 22, 44 and 55 is equal to v_1v\_1.
  • The sum of numbers in fields 22, 33, 55 and 66 is equal to v_2v\_2.
  • The sum of numbers in fields 44, 55, 77 and 88 is equal to v_3v\_3.
  • The sum of numbers in fields 55, 66, 88 and 99 is equal to v_4v\_4.
  • The sum of numbers in the red fields is equal to v_Av\_{\texttt{A}}.
  • The sum of numbers in the green fields is equal to v_Bv\_{\texttt{B}}.
  • The sum of numbers in the blue fields is equal to v_Cv\_{\texttt{C}}.

Help Maggy prove to Johnny the childishness of his hobby and write a program solving Suko puzzles.

입력

The first line of the input contains three integers v_A,v_Bv\_{\texttt{A}}, v\_{\texttt{B}} and v_Cv\_{\texttt{C}} (1v_A,v_B,v_C421 \leq v\_{\texttt{A}}, v\_{\texttt{B}}, v\_{\texttt{C}} \leq 42), each separated by a single space. In the second row there are four integers v_1,v_2,v_3,v_4v\_1, v\_2, v\_3, v\_4 (10v_1,v_2,v_3,v_43010 \leq v\_1, v\_2, v\_3, v\_4 \leq 30 ), each separated by a single space. The third line contains a description of the colours of the first row from the top. It is a sequence of three characters from the set \\{A, B, C\\}, denoting the colours red, green and blue, and describes colours of the consecutive fields in the first row of the chart. In the fourth and fifth lines there are similar descriptions of the second and third row of the chart.

For each colour there is a field of this colour in the chart.

출력

You should write three lines describing the solution of the given puzzle -- the ii-th line should contain a description of ii-th row of the chart in the form of three digits placed in the consecutive fields, from left to right.

If there are many solutions, you can write an arbitrarily chosen one.

If there is no chart meeting the conditions, one word "NIE" (Polish for "no") should be written in the first and only line.