#include <bits/stdc++.h>
using namespace std;
const int MAX = 509;
int n, m, dis[MAX][MAX], in[MAX][MAX], ans[MAX][MAX];
vector<pair<int, int> > g[MAX];
int main() {
  cin >> n >> m;
  for (int i = 0; i < MAX; i++)
    for (int j = 0; j < MAX; j++) dis[i][j] = (i == j ? 0 : 1e9);
  for (int i = 0, v, u, w; i < m; i++)
    cin >> v >> u >> w, v--, u--, dis[v][u] = dis[u][v] = w,
                                  g[v].push_back({u, w}),
                                  g[u].push_back({v, w});
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (auto v : g[j])
        if (dis[i][v.first] + v.second == dis[i][j]) in[i][j]++;
    }
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++)
        if (dis[i][j] + dis[j][k] == dis[i][k]) ans[i][k] += in[i][j];
  }
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) cout << ans[i][j] << ' ';
}
