#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
const int mod = 1e9 + 7;
void IOS() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void FRE() {
  freopen(
      "Test"
      ".inp",
      "r", stdin);
  freopen(
      "Test"
      ".out",
      "w", stdout);
}
const int N = 505;
int n, m;
std::vector<pair<int, int> > Adj[N];
int d[N];
int Ans[N][N];
int cnt[N];
int f[N][N];
int main() {
  IOS();
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      f[i][j] = INF;
    }
    f[i][i] = 0;
  }
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    Adj[u].push_back(pair<int, int>(w, v));
    Adj[v].push_back(pair<int, int>(w, u));
    f[u][v] = f[v][u] = min(f[u][v], w);
  }
  for (int k = 1; k <= n; k++) {
    for (int u = 1; u <= n; u++) {
      for (int v = 1; v <= n; v++) {
        f[u][v] = min(f[u][v], f[u][k] + f[k][v]);
      }
    }
  }
  for (int v = 2; v <= n; v++) {
    for (int u = 1; u <= n; u++) {
      d[u] = INF;
      cnt[u] = 1;
      for (int i = 0; i < Adj[u].size(); i++) {
        int k = Adj[u][i].second;
        int w = Adj[u][i].first + f[k][v];
        if (d[u] > w) {
          d[u] = w;
          cnt[u] = 1;
        } else {
          if (d[u] == w) {
            cnt[u]++;
          }
        }
      }
    }
    for (int u = 1; u < v; u++) {
      if (f[u][v] == INF) {
        Ans[u][v] = 0;
        continue;
      }
      for (int k = 1; k <= n; k++) {
        if (f[u][v] == f[u][k] + d[k]) {
          Ans[u][v] += cnt[k];
        }
      }
    }
  }
  for (int u = 1; u <= n; u++) {
    for (int v = u + 1; v <= n; v++) {
      cout << Ans[u][v] << " ";
    }
  }
  return 0;
}
