#include <bits/stdc++.h>
using namespace std;
struct edge {
  int from;
  int to;
  int wei;
};
int dis[501][501], ans[501][501];
vector<edge> edges;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      dis[i][j] = 1e9;
    }
    dis[i][i] = 0;
  }
  int x, y, w;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &x, &y, &w);
    dis[x][y] = dis[y][x] = w;
    edges.push_back({x, y, w});
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        dis[j][i] = dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 1; j <= n; j++) {
      if (dis[j][edges[i].to] + edges[i].wei == dis[j][edges[i].from])
        ans[j][edges[i].from]++;
      if (dis[j][edges[i].from] + edges[i].wei == dis[j][edges[i].to])
        ans[j][edges[i].to]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int c = 0;
      for (int k = 1; k <= n; k++) {
        if (dis[i][k] + dis[k][j] == dis[i][j]) c += ans[i][k];
      }
      printf("%d ", c);
    }
  }
  return 0;
}
