#include <bits/stdc++.h>
using namespace std;
const int N = 505;
const int INF = 0x3f3f3f3f;
int e[N][N];
int dis[N][N];
int cnt[N][N];
void Floyd(int n) {
  for (int i = 0; i < n; i++) {
    dis[i][i] = 0;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }
}
int main() {
  memset(e, INF, sizeof(e));
  int n, m, u, v, c;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &u, &v, &c);
    u--, v--;
    e[u][v] = e[v][u] = c;
  }
  memcpy(dis, e, sizeof(dis));
  Floyd(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (e[k][j] != INF && dis[i][k] + e[k][j] == dis[i][j]) {
          cnt[i][j]++;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int anss = 0;
      for (int k = 0; k < n; k++) {
        if (dis[i][k] + dis[k][j] == dis[i][j]) {
          anss += cnt[i][k];
        }
      }
      printf("%d ", anss);
    }
  }
  return 0;
}
