#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int n, m, x, y;
struct edge {
  int x, y, l;
} e[500 * 500];
int nrE[502][502], ans[502][502], mat[502][502];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> e[i].x >> e[i].y >> e[i].l;
    mat[e[i].x][e[i].y] = e[i].l;
    mat[e[i].y][e[i].x] = e[i].l;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (i != j && mat[i][j] == 0) mat[i][j] = INF;
    }
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) {
        if (mat[i][k] + mat[k][j] < mat[i][j])
          mat[i][j] = mat[i][k] + mat[k][j];
      }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (e[j].l + mat[i][e[j].y] == mat[i][e[j].x]) nrE[i][e[j].x]++;
      if (e[j].l + mat[i][e[j].x] == mat[i][e[j].y]) nrE[i][e[j].y]++;
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++)
        if (mat[i][k] + mat[k][j] == mat[i][j]) ans[i][j] += nrE[i][k];
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) cout << ans[i][j] << " ";
  return 0;
}
