text: push_back(make_pair(min(x[i], y[i]), i)); } for (register int i = (1); i <= (n); i++) { for (register int it = (0); it < (int(e[i].size())); it++) { if (!v[e[i][it].first]) { v[e[i][it].first] = 1; w[e[i][it].second] = 0; s[i]--; } in[s[e[i][it].first]] = 1; } for (register int it = (0); it < (int(e[i].size())); it++) { if (!in[s[i]]) break; s[i]++; v[e[i][it].first] = 0; w[e[i][it].second]++; } for (register int it = (0); it < (int(e[i].size())); it++) in[s[e[i][it].first]] = 0; } for (register int i = (1); i <= (n); i++) if (v[i]) res.push_back(i); writeln(int(res.size())); for (register int it = (0); it < (int(res.size())); it++) writeln(res[it], ' '); puts(""); for (register int i = (1); i <= (m); i++) { writeln(x[i], ' '); writeln(y[i], ' '); writeln(w[i]); } return 0; }