#include <bits/stdc++.h>
using namespace std;
int a[505][505], d[505][505], num[505][505] = {{0}};
int main() {
  int max0 = 1000000000;
  for (int i = 0; i < 505; i++)
    for (int j = 0; j < 505; j++) d[i][j] = a[i][j] = i == j ? 0 : max0;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    a[x][y] = a[y][x] = d[x][y] = d[y][x] = z;
  }
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (d[i][k] != max0 && d[k][j] != max0)
          d[i][j] = min(d[i][k] + d[k][j], d[i][j]);
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) {
        if (a[k][j] && d[i][j] == d[i][k] + a[k][j]) num[i][j]++;
      }
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      int s = 0;
      for (int k = 1; k <= n; k++)
        if (d[i][k] != max0 && d[k][j] != max0 && d[i][k] + d[k][j] == d[i][j])
          s += num[i][k];
      printf("%d ", s);
    }
  puts("");
  return 0;
}
