Triangle Cuts

Time limit1sMemory limit128 MB

Problem

A computer science professor was watching his young daughter cut large triangular pieces of paper with scissors. Each piece is green on one side and white on the other, and she always keeps the white side facing up, so the green side is never visible. She always follows the same procedure: starting from one large white triangle, she makes exactly three straight cuts. Each cut separates a single piece of paper into two, and when she finishes she is left with exactly four smaller white triangles. She then sets those four aside and starts again with a new large triangle.

Several arrangements of the four triangles are possible (all angles are given in degrees):

  • In exactly two of the arrangements, no cut runs all the way from a vertex of the original large triangle to the opposite side. Together with their rotations, these two arrangements are the only ways to obtain four triangles without ever making such a cut. In the first, one small triangle is cut off at each of the three corners, leaving a fourth triangle in the middle. In the second, one corner is cut off completely, and the remaining piece is divided into three triangles that all meet at a single interior point lying on that first cut.
  • Every other valid arrangement uses at least one cut that runs from a vertex straight across to the opposite side.
  • Some arrangements can never occur, because each cut must separate exactly one existing piece into two pieces.

Because the paper is never turned over, each triangle may be rotated but never mirrored.

The professor wonders whether he could recognize his daughter's work: given the exact shapes of four small triangles, could they have come from a single large triangle cut by her procedure? He notes that only the shapes of the triangles matter -- whenever the shapes are compatible, suitable sizes can always be chosen. Your task: given the angles of a large triangle and of four smaller triangles, decide whether the four small triangles could have been produced from the large one using the procedure above.

Input

The input contains from 1 to 30 datasets, followed by a line containing only 0 0 180, which marks the end of the input.

Each dataset is a single line of 15 positive integers separated by single spaces; every integer is less than 180. The 15 integers form five groups of three, and each group lists the three vertex angles (in degrees) of one triangle. The first group describes the large triangle; the remaining four groups describe the four small triangles.

None of the triangles is flipped over (the green side stays up), and within each triangle the three vertex angles are listed in clockwise order.

Output

For each dataset, output a single line: yes if the daughter's procedure, starting from the large triangle, could have produced four triangles matching the four given small triangles, and no otherwise.