#include <bits/stdc++.h>
const int N = 500;
const int inf = (int)1e9;
int g[N + 5][N + 5], mp[N + 5][N + 5];
int n, m;
void input() {
  scanf("%d %d", &n, &m);
  for (int i = 0, i_END_ = n; i < i_END_; ++i)
    for (int j = 0, j_END_ = n; j < j_END_; ++j) {
      if (i == j)
        g[i][j] = 0;
      else
        g[i][j] = inf;
    }
  for (int i = 0, i_END_ = m; i < i_END_; ++i) {
    int u, v, val;
    scanf("%d %d %d", &u, &v, &val);
    --u;
    --v;
    g[u][v] = g[v][u] = val;
  }
}
void floyd() {
  for (int i = 0, i_END_ = n; i < i_END_; ++i)
    for (int j = 0, j_END_ = n; j < j_END_; ++j) mp[i][j] = g[i][j];
  for (int k = 0, k_END_ = n; k < k_END_; ++k)
    for (int i = 0, i_END_ = n; i < i_END_; ++i)
      for (int j = 0, j_END_ = n; j < j_END_; ++j)
        mp[i][j] = std::min(mp[i][j], mp[i][k] + mp[k][j]);
}
int ans[N + 5][N + 5];
int in[N + 5];
void solve(int s) {
  for (int i = 0, i_END_ = n; i < i_END_; ++i) in[i] = 0;
  for (int i = 0, i_END_ = n; i < i_END_; ++i)
    for (int j = 0, j_END_ = n; j < j_END_; ++j)
      if (i != j && g[i][j] != inf && mp[s][i] + g[i][j] == mp[s][j]) in[j]++;
  for (int i = 0, i_END_ = n; i < i_END_; ++i) {
    ans[s][i] = 0;
    for (int j = 0, j_END_ = n; j < j_END_; ++j)
      if (mp[s][j] + mp[j][i] == mp[s][i]) ans[s][i] += in[j];
  }
}
void output() {
  for (int i = 0, i_END_ = n; i < i_END_; ++i)
    for (int j = i + 1, j_END_ = n; j < j_END_; ++j) printf("%d ", ans[i][j]);
}
int main() {
  input();
  floyd();
  for (int i = 0, i_END_ = n; i < i_END_; ++i) solve(i);
  output();
  return 0;
}
