# Include <stdio. h>
# Include <string. h>
Typedef struct student
{
Char name [60];
Int score;
} Ss;
Int main ()
{
Int N, I, j, flag, flag1, flag2;
Ss stu1 [1, 500], stu2 [500];
Char temp [60];
Int tmp;
While (scanf ("% d", & N )! = EOF)
{
I = 0;
While (I <N)
{
Scanf ("% s % d", & stu1 [I]. name, & stu1 [I]. score );
I ++;
}
I = 0;
While (I <N)
{
Scanf ("% s % d", & stu2 [I]. name, & stu2 [I]. score );
I ++;
}
For (I = 0; I <N; I ++)
{
Flag = 0;
For (j = 0; j <N-1-i; j ++)
{
If (stu1 [j]. score <stu1 [j + 1]. score)
{
Strcpy (temp, stu1 [j]. name );
Tmp = stu1 [j]. score;
Strcpy (stu1 [j]. name, stu1 [j + 1]. name );
Stu1 [j]. score = stu1 [j + 1]. score;
Strcpy (stu1 [j + 1]. name, temp );
Stu1 [j + 1]. score = tmp;
Flag = 1;
}
}
If (flag = 0)
Break;
}
Flag1 = 0;
Flag2 = 0;
I = 0;
While (I <N)
{
If (strcmp (stu1 [I]. name, stu2 [I]. name )! = 0)
{
Flag1 = 1;
}
If (stu1 [I]. score! = Stu2 [I]. score)
{
Flag2 = 1;
}
I ++;
}
If (flag1 = 0)
{
Printf ("Right \ n ");
}
Else
{
If (flag2 = 0)
{
Printf ("Not stable \ n ");
I = 0;
While (I <N)
{
Printf ("% s % d \ n", stu1 [I]. name, stu1 [I]. score );
I ++;
}
}
Else
{
Printf ("Error \ n ");
I = 0;
While (I <N)
{
Printf ("% s % d \ n", stu1 [I]. name, stu1 [I]. score );
I ++;
}
}
}
}
Return 0;
}