#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
const int maxn = 505;
const int inf = 1e9 + 7;
int dist[maxn][maxn];
int ed[maxn][maxn];
int cnt[maxn][maxn];
int n, m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i != j) dist[i][j] = dist[j][i] = inf;
    }
  }
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    --u;
    --v;
    dist[u][v] = dist[v][u] = ed[u][v] = ed[v][u] = w;
  }
  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]);
      }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++) {
        if (ed[k][j]) {
          if (dist[i][k] + ed[k][j] == dist[i][j]) {
            cnt[i][j]++;
          }
        }
      }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int res = 0;
      for (int k = 0; k < n; k++) {
        if (dist[i][k] + dist[k][j] == dist[i][j]) {
          res += cnt[i][k];
        }
      }
      cout << res << " ";
    }
  }
  cout << endl;
  return 0;
}
