#include <bits/stdc++.h>
using namespace std;
struct edge {
  int u, v, w;
  edge(int _u, int _v, int _w) : u(_u), v(_v), w(_w) {}
};
int N, M;
long long dist[505][505];
int ways[505][505];
vector<edge> edges;
void floyd_warshall() {
  for (int i = 0; i < N; i++) {
    for (int u = 0; u < N; u++) {
      for (int v = 0; v < N; v++) {
        dist[u][v] = min(dist[u][v], dist[u][i] + dist[i][v]);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) dist[i][j] = i == j ? 0 : 1000000000;
  }
  for (int i = 0; i < M; i++) {
    int x, y, l;
    cin >> x >> y >> l;
    x--;
    y--;
    edges.push_back(edge(x, y, l));
    dist[x][y] = l;
    dist[y][x] = l;
  }
  floyd_warshall();
  for (int i = 0; i < N; i++) {
    int dp[505] = {0};
    for (int j = 0; j < M; j++) {
      if (dist[i][edges[j].u] == dist[i][edges[j].v] + edges[j].w)
        dp[edges[j].u]++;
      if (dist[i][edges[j].v] == dist[i][edges[j].u] + edges[j].w)
        dp[edges[j].v]++;
    }
    for (int j = i + 1; j < N; j++) {
      for (int k = 0; k < N; k++) {
        if (dist[i][j] == dist[i][k] + dist[k][j]) ways[i][j] += dp[k];
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) cout << ways[i][j] << ' ';
  }
  cout << '\n';
  return 0;
}
