Cube

You wake up and find yourself inside an empty cubic room. At first you feel surprised but then you notice that at the center of each wall, roof, and floor there is a gate that seems to give access to another similar empty cubic room. You start feeling a kind of fear as you move from room to room and realize that there is no water, there is no food, and the number of rooms seems endless. Unless you find an exit to get out of there, you are going to starve to death! To make things even worse, you meet other people, also wandering through the rooms, who tell you that some of the rooms are booby-trapped. If you enter a booby-trapped room, some nasty thing will happen to you, like an acid shower or a poisonous atmosphere and you will die slowly but surely. But there is hope! You had already notice that at a given corner of each room there is a decimal number, that you call the room number. By comparing information with the other people trapped in the cubes, you realize that each room number encodes the Cartesian coordinates of the gate that leads towards the exit. This gate may not be safe, though: the pointed room may have a bomb or some other booby-trap. Here is what you found:

  1. In the coordinate system, the dimension of each cube side is 1. Therefore, the gate on the floor is at (1/2, 1/2, 0), while the gate at the ceiling is at (1/2, 1/2, 1).
  2. The x coordinate is the quotient between the number of even digits and the number of digits.
  3. The y coordinate is the quotient between the number of digits that are prime number and the number of digits (notice that 1 is not a prime).
  4. The z coordinate is the quotient of the number of digits that correspond to odd numbers less than 5, by the number of digits.
  5. Once simplified, all the above quotients are either 0, 1/2, or 1.
  6. In order to find if the pointed room is booby-trapped you must set up a vector with three co- ordinates using the room number, computed as follows. The x-coordinate is the quotient of the first digit by the second, the y-coordinate is the quotient of the third digit by the fourth, and the z-coordinate is the quotient of the fifth digit by the sixth. If the room number has less than 6 digits, restart from the first digit; If it has more than 6 ignore the remaining digits. Now, compute the dot product of this vector and the vector describing the coordinates of the exit. Simplify the resulting fraction. If the numerator of the simplified fraction is composite (i.e., not prime nor equals to 1) the exit is safe. Note: The dot product can be defined for two n-dimensional vectors X and Y by ∑n X.Y = Your job is to decode the room number so that you and your companions can find the exit and get some fresh air. Hurry up and good luck! Input The input file contains several test cases, each of them is integer number, N, with 0 < N < 2000000000, representing a number found in a room, on a line by itself. i=1 xiyi = x1y1 + . . . + xnyn.

2/2 Output For each test case, the output has two lines. The first line is a triple of fractions separated by spaces indicating in Cartesian coordinates of the local direction towards the exit. The second line has only one word: ‘SAFE’ or ‘FATAL’, depending on whether the room in the pointed direction is safe or booby trapped. Sample Input 24556789 74974652 Sample Output 1/2 1/2 0 FATAL 1/2 1/2 0 SAFE