#include <bits/stdc++.h>
const int N = 510;
const int INF = 0x3f3f3f3f;
int n, m;
int g[N][N], dis[N][N];
int ans[N][N];
int cnt[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      g[i][j] = INF, dis[i][j] = ((i == j) ? 0 : INF);
  for (int i = 1; i <= m; ++i) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    dis[u][v] = dis[v][u] = g[u][v] = g[v][u] = w;
  }
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j)
        dis[i][j] = std::min(dis[i][j], dis[i][k] + dis[k][j]);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) cnt[j] = 0;
    for (int j = 1; j <= n; ++j)
      for (int k = 1; k <= n; ++k)
        if (dis[i][j] == dis[i][k] + g[k][j]) ++cnt[j];
    for (int j = 1; j <= n; ++j)
      for (int k = 1; k <= n; ++k)
        if (dis[i][j] == dis[i][k] + dis[k][j]) ans[i][j] += cnt[k];
  }
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      printf("%d ", dis[i][j] < INF ? ans[i][j] : 0);
  return 0;
}
