#include <bits/stdc++.h>
using namespace std;
void magic_io() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
const int MAXN = 505;
int n, m;
long long dist[MAXN][MAXN];
int res[MAXN][MAXN] = {0};
int ctr[MAXN][MAXN] = {0};
struct edge {
  int first;
  int second;
  long long weight;
  friend bool operator<(const edge &lhs, const edge &rhs) {
    if (lhs.first != rhs.first) {
      return lhs.first < rhs.first;
    }
    if (lhs.second != rhs.second) {
      return lhs.second < rhs.second;
    }
    return lhs.weight < rhs.weight;
  }
};
vector<edge> edges;
void APSP() {
  for (int i = 0; i < n; i++) {
    for (int u = 0; u < n; u++) {
      for (int v = 0; v < n; v++) {
        if (dist[u][v] > dist[u][i] + dist[i][v]) {
          dist[u][v] = dist[u][i] + dist[i][v];
        }
      }
    }
  }
  for (int u = 0; u < n; u++) {
    for (auto e : edges) {
      if (dist[u][e.second] == dist[u][e.first] + e.weight) {
        ctr[u][e.second]++;
      }
      if (dist[u][e.first] == dist[u][e.second] + e.weight) {
        ctr[u][e.first]++;
      }
    }
  }
  for (int u = 0; u < n; u++) {
    for (int v = u + 1; v < n; v++) {
      for (int i = 0; i < n; i++) {
        if (dist[u][v] == dist[u][i] + dist[i][v]) {
          res[u][v] += ctr[u][i];
        }
      }
    }
  }
  for (int u = 0; u < n; u++) {
    for (int v = u + 1; v < n; v++) {
      printf("%d", res[u][v]);
      if (u == n - 2 && v == n - 1) {
        printf("\n");
      } else {
        printf(" ");
      }
    }
  }
}
int main() {
  for (int i = 0; i < MAXN; i++) {
    for (int j = 0; j < MAXN; j++) {
      if (i == j) {
        dist[i][j] = 0;
      } else {
        dist[i][j] = 100000000000000LL;
      }
    }
  }
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    u--;
    v--;
    edges.push_back(edge{u, v, w});
    dist[u][v] = w;
    dist[v][u] = w;
  }
  APSP();
  return 0;
}
