#include <bits/stdc++.h>
using namespace std;
const int MAXV = 505;
const int INF = 111111111;
int n, m, d[MAXV][MAXV], sp[MAXV][MAXV], cnt[MAXV][MAXV];
bool reached[MAXV][MAXV];
void floyd() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) sp[i][j] = d[i][j];
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (i != j && j != k && k != i && sp[i][k] + sp[k][j] < sp[i][j])
          sp[i][j] = sp[i][k] + sp[k][j];
  for (int i = 1; i <= n; i++) sp[i][i] = 0;
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (k != j && sp[i][k] + d[k][j] == sp[i][j]) cnt[i][j]++;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) d[i][j] = INF;
  for (int i = 1; i <= m; i++) {
    int v, u, w;
    cin >> v >> u >> w;
    d[v][u] = d[u][v] = w;
  }
  floyd();
  vector<int> res;
  res.clear();
  for (int s = 1; s < n; s++)
    for (int t = s + 1; t <= n; t++)
      if (sp[s][t] != INF) {
        int tmp = 0;
        for (int k = 1; k <= n; k++)
          if (sp[s][k] + sp[k][t] == sp[s][t]) tmp += cnt[s][k];
        res.push_back(tmp);
      } else
        res.push_back(0);
  for (int i = 0; i < (int)res.size() - 1; i++) cout << res[i] << ' ';
  cout << res[(int)res.size() - 1] << endl;
  return 0;
}
