1 #include <iostream>
2 #include <cstdio>
3 #include <cmath>
4 #include <cstring>
5 #include <algorithm>
6 #include <queue>
7 #include <stack>
8 #include <vector>
9 using namespace std;
10 stack<int>z;
11 int p,q,r,s,t,len,flag;
12 char a[250];
13 int fun()
14 {
15 for(int i=len-1;i>=0;i--)
16 {
17 if(a[i]=='p')
18 z.push(p);
19 else if(a[i]=='q')
20 z.push(q);
21 else if(a[i]=='r')
22 z.push(r);
23 else if(a[i]=='s')
24 z.push(s);
25 else if(a[i]=='t')
26 z.push(t);
27 else if(a[i]=='A')
28 {
29 int k1=z.top();
30 z.pop();
31 int k2=z.top();
32 z.pop();
33 int k3=k1||k2;
34 z.push(k3);
35 }
36 else if(a[i]=='K')
37 {
38 int k1=z.top();
39 z.pop();
40 int k2=z.top();
41 z.pop();
42 int k3=k1&&k2;
43 z.push(k3);
44 }
45 else if(a[i]=='N')
46 {
47 int k1=z.top();
48 z.pop();
49 int k3=!k1;
50 z.push(k3);
51 }
52 else if(a[i]=='C')
53 {
54 int k1=z.top();
55 z.pop();
56 int k2=z.top();
57 z.pop();
58 int k3=(!k1)||k2;
59 z.push(k3);
60 }
61 else if(a[i]=='E')
62 {
63 int k1=z.top();
64 z.pop();
65 int k2=z.top();
66 z.pop();
67 if(k1==k2)
68 z.push(1);
69 else
70 z.push(0);
71 }
72 }
73 if(z.top()==0)
74 return 1;
75 return 0;
76 }
77 int check()
78 {
79 for(p=0;p<2;p++)
80 {
81 for(q=0;q<2;q++)
82 {
83 for(r=0;r<2;r++)
84 {
85 for(s=0;s<2;s++)
86 {
87 for(t=0;t<2;t++)
88 {
89 if(fun())
90 {
91 flag=1;
92 printf("not\n");
93 return 0;
94 }
95 }
96 }
97 }
98 }
99 }
100 return 1;
101 }
102 int main(int argc, char *argv[])
103 {
104
105 while(gets(a))
106 {
107 if(a[0]=='0')
108 break;
109 len=strlen(a);
110 flag=0;
111 check();
112 if(!flag)
113 printf("tautology\n");
114 }
115 return 0;
116 }