#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long LL; typedef pair PII; typedef vector VI; typedef vector VPII; typedef pair PLL; typedef pair PIL; typedef pair PLI; typedef double DB; #define pb push_back #define mset(a, b) memset(a, b, sizeof a) #define all(x) (x).begin(), (x).end() #define bit(x) (1 << (x)) #define bitl(x) (1LL << (x)) #define sqr(x) ((x) * (x)) #define sz(x) ((int)(x.size())) #define cnti(x) (__builtin_popcount(x)) #define cntl(x) (__builtin_popcountll(x)) #define clzi(x) (__builtin_clz(x)) #define clzl(x) (__builtin_clzll(x)) #define ctzi(x) (__builtin_ctz(x)) #define ctzl(x) (__builtin_ctzll(x)) #define X first #define Y second #define Error(x) cout << #x << " = " << x << endl template inline void chkmax(T& x, U y) { if (x < y) x = y; } template inline void chkmin(T& x, U y) { if (y < x) x = y; } const int oo = 21000; int n; map H; char s[10005]; struct Interval { static const int ML = 35; PII v[ML]; void init() { for (int i = 0; i < ML; i++) { v[i].X = -oo; v[i].Y = oo; } } void update(int id, int x, int y) { chkmax(v[id].X, x); chkmin(v[id].Y, y); } bool intersect(Interval &I) { for (int k = 0; k < ML; k++) { int mi = max(v[k].X, I.v[k].X); int ma = min(v[k].Y, I.v[k].Y); if (mi > ma) return 0; } return 1; } } I[1005]; int Hash(string s) { if (H.count(s)) return H[s]; return H[s] = n++; } int get(char *s) { if (s[0] == '<') { if (s[1] != '=') return 2; return 3; } if (s[0] == '>') { if (s[1] != '=') return 0; return 1; } return 4; } bool isOp(char c) { return c == '<' || c == '=' || c == '>'; } int main() { int tn; scanf("%d\n", &tn); for (int tc = 0; tc < tn; tc++) { gets(s); I[tc].init(); for (char *t = strtok(s, ","); t; t = strtok(NULL, ",")) { int i = 0, id, op, val; for (char *tt = t; *tt; tt++) { if (isOp(*tt)) { op = get(tt); break; } } for (char *tt = t; *tt; tt++) { if (islower(*tt)) { string s = ""; for (; islower(*tt) && *tt; tt++) s += *tt; id = Hash(s); break; } } for (char *tt = t; *tt; tt++) { if (isdigit(*tt) || *tt == '-') { sscanf(tt, "%d", &val); break; } } if (op == 4) { I[tc].update(id, val, val); continue; } if (op == 0) { I[tc].update(id, val + 1, oo); } else if (op == 1) { I[tc].update(id, val, oo); } else if (op == 2) { I[tc].update(id, -oo, val - 1); } else { I[tc].update(id, -oo, val); } } VI ans; for (int i = 0; i < tc; i++) if (I[tc].intersect(I[i])) { ans.push_back(i + 1); } if (ans.empty()) puts("unique"); else { for (int i = 0; i < sz(ans); i++) { if (i) putchar(' '); printf("%d", ans[i]); } puts(""); } } return 0; }