#include #include #include using namespace std; #define inf 10010 struct hi { int flag; int count; char one[40][40]; int two1[40], two2[40]; int three[40]; hi() { flag = 0; count = 0; for (int i = 1; i <= 35; i++) { two1[i] = -inf; two2[i] = inf; } } } a[1010]; void Union(char temp2[40], int temp4, int i, int x) { if (strcmp(temp2, "==") == 0) { if (temp4 >= a[x].two1[i] && temp4 <= a[x].two2[i]) a[x].two1[i] = a[x].two2[i] = temp4; else a[x].flag = 1; } else if (strcmp(temp2, ">") == 0) { temp4++; if (temp4 >= a[x].two1[i] && temp4 <= a[x].two2[i]) a[x].two1[i] = temp4; else if (temp4 < a[x].two1[i]) ; else a[x].flag = 1; } else if (strcmp(temp2, ">=") == 0) { if (temp4 >= a[x].two1[i] && temp4 <= a[x].two2[i]) a[x].two1[i] = temp4; else if (temp4 < a[x].two1[i]) ; else a[x].flag = 1; } else if (strcmp(temp2, "<") == 0) { temp4--; if (temp4 >= a[x].two1[i] && temp4 <= a[x].two2[i]) a[x].two2[i] = temp4; else if (temp4 > a[x].two2[i]) ; else a[x].flag = 1; } else { if (temp4 >= a[x].two1[i] && temp4 <= a[x].two2[i]) a[x].two2[i] = temp4; else if (temp4 > a[x].two2[i]) ; else a[x].flag = 1; } } void deal(char temp1[40], char temp2[40], char temp3[40], int x, int num) { int len = strlen(temp3), i; int temp4 = 0; i = 0; if (temp3[0] == '-') i = 1; for (; i < len; i++) temp4 = 10 * temp4 + temp3[i] - '0'; if (temp3[0] == '-') temp4 *= -1; for (i = 1; i <= num; i++) if (strcmp(a[x].one[i], temp1) == 0) { Union(temp2, temp4, i, x); break; } if (i == num + 1) { a[x].count++; strcpy(a[x].one[i], temp1); Union(temp2, temp4, i, x); } } void ans(int x) { int arg[1010], l = 0, sign; if (a[x].flag == 1) { printf("unique\n"); return; } for (int i = 1; i < x; i++) { sign = 0; if (a[i].flag == 1) continue; for (int j = 1; j <= a[x].count; j++) { for (int k = 1; k <= a[i].count; k++) if (strcmp(a[x].one[j], a[i].one[k]) == 0) if (a[x].two2[j] < a[i].two1[k] || a[i].two2[k] < a[x].two1[j]) { sign = 1; break; } if (sign == 1) break; } if (sign == 0) arg[l++] = i; } if (l == 0) { printf("unique\n"); return; } else { for (int i = 0; i < l; i++) if (i == l - 1) printf("%d\n", arg[i]); else printf("%d ", arg[i]); } } int main() { int n, where; char b[300], temp1[40], temp2[40], temp3[40]; cin >> n; getchar(); for (int i = 1; i <= n; i++) { gets(b); where = 0; int len = strlen(b); for (int j = 0; j < len;) { if (b[j] == ' ' || b[j] == ',') { j++; continue; } if (where == 0) { int k = 0; while (j < len && b[j] != ' ' && b[j] != ',') temp1[k++] = b[j++]; temp1[k] = '\0'; where = 1; } else if (where == 1) { int k = 0; while (j < len && b[j] != ' ' && b[j] != ',') temp2[k++] = b[j++]; temp2[k] = 0; where = 2; } else { int k = 0; while (j < len && b[j] != ' ' && b[j] != ',') temp3[k++] = b[j++]; temp3[k] = 0; where = 0; if (a[i].flag == 0) deal(temp1, temp2, temp3, i, a[i].count); } } ans(i); } return 0; }