#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, z, sp[505][505], a[505][505], in[505][505];
vector<int> v[505];
bool b[505][505][505];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      sp[i][j] = 1000000000;
    }
  }
  for (int i = 1; i <= n; i++) {
    sp[i][i] = 0;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d", &x, &y, &z);
    sp[x][y] = sp[y][x] = a[x][y] = a[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 (i != j && j != k && k != i) {
          sp[i][j] = min(sp[i][j], sp[i][k] + sp[k][j]);
        }
      }
    }
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (sp[i][j] == sp[i][k] + sp[k][j]) b[i][j][k] = 1;
        if (sp[i][j] == sp[i][k] + a[k][j]) {
          if (a[j][k]) in[i][j]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int cev = 0;
      for (int k = 1; k <= n; k++) {
        if (b[i][j][k] == 1) {
          cev += in[i][k];
        }
      }
      printf("%d ", cev);
    }
  }
  return 0;
}
