In Computer Science, NAN
stands for not a number, that can be interpreted as a value that is undefined. developed a new language, named NAN language. There are two types of words in NAN language: A-word and B-word.
Every word that satisfies the following rules is an A-word.
- A single letter
N
is an A-word - Given an A-word, replacing any letter
N
withNAN
orNA
will generate a new A-word
Every word that satisfies the following rules is a B-word.
- A single letter
N
is a B-word - Given a B-word, replacing any letter
N
withNAN
orNA
orAN
will generate a new B-word
Based on the above rules, can you write a program to check if a given word is an A-word or a B-word in NAN language?
Constraints
For all subtasks:
Subtask 1 [17%]
Subtask 2 [48%]
Subtask 3 [35%]
No additional constraints.
Input Specification
The first line contains an integer , the number of test cases.
Each of the following lines contains a string , only consisting of letters N
and A
.
Output Specification
Output lines. Each line contains two integers and . If the word is an A-word, ; otherwise, . If the word is a B-word, ; otherwise, .
Sample Input
4
NAN
ANN
ANAN
NANA
Sample Output
1 1
0 0
0 1
1 1
Comments