func_code_string: #include <bits/stdc++.h>   using namespace std;   struct edge {     int v, c, i, d;     edge(int v, int c, int i, int d) : v(v), c(c), i(i), d(d) {}   };   vector<vector<edge> > g(200005);   int n, m, d[200005], f[200005];   int main() {     cin >> n >> m;     for (int _n = m, i = 0; i < _n; ++i) {       int a, b, c;       cin >> a >> b >> c;       a--;       b--;       g[a].push_back(edge(b, c, i, 0));       g[b].push_back(edge(a, c, i, 1));       f[a] += c;       f[b] += c;     }     for (int _n = n, i = 0; i < _n; ++i) f[i] /= 2;     queue<int> Q;     Q.push(0);     memset(d, -1, sizeof(d));     while (!Q.empty()) {       int u = Q.front();       Q.pop();       for (int _n = int((g[u]).size()), i = 0; i < _n; ++i) {         int id = g[u][i].i;         if (d[id] == -1) {           d[id] = g[u][i].d;           int v = g[u][i].v;           f[v] -= g[u][i].c;           if (f[v] == 0 && v != n - 1) Q.push(v);         }       }     }     for (int _n = m, i = 0; i < _n; ++i) cout << d[i] << endl;     return 0;   }   