#include <bits/stdc++.h>
using namespace std;
const int MAX = 5e2 + 5;
vector<pair<int, int> > adj[MAX];
int dis[MAX][MAX], in[MAX][MAX];
int n, m;
void dijkstra(int source) {
  memset(dis[source], 0x3F, sizeof dis[source]);
  dis[source][source] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      pq;
  pq.emplace(dis[source][source], source);
  while (!pq.empty()) {
    pair<int, int> cur = pq.top();
    pq.pop();
    int w, v;
    tie(w, v) = cur;
    if (w > dis[source][v]) {
      continue;
    }
    for (auto &each : adj[v]) {
      int vv, ww;
      tie(vv, ww) = each;
      if (dis[source][vv] > w + ww) {
        dis[source][vv] = w + ww;
        in[source][vv] = 1;
        pq.emplace(dis[source][vv], vv);
      } else if (dis[source][vv] == w + ww) {
        in[source][vv]++;
      }
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = int(0); i < int(m); i++) {
    int u, v, w;
    scanf("%d %d %d", &u, &v, &w);
    adj[u].emplace_back(v, w);
    adj[v].emplace_back(u, w);
  }
  for (int i = int(1); i < int(n + 1); i++) {
    dijkstra(i);
  }
  for (int i = int(1); i < int(n + 1); i++) {
    for (int j = int(i + 1); j < int(n + 1); j++) {
      int total = 0;
      for (int k = int(1); k < int(n + 1); k++) {
        if (dis[i][k] + dis[k][j] == dis[i][j]) {
          total += in[i][k];
        }
      }
      printf("%d ", total);
    }
  }
  puts("");
  return 0;
}
