#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int dist[501][501];
int INF = 1000000000;
int s[501][501];
int c[501][501];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      dist[i][j] = INF;
      c[i][j] = INF;
    }
  memset(s, 0, sizeof(s));
  for (int i = 1; i <= n; i++) {
    dist[i][i] = 0;
  }
  for (int i = 1; i <= m; i++) {
    int x, y, l;
    cin >> x >> y >> l;
    dist[x][y] = l;
    dist[y][x] = l;
    c[x][y] = l;
    c[y][x] = l;
  }
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) {
        if (dist[i][k] + dist[k][j] < dist[i][j]) {
          dist[i][j] = dist[i][k] + dist[k][j];
        }
      }
  memset(s, 0, sizeof(s));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++)
        if (c[k][j] && dist[i][k] + c[k][j] == dist[i][j]) s[i][j]++;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      int ans = 0;
      for (int k = 1; k <= n; k++)
        if (dist[i][k] < INF && dist[k][j] < INF)
          if (dist[i][k] + dist[k][j] == dist[i][j]) ans += s[i][k];
      cout << ans << " ";
    }
  return 0;
}
