#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e2 + 10;
int n, m;
long long adj[MAXN][MAXN];
long long adj_[MAXN][MAXN];
int ans[MAXN][MAXN];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  memset(adj, 63, sizeof(adj));
  memset(adj_, 63, sizeof(adj_));
  for (int i = 0; i < m; i++) {
    int u, v, l;
    cin >> u >> v >> l;
    adj[u][v] = adj[v][u] = l;
    adj_[u][v] = adj_[v][u] = l;
  }
  for (int i = 1; i <= n; i++) adj[i][i] = 0;
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        adj[i][j] = min(adj[i][j], adj[i][k] + adj[j][k]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++)
        if (adj_[k][j] < 1e9 && (adj[i][k] + adj_[k][j]) == adj[i][j])
          ans[i][j]++;
  for (int i = 1; i < n; i++)
    for (int j = i + 1; j <= n; j++) {
      int answer = 0;
      for (int k = 1; k <= n; k++)
        if ((adj[i][k] + adj[k][j]) == adj[i][j]) answer += ans[i][k];
      cout << answer << ' ';
    }
  return 0;
}
