#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n, m, t, a, b;
vector <vector <int>> g(2e5 + 1);
vector <bool> ent(2e5 + 1, false);
vector <bool> lef(2e5 + 1, false);
vector <int> tp;
vector <int> ans(2e5 + 1, 0);
void get_tp(int x) {
if (ent[x] && !lef[x]) { cout << "NEM"; exit(0); }
if (ent[x]) return;
ent[x] = true;
for (int i : g[x]) get_tp(i);
lef[x] = true;
tp.push_back(x);
}
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; i++) g[i].push_back(i + n);
for (int i = 0; i < m; i++) {
cin >> t >> a >> b;
if (t == 1) {
g[a].push_back(b + n);
g[b].push_back(a + n);
}
if (t == 2) g[a + n].push_back(b);
}
for (int i = 1; i <= n; i++) get_tp(i);
reverse(tp.begin(), tp.end());
for (int i = 0; i < 2 * n; i++) ans[tp[i]] = i + 1;
cout << "IGEN\n";
for (int i = 1; i <= n; i++) cout << ans[i] << " " << ans[i + n] << endl;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 8ms | 12720 KiB | ||||
2 | Accepted | 7ms | 12916 KiB | ||||
3 | Accepted | 10ms | 13712 KiB | ||||
subtask2 | 5/5 | ||||||
4 | Accepted | 328ms | 23160 KiB | ||||
5 | Accepted | 275ms | 22236 KiB | ||||
6 | Accepted | 268ms | 21736 KiB | ||||
subtask3 | 15/15 | ||||||
7 | Accepted | 8ms | 13444 KiB | ||||
8 | Accepted | 8ms | 13680 KiB | ||||
9 | Accepted | 8ms | 13788 KiB | ||||
10 | Accepted | 7ms | 13860 KiB | ||||
11 | Accepted | 7ms | 14076 KiB | ||||
12 | Accepted | 7ms | 14128 KiB | ||||
subtask4 | 10/10 | ||||||
13 | Accepted | 7ms | 14128 KiB | ||||
14 | Accepted | 7ms | 14272 KiB | ||||
15 | Accepted | 6ms | 14200 KiB | ||||
16 | Accepted | 7ms | 14196 KiB | ||||
17 | Accepted | 7ms | 14200 KiB | ||||
subtask5 | 35/35 | ||||||
18 | Accepted | 7ms | 14460 KiB | ||||
19 | Accepted | 8ms | 14524 KiB | ||||
20 | Accepted | 335ms | 27300 KiB | ||||
21 | Accepted | 344ms | 27244 KiB | ||||
22 | Accepted | 7ms | 14980 KiB | ||||
23 | Accepted | 8ms | 15056 KiB | ||||
24 | Accepted | 112ms | 25296 KiB | ||||
subtask6 | 35/35 | ||||||
25 | Accepted | 335ms | 25608 KiB | ||||
26 | Accepted | 296ms | 25656 KiB | ||||
27 | Accepted | 321ms | 25668 KiB | ||||
28 | Accepted | 326ms | 25608 KiB | ||||
29 | Accepted | 112ms | 24444 KiB | ||||
30 | Accepted | 298ms | 25968 KiB | ||||
31 | Accepted | 347ms | 25636 KiB | ||||
32 | Accepted | 119ms | 24424 KiB | ||||
33 | Accepted | 112ms | 25576 KiB | ||||
34 | Accepted | 370ms | 25936 KiB | ||||
35 | Accepted | 115ms | 23912 KiB |