#include <bits/stdc++.h>
using namespace std;
const int N = 510;
int mp[N][N], cnt[N], ans[N][N];
struct line {
  int x;
  int y;
  int d;
} edge[N * N];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j) {
        mp[i][j] = 0;
      } else {
        mp[i][j] = 0x3f3f3f3f;
      }
    }
  }
  memset(ans, 0, sizeof(ans));
  for (int i = 1; i <= m; i++) {
    cin >> edge[i].x >> edge[i].y >> edge[i].d;
    mp[edge[i].x][edge[i].y] = mp[edge[i].y][edge[i].x] = edge[i].d;
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        mp[i][j] = min(mp[i][j], mp[i][k] + mp[k][j]);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    memset(cnt, 0, sizeof(cnt));
    for (int j = 1; j <= m; j++) {
      if (mp[edge[j].x][i] == edge[j].d + mp[edge[j].y][i]) {
        cnt[edge[j].x]++;
      }
      if (mp[edge[j].y][i] == edge[j].d + mp[edge[j].x][i]) {
        cnt[edge[j].y]++;
      }
    }
    for (int j = i + 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        if (mp[i][j] == mp[i][k] + mp[k][j]) {
          ans[i][j] += cnt[k];
        }
      }
    }
  }
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      cout << ans[i][j] << " ";
    }
  }
  cout << endl;
}
