#include <iostream>
#include <algorithm> //для использования функции sort
using namespace std;
int main()
{
const int lch = 256;
int n;
cin>>n;
char **p = new char* [n]; //Создаем массив p, где будем хранить пары символов.
for (int i = 0; i < n; i++)
{
p[i] = new char [2];
}
for (int i = 0; i < n; i++)
{
cin >> p[i][1]>>p[i][2];
}
int chars[lch];
for (int i = 0; i<lch; i++)
{
chars[i] = -1;
}
int K = 0;
for (int i = 0; i<n; i++)
{
if (chars [ p[i][1]] == -1)
K++;
if (chars [ p[i][2]] == -1)
K++;
chars [ p[i][1]] = 0;
chars [ p[i][2]] = 0;
}
bool change;
char x, y;
int M;
for (int i = 0; i < n; i++)
{
change = false;
for (int j = 0; j < n; j++)
{
x = p[j][1];
y = p[j][2];
M = max(chars[x] + 1, chars [y]);
if (M > (K-1))
{
cout<<"Порядок противоречив";
return 0;
}
if (chars[y] != M)
{
change = true;
}
chars[y] = M;
}
if (!change)
{
sort(chars, chars+lch);
int previous = K;
int i = lch-1;
while (chars [i] > -1)
{
if (chars[i] == previous - 1)
{
previous--;
}
else
{
cout<<"порядок неполный";
return 0;
}
i--;
}
cout<<"полный порядок";
return 0;
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPiAvL9C00LvRjyDQuNGB0L/QvtC70YzQt9C+0LLQsNC90LjRjyDRhNGD0L3QutGG0LjQuCBzb3J0CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpCnsKCWNvbnN0IGludCBsY2ggPSAyNTY7CglpbnQgbjsKCWNpbj4+bjsKCQoJY2hhciAqKnAgPSBuZXcgY2hhciogW25dOyAvL9Ch0L7Qt9C00LDQtdC8INC80LDRgdGB0LjQsiBwLCDQs9C00LUg0LHRg9C00LXQvCDRhdGA0LDQvdC40YLRjCDQv9Cw0YDRiyDRgdC40LzQstC+0LvQvtCyLgogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspCiAgICB7CiAgICAgICAgcFt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