#include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n, m; int p[N]; struct Node { int a, b; char op; } s[N]; int find(int x) { if (p[x] != x) p[x] = find(p[x]); return p[x]; } void merge(int a, int b) { int pa = find(a), pb = find(b); p[pa] = pb; } bool same(int a, int b) { return find(a) == find(b); } bool check(int a, int b, char c) { if (c == '=') { if (same(a, b + n) || same(a + n, b)) return false; merge(a, b); merge(a + n, b + n); merge(a + n + n, b + n + n); } else if (c == '>') { if (same(a, b) || same(a + n, b)) return false; merge(a, b + n); merge(a + n, b + n + n); merge(a + n + n, b); } else { if (same(a, b) || same(a, b + n)) return false; merge(a + n, b); merge(a + n + n, b + n); merge(a, b + n + n); } return true; } void solve() { while (cin >> n >> m) { for (int i = 1; i <= m; i ++) { int a, b; char op; cin >> a >> op >> b; s[i] = {a, b, op}; } // 记录裁判的个数 int cnt = 0; // 记录裁判的编号 int res = 0; // 记录得到裁判信息的行号 int the_line = 0; // 假设编号为 t 的人是裁判 for (int t = 0; t < n; t ++) { // 每次都要将集合初始化 for (int i = 0; i < 3 * n; i ++) p[i] = i; bool is_ok = true; for (int i = 1; i <= m; i ++) { auto& [a, b, op] = s[i]; // 将裁判跳过 if (a == t || b == t) continue; // 检查是否合法,合法则合并集合,不会进入if中 if (!check(a, b, op)) { // 不合法才会进入 is_ok = false; // 其他人不是裁判的最大轮数 if (the_line <= i) the_line = i; break; } } if (is_ok) { res = t; cnt ++; } } if (!cnt) printf("Impossible\n"); else if (cnt > 1) printf("Can not determine\n"); else printf("Player %d can be determined to be the judge after %d lines\n", res, the_line); } } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); solve(); return 0; }