Problem: You are given a directed acyclic graph (a directed graph that does not contain cycles) of n vertices and m arcs. The i-th arc leads from the vertex x_i to the vertex y_i and has the weight w_i.

Your task is to select an integer a_v for each vertex v, and then write a number b_i on each arcs i such that b_i = a_{x_i} - a_{y_i}. You must select the numbers so that:

  * all b_i are positive; 
  * the value of the expression ∑ _{i = 1}^{m} w_i b_i is the lowest possible. 



It can be shown that for any directed acyclic graph with non-negative w_i, such a way to choose numbers exists.

Input

The first line contains two integers n and m (2 ≤ n ≤ 18; 0 ≤ m ≤ (n(n - 1))/(2)).

Then m lines follow, the i-th of them contains three integers x_i, y_i and w_i (1 ≤ x_i, y_i ≤ n, 1 ≤ w_i ≤ 10^5, x_i ≠ y_i) — the description of the i-th arc.

It is guaranteed that the lines describe m arcs of a directed acyclic graph without multiple arcs between the same pair of vertices.

Output

Print n integers a_1, a_2, ..., a_n (0 ≤ a_v ≤ 10^9), which must be written on the vertices so that all b_i are positive, and the value of the expression ∑ _{i = 1}^{m} w_i b_i is the lowest possible. If there are several answers, print any of them. It can be shown that the answer always exists, and at least one of the optimal answers satisfies the constraints 0 ≤ a_v ≤ 10^9.

Examples

Input


3 2
2 1 4
1 3 2


Output


1 2 0


Input


5 4
1 2 1
2 3 1
1 3 6
4 5 8


Output


43 42 41 1337 1336


Input


5 5
1 2 1
2 3 1
3 4 1
1 5 1
5 4 10


Output


4 3 2 1 2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int N = 5e5 + 5, M = 1000000007, INF = 0x3f3f3f3f;
const ll LNF = 0x3f3f3f3f3f3f3f3f;
void Main();
void debug() { cerr << endl; }
template <typename T, typename... Ts>
void debug(T x, Ts... y) {
  cerr << "\033[31m" << x << "\033[0m";
  if (sizeof...(y) > 0) cerr << ' ';
  debug(y...);
}
template <typename T>
void debug(const T& a, int l, int r, char c) {
  for (int i = l; i <= r; ++i)
    cerr << "\033[31m" << a[i] << "\033[0m" << (i == r ? '\n' : c);
}
template <typename T>
void debug(vector<T> a) {
  for (int i = 0; i < (int)a.size(); ++i)
    cout << "\033[31m" << a[i] << "\033[0m"
         << " \n"[i == (int)a.size() - 1];
}
void print() { cout << '\n'; }
template <typename T, typename... Ts>
void print(T x, Ts... y) {
  cout << x;
  if (sizeof...(y) > 0) cout << ' ';
  print(y...);
}
template <typename T>
void print(const T& a, int l, int r, char c) {
  for (int i = l; i <= r; ++i) cout << a[i] << (i == r ? '\n' : c);
}
template <typename T>
void print(vector<T> a) {
  for (int i = 0; i < (int)a.size(); ++i)
    cout << a[i] << " \n"[i == (int)a.size() - 1];
}
void input() {}
template <typename T, typename... Ts>
void input(T& x, Ts&... y) {
  cin >> x;
  input(y...);
}
template <typename T>
void input(T* a, int l, int r) {
  for (int i = l; i <= r; ++i) cin >> a[i];
}
template <typename T>
void input(vector<T>& a, int l, int r) {
  for (int i = l; i <= r; ++i) cin >> a[i];
}
template <typename T>
void input(vector<T> a) {
  for (auto&& x : a) input(a);
}
template <typename T>
void Max(T& a, T b) {
  if (a < b) a = b;
}
template <typename T>
void Min(T& a, T b) {
  if (a > b) a = b;
}
template <typename T>
void Add(T& a, T b) {
  a += b;
  if (a > M) a -= M;
  if (a < 0) a += M;
}
template <typename T>
void Mul(T& a, T b) {
  a = a * b % M;
}
template <typename T>
T Mod(T a) {
  return (a % M + M) % M;
}
ll qpow(ll a, ll b) {
  ll ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % M;
    a = a * a % M, b >>= 1;
  }
  return ret;
}
ll pinv(ll x, ll mod = M) { return qpow(x, mod - 2); }
template <typename... Args>
string sformat(const string& format, Args... args) {
  size_t size = snprintf(nullptr, 0, format.c_str(), args...) + 1;
  unique_ptr<char[]> buf(new char[size]);
  snprintf(buf.get(), size, format.c_str(), args...);
  return string(buf.get(), buf.get() + size - 1);
}
int main(int argc, char** argv) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  Main();
}
template <typename T, int N, T oo>
struct Dinic {
  int n, s, t;
  struct edge {
    int v;
    T w;
    int rev;
  };
  vector<edge> G[N];
  void add(int u, int v, T w) {
    G[u].push_back({v, w, (int)G[v].size()});
    G[v].push_back({u, 0, (int)G[u].size() - 1});
  }
  void init(int n_) {
    n = n_;
    for (int i = 0; i <= n; i++) G[i].clear();
  }
  int dis[N], cur[N];
  bool bfs() {
    fill(dis, dis + n + 1, -1);
    fill(cur, cur + n + 1, 0);
    dis[s] = 0;
    queue<int> q;
    q.push(s);
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (edge& e : G[u])
        if (e.w && dis[e.v] == -1) {
          dis[e.v] = dis[u] + 1;
          q.push(e.v);
        }
    }
    return dis[t] != -1;
  }
  T dfs(int u, T f) {
    if (u == t) return f;
    T used = 0;
    for (int& i = cur[u]; i < (int)G[u].size() && f > used; i++) {
      int v = G[u][i].v;
      T &w = G[u][i].w, &revw = G[v][G[u][i].rev].w;
      if (dis[v] != dis[u] + 1 || w <= 0) continue;
      T t = dfs(v, min(f - used, w));
      used += t;
      w -= t;
      revw += t;
    }
    return used;
  }
  T maxflow(int s_, int t_) {
    s = s_, t = t_;
    T ans = 0;
    while (bfs()) ans += dfs(s, oo);
    return ans;
  }
};
Dinic<ll, 405, INF> F;
int a[405], ans[20];
bitset<405> vis;
void dfs(int u, int n, decltype(F.G)& G) {
  vis[u] = true;
  for (auto [v, w, ignore] : G[u])
    if (!vis[v]) {
      if (w == 0) {
        if (u == v - 1) {
          int x = (u - 1) / (n + 1) + 1;
          ans[x] = u - ((x - 1) * (n + 1) + 1);
        }
      } else {
        dfs(v, n, G);
      }
    }
}
vector<int> G[N];
void Main() {
  int n, m;
  input(n, m);
  for (int i = 1; i <= m; ++i) {
    int x, y, w;
    input(x, y, w);
    G[y].push_back(x);
    a[x] += w;
    a[y] -= w;
  }
  const int S = n * (n + 1) + 1, T = S + 1,
            U = -min(0, *min_element(a + 1, a + n + 1) * (n - 1));
  F.init(T);
  for (int i = 1, u = 1, v = 2; i <= n; ++i) {
    F.add(S, u, INF);
    for (int j = 0; j < n; ++j) {
      F.add(u, v, j * a[i] + U);
      for (int x : G[i]) {
        x = (x - 1) * (n + 1) + 1 + j + 1;
        F.add(u, x, INF);
      }
      ++u;
      ++v;
    }
    F.add(u, T, INF);
    ++u;
    ++v;
  }
  F.maxflow(S, T);
  dfs(S, n, F.G);
  print(ans, 1, n, ' ');
}