#include <bits/stdc++.h>
using namespace std;
vector<int> in[510][510];
vector<int> con[510];
int dap, d[510][510], n, m, x, y, z, edge[510][510], cnt[510];
int main() {
  int i, j, k;
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      d[i][j] = 1e9;
      if (i == j) d[i][j] = 0;
    }
  }
  for (i = 1; i <= m; i++) {
    scanf("%d %d %d", &x, &y, &z);
    d[x][y] = edge[x][y] = z;
    d[y][x] = edge[y][x] = z;
    con[y].push_back(x);
    con[x].push_back(y);
  }
  for (k = 1; k <= n; k++) {
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= n; j++) {
        if (d[i][j] > d[i][k] + d[k][j]) d[i][j] = d[i][k] + d[k][j];
      }
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      if (i == j) continue;
      for (k = 0; k < con[j].size(); k++) {
        x = con[j][k];
        if (d[i][x] + edge[x][j] == d[i][j]) cnt[j]++;
      }
    }
    for (j = i + 1; j <= n; j++) {
      dap = 0;
      for (k = 1; k <= n; k++) {
        if (i == k) continue;
        if (d[i][k] + d[k][j] == d[i][j]) dap += cnt[k];
      }
      printf("%d ", dap);
    }
    memset(cnt, 0, sizeof cnt);
  }
}
