#include <bits/stdc++.h>
using namespace std;
#define s(a) scanf("%d", &a)
#define ss(s) scanf("%s", s)
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
int color[100] ;
//same is used to store all the element which belong to same set
vector<int> same[105] ;
//diff is used to store all element which must belong different set
vector<pair<int,int>> diff;
//normal dfs
void dfs( int v , int col , int par )
{
color[v] = col;
for( auto u : same[v] )
{
if( u != par )
dfs( u , col , v);
}
}
int main() {
int n , a;
s(n);
while( n!= 0 )
{
int j = 0;
//clearing data
for( int i = 1 ; i <= n ; i++ )
{
same[i].clear();
color[i] = -1;
}
diff.clear();
char s[10];
int flag = 0;
for( int i = 1 ; i <= n ; i++ )
{
s(a);
ss(s);
if( s[0] == 'f' )
{
//if string is false then statements belong to different set i.e, one can
//be true and other can be false or vice-versa
diff.push_back(mk(i,a));
j++;
}
else
{
//if string is true then either both are true or false i.e, they belong
//to same set
same[i].pb(a);
same[a].pb(i);
}
}
//flag is 1 if there is paradox and 0 if there is no paradox
// a paradox is encountered if two elements of same sets are said to be false
for( int i = 0 ; i < j ; i++ )
{
int a = diff[i].first , b = diff[i].second;
if( color[a] == -1 && color[b] == -1 )
{
// if both are uncolored then color one and if other one is colored
// then we know a and b belonged to same set , so it is a paradox
dfs(a,0,0);
if( color[a] == color[b] )
{
flag = 1;
break;
}
dfs(b,1,0);
}
else if( color[a] != -1 && color[b] == -1 )
{
//one colored and other uncolored
dfs(b,1-color[a],0);
if( color[a] == color[b] )
{
flag = 1;
break;
}
}
else if( color[a] == -1 && color[b] != -1 )
{
dfs(a , 1-color[b],0);
if( color[a] == color[b] )
{
flag = 1;
break;
}
}
else if( color[a] == color[b] )
{
// if both are colored by the same color
dfs( a ,1-color[a] ,0);
if( color[a] == color[b] )
{
flag = 1;
break;
}
}
}
if( flag )
{
cout << "PARADOX\n";
}
else
{
cout << "NOT PARADOX\n";
}
s(n);
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFj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