#include <bits/stdc++.h>
using namespace std;
int n, m, e[500 + 10][500 + 10], dis[500 + 10][500 + 10],
    out[500 + 10][500 + 10];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (int)(1); i <= (int)(n); ++i) {
    for (int j = (int)(1); j <= (int)(n); ++j) {
      dis[i][j] = 1 << 28;
    }
    dis[i][i] = 0;
  }
  for (int i = (int)(1); i <= (int)(m); ++i) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    e[u][v] = w;
    e[v][u] = w;
    dis[u][v] = w;
    dis[v][u] = w;
  }
  for (int k = (int)(1); k <= (int)(n); ++k) {
    for (int i = (int)(1); i <= (int)(n); ++i) {
      for (int j = (int)(1); j <= (int)(n); ++j) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }
  for (int i = (int)(1); i <= (int)(n); ++i) {
    for (int j = (int)(1); j <= (int)(n); ++j) {
      if (e[i][j]) {
        for (int k = (int)(1); k <= (int)(n); ++k) {
          out[i][k] += e[i][j] + dis[j][k] == dis[i][k];
        }
      }
    }
  }
  for (int i = (int)(1); i <= (int)(n); ++i) {
    for (int j = (int)(i + 1); j <= (int)(n); ++j) {
      int ans = 0;
      for (int k = (int)(1); k <= (int)(n); ++k) {
        if (dis[i][k] + dis[k][j] == dis[i][j]) ans += out[k][j];
      }
      printf("%d ", ans);
    }
  }
}
