#include <bits/stdc++.h>
using namespace std;
const int N = 510;
const int INF = 1e9;
int A[N][N];
int dist[N][N];
pair<pair<int, int>, int> B[N * N];
int num[N][N];
int ans[N][N];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) dist[i][j] = (i == j) ? 0 : INF;
  for (int i = 0; i < m; i++) {
    int x, y, w;
    cin >> x >> y >> w;
    x--;
    y--;
    dist[x][y] = dist[y][x] = w;
    B[i] = make_pair(make_pair(x, y), w);
  }
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  memset(num, 0, sizeof num);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      int u = B[j].first.first;
      int v = B[j].first.second;
      int c = B[j].second;
      if (dist[i][u] + c == dist[i][v]) num[i][v]++;
      if (dist[i][v] + c == dist[i][u]) num[i][u]++;
    }
  memset(ans, 0, sizeof ans);
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (dist[i][j] == dist[i][k] + dist[k][j]) ans[i][j] += num[i][k];
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) cout << ans[i][j] << " ";
  cout << endl;
}
