#include <bits/stdc++.h>
using namespace std;
int n, m, g[505][505];
int dis[505][505];
int tail[505], ans[505][505];
int main() {
  scanf("%d%d", &n, &m);
  memset(dis, 0x3f, sizeof(dis));
  memset(g, 0x3f, sizeof(g));
  int INF = dis[0][0];
  for (int i = 1; i <= n; i++) dis[i][i] = 0;
  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] = min(dis[i][j], dis[i][k] + dis[k][j]);
  for (int i = 1; i <= n; i++) {
    memset(tail, 0, sizeof(tail));
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++)
        if (dis[i][k] + g[k][j] == dis[i][j]) tail[j]++;
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++)
        if (dis[i][k] + dis[k][j] == dis[i][j]) ans[i][j] += tail[k];
  }
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      if (dis[i][j] == INF) ans[i][j] = 0;
      printf("%d ", ans[i][j]);
    }
  return 0;
}
