#include <bits/stdc++.h>
using namespace std;
void scan(int &n) {
  char c;
  while (c = getchar()) {
    if (c >= '0' && c <= '9') break;
  }
  n = c - '0';
  while (c = getchar()) {
    if (!(c >= '0' && c <= '9')) break;
    n = n * 10 + c - '0';
  }
}
int edges[505][505], dist[505][505];
int ind[505];
int main() {
  int n, m;
  scan(n);
  scan(m);
  for (int i = (1); i <= (n); i++)
    for (int j = (1); j <= (n); j++) edges[i][j] = (i != j) ? 1000000000 : 0;
  for (int i = (1); i <= (m); i++) {
    int u, v, w;
    scan(u);
    scan(v);
    scan(w);
    edges[u][v] = min(edges[u][v], w);
    edges[v][u] = min(edges[v][u], w);
  }
  memcpy(dist, edges, sizeof(edges));
  for (int k = (1); k <= (n); k++)
    for (int i = (1); i <= (n); i++)
      for (int j = (1); j <= (n); j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
  for (int i = (1); i <= (n); i++) {
    for (int j = (1); j <= (n); j++) ind[j] = 0;
    for (int j = (1); j <= (n); j++)
      for (int k = (1); k <= (n); k++) {
        if (j == k || dist[i][j] == 1000000000 || edges[j][k] == 1000000000 ||
            dist[i][k] == 1000000000 || dist[i][j] + edges[j][k] != dist[i][k])
          continue;
        ind[k]++;
      }
    for (int k = (i + 1); k <= (n); k++) {
      int cnt = 0;
      for (int j = (1); j <= (n); j++) {
        if (dist[i][j] == 1000000000 || dist[i][k] == 1000000000 ||
            dist[j][k] == 1000000000 || dist[i][j] + dist[j][k] != dist[i][k])
          continue;
        cnt += ind[j];
      }
      printf("%d ", cnt);
    }
  }
  printf("\n");
  return 0;
}
