#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse")
#pragma GCC target("sse2")
#pragma GCC target("ssse3")
#pragma GCC target("sse4")
#pragma GCC target("abm")
#pragma GCC target("mmx")
#pragma GCC target("avx")
#pragma GCC target("avx2")
#pragma GCC target("popcnt")
#pragma GCC target("tune=native")
using namespace std;
const int mxn = 500 + 10;
int n, m, l, v, u;
int dis[mxn][mxn];
vector<pair<int, int> > adj[mxn];
long long C[mxn][mxn];
void input() {
  for (int i = 0; i < mxn; i++) {
    for (int j = 0; j < mxn; j++) {
      dis[i][j] = 1e9;
    }
  }
  for (int i = 0; i < mxn; i++) {
    dis[i][i] = 0;
  }
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> u >> v >> l;
    adj[v].push_back(make_pair(u, l)), adj[u].push_back(make_pair(v, l));
    dis[v][u] = l, dis[u][v] = l;
  }
}
void solve() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      C[i][j] = 0;
      for (int w = 1; w <= n; w++) {
        dis[j][w] = min(dis[j][w], dis[j][i] + dis[i][w]);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    long long cnt = 0;
    for (int j = 1; j <= n; j++) {
      cnt = 0;
      for (int w = 0; w < adj[j].size(); w++) {
        int x = adj[j][w].first;
        if (dis[i][x] + adj[j][w].second == dis[i][j]) {
          cnt++;
        }
      }
      for (int w = 1; w <= n; w++) {
        if (dis[i][j] + dis[j][w] == dis[i][w]) {
          C[i][w] += cnt;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      cout << C[i][j] << ' ';
    }
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  input(), solve();
  return 0;
}
