#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int count[505][505];
  memset(count, 0x3f3f3f3f, sizeof(count));
  while (m--) {
    int u, v, w;
    scanf("%d %d %d", &u, &v, &w);
    u--;
    v--;
    count[u][v] = count[v][u] = w;
  }
  int dist[505][505];
  memcpy(dist, count, sizeof(count));
  for (int i = 0; i < n; i++) dist[i][i] = 0;
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }
  }
  int dp[505][505];
  for (int i = 0; i < n; i++) {
    for (int k = 0; k < n; k++) {
      for (int j = 0; j < n; j++) {
        if (count[i][k] != 0x3f3f3f3f && dist[i][j] == count[i][k] + dist[k][j])
          dp[i][j]++;
      }
    }
  }
  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 (dist[i][j] == dist[i][k] + dist[k][j]) ans += dp[k][j];
      printf("%d ", ans, ' ');
    }
  }
  printf("\n");
  return 0;
}
