snails
시간 제한16초메모리 제한2048 MB
수열이 0, 1, 2, 3으로 시작해 앞의 네 항을 더해 이어지는 사각나선(tetranacci) 패턴과 일치하는지 판정한다.
문제
In prehistoric times, there were many creatures with shells that lived in the ocean. You are part of a team of researchers who are looking at a collection of shell fossils with spiral shapes. You want to determine what kind of animal each one came from.
For each shell, you have taken a sequence of measurements along the spiral part. It is hypothesized that if the measurements for a given shell follow the pattern of the following sequence, it is a nautilus shell: \begin{align*} M_1 &= 0 \\ M_2 &= 1 \\ M_3 &= 2 \\ M_4 &= 3 \\ M_{k} &= M_{k-1} + M_{k-2} + M_{k-3} + M_{k-4} & \text{when } \end{align*} Otherwise, it is a snail shell.
The team has collected a very large number of measurements. Being the member with the most programming experience, you have been asked to write a computer program to automate the task of determining whether each sequence of measurements is for a snail shell or nautilus shell.
입력
The first line of input shall be , the number of lines of input that follow, where .
The subsequent lines of input shall each be a sequence of (where ) measurements pertaining to one shell fossil. Measurements are separated by spaces. Each measurement shall be in the range .
출력
For each line of input where the measurements came from a nautilus shell, the output shall be a line with only NAUTILUS. For each line of input where the measurements came from a snail shell, the output shall be a line with only SNAIL.