#include <bits/stdc++.h>
using namespace std;
const int MAX = 510;
const int INF = 1e9 + 7;
vector<vector<int>> G(MAX, vector<int>(MAX, INF)),
    ans(MAX, vector<int>(MAX, 0)), dis(MAX, vector<int>(MAX, INF));
void FloydWarshall(int n) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) dis[i][j] = G[i][j];
  for (int i = 0; i < n; i++) dis[i][i] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (dis[j][i] != INF && dis[k][i] != INF) {
          dis[j][k] = min(dis[j][k], dis[j][i] + dis[i][k]);
        }
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y, l;
    cin >> x >> y >> l;
    x--, y--;
    G[x][y] = G[y][x] = min(G[x][y], l);
  }
  FloydWarshall(n);
  vector<vector<int>> inc(MAX, vector<int>(MAX, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (dis[i][j] == INF) continue;
      for (int k = 0; k < n; k++) {
        if (G[k][j] != INF && G[k][j] + dis[i][k] == dis[i][j]) {
          inc[i][j]++;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (dis[i][j] == INF) continue;
      for (int k = 0; k < n; k++) {
        if (dis[i][k] + dis[k][j] == dis[i][j]) {
          ans[i][j] += inc[i][k];
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      cout << ans[i][j] << ' ';
    }
  }
  cout << '\n';
  return 0;
}
