#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12 + 100;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, x, y, l;
  cin >> n >> m;
  vector<pair<long long, long long>> g[550];
  vector<pair<pair<long long, long long>, long long>> es;
  while (m--) {
    cin >> x >> y >> l;
    g[x].push_back(make_pair(y, l));
    g[y].push_back(make_pair(x, l));
    es.push_back(make_pair(make_pair(x, y), l));
  }
  long long dist[n + 1][n + 1];
  long long dp[n + 1][n + 1];
  long long edges[n + 1][n + 1];
  bool mark[n + 1];
  for (int i = 1; i <= n; i++) {
    priority_queue<pair<long long, long long>,
                   vector<pair<long long, long long>>,
                   greater<pair<long long, long long>>>
        s;
    fill(dist[i], dist[i] + n + 1, INF);
    fill(dp[i], dp[i] + n + 1, 0);
    fill(edges[i], edges[i] + n + 1, 0);
    fill(mark, mark + n + 1, false);
    dist[i][i] = 0;
    s.push(make_pair(0, i));
    while (s.size()) {
      pair<long long, long long> w = s.top();
      s.pop();
      if (mark[w.second]) continue;
      mark[w.second] = true;
      for (vector<pair<long long, long long>>::iterator it =
               g[w.second].begin();
           it != g[w.second].end(); it++) {
        if (dist[i][it->first] > w.first + it->second) {
          dist[i][it->first] = w.first + it->second;
          s.push(make_pair(w.first + it->second, it->first));
        }
      }
    }
  }
  for (int i = 1; i <= n; i++)
    for (pair<pair<long long, long long>, long long> e : es) {
      if (e.second + dist[i][e.first.first] == dist[i][e.first.second])
        edges[i][e.first.second]++;
      if (e.second + dist[i][e.first.second] == dist[i][e.first.first])
        edges[i][e.first.first]++;
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++)
        if (dist[i][j] == dist[i][k] + dist[k][j]) dp[i][j] += edges[i][k];
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) cout << dp[j][i] << " ";
  cout << endl;
  return 0;
}
