#include <bits/stdc++.h>
using namespace std;
const int N = 500;
const int M = 124750;
const int INF = 1e9;
struct adj {
  int v1, v2, len;
};
adj edge[M];
int minpath[N][N];
int edge_in[N][N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) minpath[i][j] = i == j ? 0 : INF;
  for (int i = 0; i < m; ++i) {
    scanf("%d%d%d", &edge[i].v1, &edge[i].v2, &edge[i].len);
    --edge[i].v1;
    --edge[i].v2;
    minpath[edge[i].v1][edge[i].v2] = minpath[edge[i].v2][edge[i].v1] =
        edge[i].len;
  }
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j)
        minpath[i][j] = min(minpath[i][j], minpath[i][k] + minpath[k][j]);
    }
  }
  for (int e = 0; e < m; ++e) {
    for (int t = 0; t < 2; ++t) {
      for (int i = 0; i < n; ++i)
        if (i != edge[e].v1) {
          if (minpath[i][edge[e].v2] + edge[e].len == minpath[i][edge[e].v1])
            ++edge_in[i][edge[e].v1];
        }
      swap(edge[e].v1, edge[e].v2);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int ans = 0;
      for (int k = 0; k < n; ++k)
        if (k != i) {
          if (minpath[i][k] + minpath[k][j] == minpath[i][j])
            ans += edge_in[i][k];
        }
      printf("%d ", ans);
    }
  }
  printf("\n");
  return 0;
}
