#include <bits/stdc++.h>
using namespace std;
int n, m;
int maz[510][510], ans[510][510];
int cnt[510];
struct edge {
  int u, v, w;
} ed[510 * 510];
int main() {
  int i, j, k;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) maz[i][j] = 2147483647;
    maz[i][i] = 0;
  }
  for (i = 1; i <= m; i++) {
    scanf("%d%d%d", &ed[i].u, &ed[i].v, &ed[i].w);
    maz[ed[i].u][ed[i].v] = maz[ed[i].v][ed[i].u] = ed[i].w;
  }
  for (k = 1; k <= n; k++) {
    for (i = 1; i <= n; i++) {
      if (i == k || maz[i][k] == 2147483647) continue;
      for (j = 1; j <= n; j++) {
        if (j == i || j == k || maz[k][j] == 2147483647) continue;
        maz[i][j] = min(maz[i][j], maz[i][k] + maz[k][j]);
      }
    }
  }
  for (j = 1; j <= n; j++) {
    memset(cnt, 0, sizeof(cnt));
    for (i = 1; i <= m; i++) {
      if (maz[ed[i].u][j] == maz[ed[i].v][j] + ed[i].w) cnt[ed[i].u]++;
      if (maz[ed[i].v][j] == maz[ed[i].u][j] + ed[i].w) cnt[ed[i].v]++;
    }
    for (i = j - 1; i >= 1; i--) {
      for (k = 1; k <= n; k++) {
        if (maz[i][k] + maz[k][j] == maz[i][j]) ans[i][j] += cnt[k];
      }
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = i + 1; j <= n; j++)
      printf("%d%s", ans[i][j], (i == n - 1 && j == n) ? "\n" : " ");
  }
  return 0;
}
