#include <bits/stdc++.h>
using namespace std;
int n, m, tot;
int e[510][510], d[510][510], a[510][510];
int main() {
  int u, v, w;
  scanf("%d%d", &n, &m);
  memset(d, -1, sizeof(d));
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &u, &v, &w);
    u--, v--;
    d[u][v] = d[v][u] = w;
  }
  for (int i = 0; i < n; i++) d[i][i] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) a[i][j] = d[i][j];
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (d[i][k] != -1 && d[k][j] != -1 &&
            (d[i][j] == -1 || d[i][j] > d[i][k] + d[k][j]))
          d[i][j] = d[i][k] + d[k][j];
  memset(e, -1, sizeof(e));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++)
        if (d[i][j] != -1 && d[i][k] != -1 && a[k][j] != -1 &&
            d[i][k] + a[k][j] == d[i][j])
          e[i][j]++;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      tot = 0;
      for (int k = 0; k < n; k++)
        if (d[i][k] != -1 && d[k][j] != -1 && d[i][j] != -1 &&
            d[i][k] + d[k][j] == d[i][j])
          tot += e[i][k];
      printf("%d ", tot);
    }
  puts("");
}
