#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793;
const long long MOD = 1e9 + 7, INF = 1e9 + 10;
const int N = 5e2 + 10;
int dist[N][N], w[N][N], ans[N][N];
int main() {
  int n, m;
  cin >> n >> m;
  int u, v;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) dist[i][j] = w[i][j] = INF;
  for (int i = 1; i <= n; i++) dist[i][i] = 0;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    cin >> w[u][v];
    dist[u][v] = w[u][v];
    dist[v][u] = w[v][u] = w[u][v];
  }
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  for (int i = 1; i <= n; i++)
    for (int k = 1; k <= n; k++)
      for (int j = 1; j <= n; j++)
        if (dist[i][j] != INF && dist[i][j] == dist[i][k] + w[k][j])
          ans[i][j]++;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      int edgeCount = 0;
      for (int k = 1; k <= n; k++)
        if (dist[i][j] == dist[i][k] + dist[k][j]) edgeCount += ans[i][k];
      cout << edgeCount << " ";
    }
  cout << endl;
  return 0;
}
