#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
int N, M, i, j, k, z, x, y, xx, yy;
int f[505][505], CNT[505][505], ANS[505][505];
vector<pair<int, int> > G[505];
int main() {
  cin >> N >> M;
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) f[i][j] = inf;
  for (int i = 1; i <= N; i++) f[i][i] = 0;
  for (int i = 1; i <= M; i++) {
    cin >> x >> y >> z;
    f[x][y] = min(f[x][y], z);
    f[y][x] = min(f[y][x], z);
    G[x].push_back(make_pair(y, z));
    G[y].push_back(make_pair(x, z));
  }
  for (int k = 1; k <= N; k++)
    for (int i = 1; i <= N; i++)
      for (int j = 1; j <= N; j++) f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) {
      for (int z = 0; z < (int)G[j].size(); z++) {
        xx = G[j][z].first;
        yy = G[j][z].second;
        if (f[i][xx] + yy == f[i][j]) CNT[i][j]++;
      }
    }
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++)
      for (int k = 1; k <= N; k++)
        if (f[i][k] + f[k][j] == f[i][j]) ANS[i][j] += CNT[i][k];
  for (int i = 1; i <= N; i++)
    for (int j = i + 1; j <= N; j++) printf("%d ", ANS[i][j]);
  return 0;
}
