#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = 1e9;
const long long ninf = LLONG_MIN;
const double eps = 1e-12;
const long long N = 1000005;
const long long LOGN = 19;
const double PI = 3.14159265358979323846;
long long n, m;
long long d[505][505], is[505][505], ini[505][505], last[505][505];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < 505; i++)
    for (int j = 0; j < 505; j++) d[i][j] = inf, ini[i][j] = inf;
  for (int i = 0; i < m; i++) {
    long long x, y, l;
    cin >> x >> y >> l;
    d[x][y] = l;
    d[y][x] = l;
    ini[x][y] = l;
    ini[y][x] = l;
    is[x][y] = 1;
    is[y][x] = 1;
  }
  for (int i = 1; i <= n; i++) d[i][i] = 0;
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int k = 1; k <= n; k++) {
      for (int j = 1; j <= n; j++) {
        if (d[i][j] == inf) continue;
        if (d[i][k] + ini[k][j] == d[i][j]) {
          last[i][j]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      long long ans = 0;
      for (int k = 1; k <= n; k++) {
        if (d[i][k] + d[k][j] == d[i][j]) {
          ans += last[i][k];
        }
      }
      cout << ans << " ";
    }
  }
  cout << "\n";
  return 0;
}
