#include <bits/stdc++.h>
using namespace std;
int n;
int dist[510][510], indeg[510];
vector<pair<int, int> > edges[510];
vector<pair<pair<int, int>, int> > edgeList;
void makeDijkstraDAG(int s) {
  for (int i = 1; i <= n; i++) indeg[i] = 0;
  for (int i = 0; i < edgeList.size(); i++)
    if (dist[s][edgeList[i].first.first] + edgeList[i].second ==
        dist[s][edgeList[i].first.second])
      indeg[edgeList[i].first.second]++;
}
int main() {
  int m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) dist[i][j] = 1000000000;
    dist[i][i] = 0;
  }
  for (int i = 0; i < m; i++) {
    int x, y, l;
    cin >> x >> y >> l;
    edgeList.push_back(pair<pair<int, int>, int>(pair<int, int>(x, y), l));
    edgeList.push_back(pair<pair<int, int>, int>(pair<int, int>(y, x), l));
    dist[x][y] = dist[y][x] = l;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++)
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
  for (int i = 1; i <= n; i++) {
    makeDijkstraDAG(i);
    for (int j = i + 1; j <= n; j++) {
      int ans = 0;
      for (int k = 1; k <= n; k++)
        if (dist[k][j] == dist[i][j] - dist[i][k]) ans += indeg[k];
      cout << ans << " ";
    }
  }
  cout << endl;
}
