func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<pair<pair<int, int>, pair<int, int> > > way[222222];   queue<int> turn;   bool was[222222];   int i, n, m, ans[222222], cost[222222];   int main() {     cin >> n >> m;     for (i = 1; i <= m; i++) {       int a, b, c;       cin >> a >> b >> c;       cost[a] += c;       cost[b] += c;       way[a].push_back(make_pair(make_pair(i, c), make_pair(b, 0)));       way[b].push_back(make_pair(make_pair(i, c), make_pair(a, 1)));     }     for (i = 1; i <= n; i++) cost[i] /= 2;     turn.push(1);     memset(was, 1, sizeof(was));     while (!turn.empty()) {       int t = turn.front();       was[t] = 0;       turn.pop();       for (i = 0; i < way[t].size(); i++)         if (was[way[t][i].second.first]) {           int u = way[t][i].second.first;           ans[way[t][i].first.first] = way[t][i].second.second;           cost[u] -= way[t][i].first.second;           if (cost[u] == 0 && u != n) turn.push(u);         }     }     for (i = 1; i <= m; i++) cout << ans[i] << endl;     return 0;   }   