#include <bits/stdc++.h>
#pragma GCC optimize("O3")
const double PI = acos(-1.0);
using namespace std;
const int N = 509, M = 1000000;
int n, m, dis[N][N], in[N][N], ans[N][N], t[N][N];
vector<int> adj[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n >> m;
  int u, v, d;
  memset(dis, '?', sizeof dis);
  for (int i = 1; i <= m; i++) {
    cin >> u >> v >> d;
    adj[u].push_back(v);
    adj[v].push_back(u);
    dis[u][v] = dis[v][u] = d;
    t[u][v] = t[v][u] = d;
  }
  for (int i = 1; i <= n; i++) dis[i][i] = 0;
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      for (auto k : adj[j]) {
        if (dis[i][k] + t[k][j] == dis[i][j]) in[i][j]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        if (dis[i][k] + dis[k][j] == dis[i][j]) ans[i][j] += in[i][k];
      }
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      if (dis[i][j] >= dis[502][502])
        cout << "0 ";
      else
        cout << ans[i][j] << " ";
    }
  return 0;
}
