#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
template <class T>
inline T biton(T n, T pos) {
  return n | ((T)1 << pos);
}
template <class T>
inline T bitoff(T n, T pos) {
  return n & ~((T)1 << pos);
}
template <class T>
inline T ison(T n, T pos) {
  return (bool)(n & ((T)1 << pos));
}
template <class T>
inline T gcd(T a, T b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <typename T>
string NumberToString(T Number) {
  ostringstream second;
  second << Number;
  return second.str();
}
inline int nxt() {
  int aaa;
  scanf("%d", &aaa);
  return aaa;
}
inline long long int lxt() {
  long long int aaa;
  scanf("%lld", &aaa);
  return aaa;
}
inline double dxt() {
  double aaa;
  scanf("%lf", &aaa);
  return aaa;
}
template <class T>
inline T bigmod(T p, T e, T m) {
  T ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % m;
    p = (p * p) % m;
  }
  return (T)ret;
}
vector<pair<int, int> > adj[505];
int level[505][505];
vector<tuple<int, int, int> > edge;
void dijsktra(int s) {
  for (int i = 0; i < 505; i++) level[s][i] = (1e9) + 1000;
  level[s][s] = 0;
  priority_queue<pair<int, int> > pq;
  pq.push(make_pair(0, s));
  while (!pq.empty()) {
    pair<int, int> top = pq.top();
    pq.pop();
    for (auto it : adj[top.second]) {
      if (level[s][top.second] + it.second < level[s][it.first]) {
        level[s][it.first] = level[s][top.second] + it.second;
        pq.push(make_pair(-level[s][it.first], it.first));
      }
    }
  }
}
int n;
int ans[505][505];
int Edge[505][505];
void calculate(int s) {
  for (auto it : edge) {
    int a = get<0>(it);
    int b = get<1>(it);
    int c = get<2>(it);
    if (level[s][a] + c == level[s][b]) {
      Edge[s][b]++;
    }
    if (level[s][b] + c == level[s][a]) {
      Edge[s][a]++;
    }
  }
}
int main() {
  for (int i = 0; i < 505; i++)
    for (int j = 0; j < 505; j++) level[i][j] = (1e9) + 1000, level[i][i] = 0;
  n = nxt();
  int m = nxt();
  for (int i = 0; i < m; i++) {
    int a = nxt();
    int b = nxt();
    a--, b--;
    int c = nxt();
    edge.push_back(make_tuple(a, b, c));
    level[a][b] = c;
    level[b][a] = c;
  }
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        level[i][j] = min(level[i][j], level[i][k] + level[k][j]);
  for (int i = 0; i < n; i++) {
    calculate(i);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (level[i][j] == level[i][k] + level[k][j]) ans[i][j] += Edge[i][k];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      printf("%d ", ans[i][j]);
    }
  }
  printf("\n");
  return 0;
}
