#include <bits/stdc++.h>
using namespace std;
const int inf = 987654321;
int N, M;
vector<vector<pair<int, int> > > adj;
vector<vector<int> > dist;
void get_dist() {
  dist = vector<vector<int> >(N, vector<int>(N, inf));
  for (int i = 0; i < N; i++) {
    dist[i][i] = 0;
    for (int j = 0; j < adj[i].size(); j++) {
      int k = adj[i][j].first;
      int d = adj[i][j].second;
      dist[i][k] = d;
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
    }
  }
}
int main() {
  scanf("%d %d", &N, &M);
  adj.resize(N);
  for (int i = 0; i < M; i++) {
    int x, y, l;
    scanf("%d %d %d", &x, &y, &l);
    x--;
    y--;
    adj[x].push_back(pair<int, int>(y, l));
    adj[y].push_back(pair<int, int>(x, l));
  }
  get_dist();
  for (int s = 0; s < N; s++) {
    vector<int> cnt(N);
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < adj[i].size(); j++) {
        int k = adj[i][j].first;
        int d = adj[i][j].second;
        if (dist[s][i] == dist[s][k] + d) {
          cnt[i]++;
        }
      }
    }
    for (int t = s + 1; t < N; t++) {
      int ans = 0;
      for (int m = 0; m < N; m++) {
        if (dist[s][m] + dist[m][t] == dist[s][t]) {
          ans += cnt[m];
        }
      }
      printf("%d ", ans);
    }
  }
}
