#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
const double Dlt = 0.97;
const int inf = 0x3f3f3f3f;
const long long INF = 1e18;
const int maxn = 500 + 10;
const int maxm = (1 << 26) + 10;
const int mod = 1000000000 + 7;
int gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline long long read() {
  char ch = getchar();
  long long x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int dis[maxn][maxn], e[maxn][maxn], f[maxn][maxn];
int n, m;
void floyd() {
  for (int k = 1; k <= n; ++k) {
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= n; ++j) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }
}
int main() {
  memset(dis, 0, sizeof inf);
  memset(e, inf, sizeof e);
  memset(f, 0, sizeof f);
  n = read(), m = read();
  for (int i = 1; i <= m; ++i) {
    int x = read(), y = read(), z = read();
    e[x][y] = e[y][x] = z;
  }
  memcpy(dis, e, sizeof e);
  for (int i = 1; i <= n; ++i) dis[i][i] = 0;
  floyd();
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      for (int k = 1; k <= n; ++k) {
        if (e[i][j] != inf && e[i][j] + dis[j][k] == dis[i][k]) {
          f[i][k]++;
        }
      }
    }
  }
  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 (dis[i][j] == dis[i][k] + dis[k][j]) ans += f[k][j];
      }
      printf("%d ", ans);
    }
  }
}
