#include #include #include #include #include #include #include #include #include #include #include using namespace std; //#define int long long #define FOR(i, a, b) for(int i=(a);i<(b);i++) #define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--) #define REP(i, n) for(int i=0; i<(n); i++) #define RREP(i, n) for(int i=(n-1); i>=0; i--) #define ALL(a) (a).begin(),(a).end() #define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end()); #define CONTAIN(a, b) find(ALL(a), (b)) != (a).end() #define SUM(a) accumulate(ALL(a), 0) #define array2(type, x, y) array, x> #define vector2(type) vector > #define out(...) printf(__VA_ARGS__) /*================================*/ int N, M; typedef pair pos; int pos::*x = &pos::first; int pos::*y = &pos::second; vector< vector > make(200); vector nums(200); vector cache[200]; void dfs(int n, vector *a, int c) { if (cache[n][0]) { REP(i,N) { (*a)[i] += c * cache[n][i]; } return; } if (make[n].size()){ vector b(200); for (pos m : make[n]) { dfs(m.first, &b, m.second); } cache[n] = b; cache[n][0] = 1; REP(i,N) { (*a)[i] += c * cache[n][i]; } } else { (*a)[n] = c; } } signed main() { cin >> N >> M; int P, Q, R; REP(i,M) { cin >> P >> Q >> R; make[R].push_back(pos(P,Q)); } REP(i,201) cache[i].resize(200); dfs(N, &nums, 1); REP(i,N-1) { cout << nums[i+1] << endl; } return 0; }