#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
int num[501][501];
int dist[501][501];
int gr[501][501];
int cnt[501][501];
int ans[501][501];
int n, m;
void reset() {
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= n; j++) dist[i][j] = inf;
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= n; j++) gr[i][j] = inf;
}
int main() {
  cin >> n >> m;
  reset();
  for (long long i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    dist[x][y] = min(dist[x][y], z);
    dist[y][x] = min(dist[y][x], z);
    gr[x][y] = z;
    gr[y][x] = z;
  }
  for (long long i = 1; i <= n; i++) dist[i][i] = 0;
  for (long long k = 1; k <= n; k++)
    for (long long i = 1; i <= n; i++)
      for (long long j = 1; j <= n; j++)
        dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= n; j++)
      for (long long k = 1; k <= n; k++) {
        if (dist[i][k] == inf || gr[k][j] == inf || dist[i][j] == inf) continue;
        if (dist[i][j] == dist[i][k] + gr[k][j]) cnt[i][j]++;
      }
  for (long long i = 1; i <= n; i++) {
    for (long long j = i + 1; j <= n; j++) {
      int ans = 0;
      for (long long k = 1; k <= n; k++)
        if (dist[i][j] == dist[i][k] + dist[k][j]) ans += cnt[i][k];
      cout << ans << " ";
    }
  }
}
