#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 5e2 + 10;

int n, m;
long long adj[MAXN][MAXN];
long long adj_[MAXN][MAXN];
int ans[MAXN][MAXN];

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	memset(adj, 63, sizeof(adj));
	memset(adj_, 63, sizeof(adj_));
	for (int i = 0; i < m; i++) {
		int u , v , l;
		cin >> u >> v >> l;
		adj[u][v] = adj[v][u] = l;
		adj_[u][v] = adj_[v][u] = l;
	}
	for (int i = 1; i <= n; i++)
		adj[i][i] = 0;
	for (int k = 1; k <= n; k++)
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				adj[i][j] = min(adj[i][j], adj[i][k] + adj[j][k]);

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			for (int k = 1; k <= n; k++)
				if (adj_[k][j] < 1e9 && (adj[i][k] + adj_[k][j]) == adj[i][j])
					ans[i][j]++;

	for (int i = 1; i < n; i++)
		for (int j = i + 1; j <= n ; j++) {
			int answer = 0;
			for (int k = 1; k <= n; k++)
				if ((adj[i][k] + adj[k][j]) == adj[i][j])
					answer += ans[i][k];
			cout << answer << ' ';
		}
	//system("pause");
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 5e2 + 10;

int n, m;
int adj[MAXN][MAXN];
int adj_[MAXN][MAXN];
int ans[MAXN][MAXN];

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	memset(adj, 63, sizeof(adj));
	memset(adj_, 63, sizeof(adj_));
	for (int i = 0; i < m; i++) {
		int u , v , l;
		cin >> u >> v >> l;
		adj[u][v] = adj[v][u] = l;
		adj_[u][v] = adj_[v][u] = l;
	}
	for (int i = 1; i <= n; i++)
		adj[i][i] = 0;
	for (int k = 1; k <= n; k++)
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				adj[i][j] = min(adj[i][j], adj[i][k] + adj[j][k]);

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			for (int k = 1; k <= n; k++)
				if (adj_[k][j] < 1e9 && (adj[i][k] + adj_[k][j]) == adj[i][j])
					ans[i][j]++;

	for (int i = 1; i < n; i++)
		for (int j = i + 1; j <= n ; j++) {
			int answer = 0;
			for (int k = 1; k <= n; k++)
				if ((adj[i][k] + adj[k][j]) == adj[i][j])
					answer += ans[i][k];
			cout << answer << ' ';
		}
	//system("pause");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for (int i=(n-1); i>=0; --i)
#define REP1(i,n) FOR(i,1,n+1)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#ifdef BALBIT
#define IOS()
#define bug(...) fprintf(stderr,"#%d (%s) = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define bug(...)
#endif

const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;

void GG(){cout<<"-1\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b) % mo;
}

const int maxn = 505;

ll g[maxn][maxn]; // Adjacency list
bool vis[maxn];
ll dst[maxn][maxn];
ll ans[maxn][maxn];
bitset<maxn> rch[maxn];
int odeg[maxn];
int into[maxn];

signed main(){
    IOS();
    int n, m; cin>>n>>m;
    REP(i,n) REP(j,n) dst[i][j]= (i==j)?0:inf, g[i][j]=inf;
    REP(i,m) {
        int a, b; cin>>a>>b; --a; --b;
        int w; cin>>w;
        g[a][b] = g[b][a] = dst[a][b] = dst[b][a] = w;
    }
    REP(k,n) REP(i,n) REP(j,n) {
        if (dst[i][j] > dst[i][k] + dst[k][j]) {
            dst[i][j] = dst[i][k] + dst[k][j];
        }
    }
    REP(st, n) {
        bug("Doing ", st);
        REP(i,n) {
            rch[i].reset();
            rch[i][i]=1;
            odeg[i]=0;
            into[i]=0;
        }
        REP(i,n) {
            FOR(j,0,n) {
                if (dst[st][i] + g[i][j] == dst[st][j] && dst[st][j]<inf-10000) {
                    odeg[i]++; into[j]++;
                    bug(i,j);
                }
            }
        }
        queue<int> q;
        REP(i,n) {
            if (odeg[i] == 0) {
                q.push(i);
            }
        }
        while (!q.empty()) {
            int j = q.front(); q.pop();
            REP(i,n) {
                if (dst[st][i] + g[i][j] == dst[st][j] && dst[st][j]<inf-10000) {
                    rch[i] |= rch[j];
                    odeg[i]--;
                    if (odeg[i]==0) q.push(i);
                }
            }
        }
        REP(i,n) {
            REP(j,n) {
                if (rch[i][j]) {
                    ans[st][j] += into[i];
                }
            }
        }
    }
    REP(i,n) {
        FOR(j,i+1,n) {
            cout<<ans[i][j]<<" ";
        }
    }

}


#include <bits/stdc++.h>
using namespace std;

const int N = 505;

int n, m, apsp[N][N], dp[N][N];

int main() {
	#ifdef INPUT
	freopen("r", "r", stdin);
	#endif
	fill(apsp[0], apsp[500]+N, (int)1e9);
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; ++i) apsp[i][i] = 0;
	while(m--) {
		int u, v, w; scanf("%d %d %d", &u, &v, &w);
		apsp[u][v] = apsp[v][u] = w;
		dp[u][v] = dp[v][u] = 1;
	}
	for(int k = 1; k <= n; ++k) for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) {
		// printf("%d %d %d\n", k, i, j);
		if(k == i || k == j) continue;
		if(apsp[i][j] == apsp[i][k] + apsp[k][j]) {
			dp[i][j] += dp[i][k] + dp[k][j];
		}
		if(apsp[i][j] > apsp[i][k] + apsp[k][j]) {
			apsp[i][j] = apsp[i][k] + apsp[k][j];
			dp[i][j] = dp[i][k] + dp[k][j];
		}
	}
	for(int i = 1; i <= n; ++i) for(int j = i+1; j <= n; ++j) printf("%d ", dp[i][j]);
}


#include <bits/stdc++.h>
using namespace std;

const int N = 505;

struct data {
	int u, v, w;
	data(int u, int v, int w) : u(u), v(v), w(w) { }
};

int n, m, apsp[N][N], dp[N][N];
vector<data> E;

int main() {
	#ifdef INPUT
	freopen("r", "r", stdin);
	#endif
	fill(apsp[0], apsp[500]+N, (int)1e9);
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; ++i) apsp[i][i] = 0;
	while(m--) {
		int u, v, w; scanf("%d %d %d", &u, &v, &w);
		apsp[u][v] = apsp[v][u] = w;
		E.emplace_back(u, v, w);
	}
	for(int k = 1; k <= n; ++k) for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) {
		if(apsp[i][j] > apsp[i][k] + apsp[k][j]) {
			apsp[i][j] = apsp[i][k] + apsp[k][j];
		}
	}
	for(int i = 1; i <= n; ++i) for(auto& x : E) {
		if(apsp[i][x.u] + x.w == apsp[i][x.v]) dp[i][x.v]++;
		if(apsp[i][x.v] + x.w == apsp[i][x.u]) dp[i][x.u]++;
	}
	for(int i = 1; i <= n; ++i) for(int j = i+1; j <= n; ++j) {
		int cnt = 0;
		for(int k = 1; k <= n; ++k) if(apsp[i][k] + apsp[k][j] == apsp[i][j]) cnt += dp[i][k];
		printf("%d ", cnt);
	}
}


#include <bits/stdc++.h>
using namespace std;

const int N = 505;

int n, m, apsp[N][N], dp[N][N];

int main() {
	#ifdef INPUT
	freopen("r", "r", stdin);
	#endif
	fill(apsp[0], apsp[500]+N, (int)1e9);
	scanf("%d %d", &n, &m);
	while(m--) {
		int u, v, w; scanf("%d %d %d", &u, &v, &w);
		apsp[u][v] = apsp[v][u] = w;
		dp[u][v] = dp[v][u] = 1;
		dp[u][u] = 0;
	}
	for(int k = 1; k <= n; ++k) for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) {
		// if(k == i || k == j) continue;
		if(apsp[i][j] == apsp[i][k] + apsp[k][j]) {
			apsp[i][j] = apsp[i][k] + apsp[k][j];
			dp[i][j] += dp[i][k] + dp[k][j];
		}
		if(apsp[i][j] > apsp[i][k] + apsp[k][j]) {
			apsp[i][j] = apsp[i][k] + apsp[k][j];
			dp[i][j] = dp[i][k] + dp[k][j];
		}
	}
	for(int i = 1; i <= n; ++i) for(int j = i+1; j <= n; ++j) printf("%d ", dp[i][j]);
}


#include <bits/stdc++.h>
using namespace std;

const int N = 505;

int n, m, apsp[N][N], dp[N][N];

int main() {
	#ifdef INPUT
	freopen("r", "r", stdin);
	#endif
	fill(apsp[0], apsp[500]+N, (int)1e9);
	scanf("%d %d", &n, &m);
	while(m--) {
		int u, v, w; scanf("%d %d %d", &u, &v, &w);
		apsp[u][v] = apsp[v][u] = w;
		dp[u][v] = dp[v][u] = 1;
		dp[u][u] = 0;
	}
	for(int k = 1; k <= n; ++k) for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) {
		if(k == i || k == j) continue;
		if(apsp[i][j] == apsp[i][k] + apsp[k][j]) {
			apsp[i][j] = apsp[i][k] + apsp[k][j];
			dp[i][j] += dp[i][k] + dp[k][j];
		}
		if(apsp[i][j] > apsp[i][k] + apsp[k][j]) {
			apsp[i][j] = apsp[i][k] + apsp[k][j];
			dp[i][j] = dp[i][k] + dp[k][j];
		}
	}
	for(int i = 1; i <= n; ++i) for(int j = i+1; j <= n; ++j) printf("%d ", dp[i][j]);
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
typedef long long ll;
const ll INF=1e18+10,M=510,MOD=1e9+7;
typedef pair<ll,ll> pii;
ll d[M][M],ans[M][M],cnt[M];
vector<pii> adj[M];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)
			d[i][j]=INF;
		d[i][i]=0;
	}
	for(int i=0;i<m;i++){
		int x,y,z;
		cin>>x>>y>>z;
		d[x][y]=z;
		d[y][x]=z;
		adj[x].pb({y,z});
		adj[y].pb({x,z});
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++)
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)
			cnt[j]=0;
		for(int j=1;j<=n;j++){
			for(pii u:adj[j]){
				cnt[j]+=(d[i][j]==d[i][u.F]+u.S);
			}
		}
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++)
				ans[i][j]+=cnt[k]*(d[i][j]==d[i][k]+d[k][j]);
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++)
			cout<<ans[i][j]<<" ";
	}
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define INF 0x7ffffff
int n,m;
int mpt[505][505];
int dp[505];
int ans[505][505];
struct node
{
    int x,y,len;
}edge[130000];
void init()
{
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i==j)
            {
                mpt[i][j]=0;
            }
            else
            {
                mpt[i][j]=INF;
            }
        }
    }
}
void floyd()
{
    for(int k=1;k<=n;k++)
    {
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
                if(mpt[i][j]>mpt[i][k]+mpt[k][j])
                    mpt[i][j]=mpt[i][k]+mpt[k][j];
            }
        }
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    int a,b,c;
    init();
    int cnt=1;
    for(int i=0;i<m;i++)
    {
        scanf("%d%d%d",&a,&b,&c);
        edge[cnt].x=a;
        edge[cnt].y=b;
        edge[cnt++].len=c;
        if(c<mpt[a][b])
        {
            mpt[a][b]=mpt[b][a]=c;
        }
    }
    floyd();
    for(int i=1;i<n;i++)//ö�����
    {
        memset(dp,0,sizeof(dp));
        for(int j=1;j<=m;j++)//ö�ٱ�
        {
            if(mpt[edge[j].x][i]==mpt[edge[j].y][i]+edge[j].len)dp[edge[j].x]++;
            if(mpt[edge[j].y][i]==mpt[edge[j].x][i]+edge[j].len)dp[edge[j].y]++;
        }
        for(int j=i+1;j<=n;j++)//ö���յ�
        {
            for(int k=1;k<=n;k++)//ö���е�
            {
                if(mpt[i][j]==mpt[i][k]+mpt[k][j])ans[i][j]+=dp[k];
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            printf("%d ",ans[i][j]);
        }
    }
    return 0;
}


//sb judge system
#include <cstdio>
#include <cstring>
using namespace std;
int n,m,a,b,c,g[510][510],di[510][510];
main()
{
	scanf("%d%d",&n,&m);
	memset(g,0x3f,sizeof g);
	for (int i=1;i<=m;i++)
		scanf("%d%d%d",&a,&b,&c),
		g[a][b]=g[b][a]=c,di[a][b]=di[b][a]=1;
	for (int k=1;k<=n;k++)
		for (int i=1;i<=n;i++)
			for (int j=1;j<=n;j++)
//				if (k!=i && k!=j)
					if (g[i][j]>g[i][k]+g[k][j])
						g[i][j]=g[i][k]+g[k][j],
						di[i][j]=di[i][k]+di[k][j];
					else if (g[i][j]==g[i][k]+g[k][j])
						di[i][j]+=di[i][k]+di[k][j];
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++)
			printf("%d ",di[i][j]);
}


//sb judge system
#include <cstdio>
#include <cstring>
using namespace std;
int n,m,a,b,c,g[510][510],di[510][510];
main()
{
	scanf("%d%d",&n,&m);
	memset(g,0x3f,sizeof g);
	for (int i=1;i<=m;i++)
		scanf("%d%d%d",&a,&b,&c),
		g[a][b]=g[b][a]=c,di[a][b]=di[b][a]=1;
	for (int k=1;k<=n;k++)
		for (int i=1;i<=n;i++)
			for (int j=1;j<=n;j++)
				if (k!=i && k!=j)
					if (g[i][j]>g[i][k]+g[k][j])
						g[i][j]=g[i][k]+g[k][j],
						di[i][j]=di[i][k]+di[k][j];
					else if (g[i][j]==g[i][k]+g[k][j])
						di[i][j]+=di[i][k]+di[k][j];
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++)
			printf("%d ",di[i][j]);
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair <ll , ll> pll;
typedef vector <ll> vll;
#define pb push_back
#define X first
#define Y second
#define mkp make_pair
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(s) (ll)((s).size())
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
const ll maxn=5e2+5,M=105,bghs=1e9+7,inf=1e18;
ll n,m;
ll w[maxn][maxn],dist[maxn][maxn];
ll e[M][M];
int main()
{
	IOS;
	cin>>n>>m;
	memset(dist,63,sizeof dist);
	memset(w,62,sizeof w);
	for (ll i=0;i<n;i++) dist[i][i]=0;
	for (ll i=0;i<m;i++)
	{
		ll u,v,x;cin>>u>>v>>x;
		u--;v--;
		w[u][v]=dist[u][v]=x;
		w[v][u]=dist[v][u]=x;
	}
	for (ll k=n-1;k>=0;k--)
		for (ll i=0;i<n;i++) for (ll j=0;j<n;j++)
		{
			if (dist[i][j]>dist[i][k]+dist[k][j])
			{
				dist[i][j]=dist[i][k]+dist[k][j];
			}
		}

	for (ll u=0;u<n;u++)
	{
		for (ll khar=0;khar<n;khar++)
		{
			for (ll v=0;v<n;v++)
			{
				e[u][khar]+=(dist[u][v]+w[v][khar])==dist[u][khar];
			}
		}
	}
	for (ll i=0;i<n;i++)
		for (ll j=i+1;j<n;j++)
		{
			ll jav=0;
			for (ll k=0;k<n;k++)
			{
				if (dist[i][k]+dist[k][j]==dist[i][j])
				{
					jav+=e[i][k];
					//cout << k << " dar beyne " << i << " va " << j << " hast va e[i][k]=" << e[i][k] << '\n';
				}
			}
			cout << jav << ' ';
		}
	cout<<endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair <ll , ll> pll;
typedef vector <ll> vll;
#define pb push_back
#define X first
#define Y second
#define mkp make_pair
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(s) (ll)((s).size())
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
const ll maxn=5e2+5,M=505,bghs=1e9+7,inf=1e18;
ll n,m;
ll w[maxn][maxn],dist[maxn][maxn];
ll e[M][M];
int main()
{
	IOS;
	cin>>n>>m;
	memset(dist,63,sizeof dist);
	memset(w,62,sizeof w);
	for (ll i=0;i<n;i++) dist[i][i]=0;
	for (ll i=0;i<m;i++)
	{
		ll u,v,x;cin>>u>>v>>x;
		u--;v--;
		w[u][v]=dist[u][v]=x;
		w[v][u]=dist[v][u]=x;
	}
	for (ll k=n-1;k>=0;k--)
		for (ll i=0;i<n;i++) for (ll j=0;j<n;j++)
		{
			if (dist[i][j]>dist[i][k]+dist[k][j])
			{
				dist[i][j]=dist[i][k]+dist[k][j];
			}
		}

	for (ll u=0;u<n;u++)
	{
		for (ll khar=0;khar<n;khar++)
		{
			for (ll v=0;v<n;v++)
			{
				e[u][khar]+=(dist[u][v]+w[v][khar])==dist[u][khar];
			}
		}
	}
	for (ll i=0;i<n;i++)
		for (ll j=i+1;j<n;j++)
		{
			ll jav=0;
			for (ll k=0;k<n;k++)
			{
				if (dist[i][k]+dist[k][j]==dist[i][j])
				{
					jav+=e[i][k];
					//cout << k << " dar beyne " << i << " va " << j << " hast va e[i][k]=" << e[i][k] << '\n';
				}
			}
			cout << jav << ' ';
		}
	cout<<endl;
}


#include <iostream>
#include <vector>
using namespace std;

const int MAXN = 505;
int n, m, dp[MAXN][MAXN], mx[MAXN];
vector<pair<int, int> > Mat[MAXN];
void upmx(int s) {
	for (int i = 0; i <= n; i++)
		mx[i] = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 0; j < Mat[i].size(); j++)
			if (dp[s][Mat[i][j].first] + Mat[i][j].second == dp[s][i])
				mx[i]++;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= n; j++)
			dp[i][j] = (1 << 22) * (i != j);
	for (int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		Mat[a].push_back({b, c});
		Mat[b].push_back({a, c});
		dp[a][b] = c;
		dp[b][a] = c;
	}
	for (int k = 1; k <= n; k++)
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
	for (int i = 1; i <= n; i++) {
		upmx(i);
		for (int j = i + 1; j <= n; j++) {
			int res = 0;
			for (int k = 1; k <= n; k++)
				if (dp[i][k] + dp[k][j] == dp[i][j])
					res += mx[k];
			cout << res << ' ';
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
const int MAX=509;
int n,m,dis[MAX][MAX],in[MAX][MAX],ans[MAX][MAX];
vector<pair<int,int> > g[MAX];
int main()
{
	cin>>n>>m;
	for (int i=0;i<MAX;i++)
		for (int j=0;j<MAX;j++)
			dis[i][j]=(i==j?0:1e9);
	for (int i=0,v,u,w;i<m;i++) cin>>v>>u>>w,v--,u--,dis[v][u]=dis[u][v]=w,g[v].push_back({u,w}),g[u].push_back({v,w});
	for (int k=0;k<n;k++)
		for (int i=0;i<n;i++)
			for (int j=0;j<n;j++)
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<n;j++)
		{
			for (auto v:g[j])
				if (dis[i][v.first]+v.second==dis[i][j])
					in[i][j]++;
		}
		for (int j=0;j<n;j++)
			for (int k=0;k<n;k++)
				if (dis[i][j]+dis[j][k]==dis[i][k])
					ans[i][k]+=in[i][j];
	}
	for (int i=0;i<n;i++)
		for (int j=i+1;j<n;j++)
			cout<<ans[i][j]<<' ';
}


/*
Floyd Warshall

*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define x first
#define y second
#define pb push_back
#define all(x) x.begin(), x.end()

#define MAXN 505

struct Edge {
	int a, b, w;
};
vector<Edge> es;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);

	int N, M;
	cin >> N >> M;
	ll G[MAXN][MAXN];
	for (int i = 0; i < N*N; i++) G[i/N][i%N] = INT_MAX;
	for (int i = 0; i < N; i++) G[i][i] = 0;
	for (int i = 0; i < M; i++) {
		int a, b, w;
		cin >> a >> b >> w;
		a--; b--;
		G[a][b] = w;
		G[b][a] = w;
		es.push_back({a, b, w});
	}

	// floyd warshall
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
			}
		}
	}
	// for (int i = 0; i < N; i++) {
	// 	for (int j = 0; j < N; j++) printf("%lld ", G[i][j]);
	// 	printf("\n");
	// }

	int inEdges[MAXN][MAXN] = {{0}};
	for (int s = 0; s < N; s++) {
		for (Edge e : es) {
			if (G[s][e.a] == G[s][e.b] + e.w) inEdges[s][e.a]++;
			if (G[s][e.b] == G[s][e.a] + e.w) inEdges[s][e.b]++;
		}
	}

	for (int s = 0; s < N; s++) {
		for (int t = s+1; t < N; t++) {
			ll ans = 0;
			for (int i = 0; i < N; i++) {
				if (G[s][i] + G[i][t] == G[s][t]) ans += (ll)inEdges[s][i];
			}
			printf("%lld ", ans);
		}
	}
	printf("\n");
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "PP"
const int MAXN = 501;
struct Node
{
	int u, v, w;
};
int N, M;
int A[MAXN][MAXN];
Node save[MAXN * MAXN / 2];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= M; i++)
	{
		int u, v, w;
		cin >> u >> v >> w;
		save[i] = {u, v, w};
		A[u][v] = A[v][u] = w;
	}
}
int cnt[MAXN][MAXN];
void Output()
{
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= N; j++)
			if(A[i][j] == 0)
				A[i][j] = 1e9 + 7;
/*	for(int i = 1; i <= N; i++)
	{
		for(int j = 1; j <= N; j++)
			cout << A[i][j] << " ";
		cout << endl;
	}*/
	for(int k = 1; k <= N; k++)
		for(int u = 1; u <= N; u++)
			for(int v = 1; v <= N; v++)
				A[u][v] = min(A[u][v], A[u][k] + A[k][v]);
	/*for(int i = 1; i <= N; i++)
	{
		for(int j = 1; j <= N; j++)
			cout << A[i][j] << " ";
		cout << endl;
	}*/
	for(int i = 1; i <= N; i++)
		A[i][i] = 0;
	for(int u = 1; u <= N; u++)
		for(int i = 1; i <= M; i++)
		{
			int k = save[i].u;
			int v = save[i].v;
			int w = save[i].w;
			if(A[u][k] + w == A[u][v])
				cnt[u][v]++;
			swap(k, v);
			if(A[u][k] + w == A[u][v])
				cnt[u][v]++;
		}
	for(int u = 1; u <= N; u++)
		for(int v = u + 1; v <= N; v++)
		{
			int sum = 0;
			for(int k = 1; k <= N; k++)
				if(A[u][k] + A[k][v] == A[u][v])
					sum += cnt[u][k];
			cout << sum << " ";
		}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 /*   freopen(task".inp", "r", stdin);
    freopen(task".out", "w", stdout);*/
    Input();
    Output();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define task "PP"
const int MAXN = 501;
struct Node
{
	int u, v, w;
};
int N, M;
int A[MAXN][MAXN];
Node save[MAXN];
void Input()
{
	cin >> N >> M;
	for(int i = 1; i <= M; i++)
	{
		int u, v, w;
		cin >> u >> v >> w;
		save[i] = {u, v, w};
		A[u][v] = A[v][u] = w;
	}
}
int cnt[MAXN][MAXN];
void Output()
{
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= N; j++)
			if(A[i][j] == 0)
				A[i][j] = 1e9 + 7;
/*	for(int i = 1; i <= N; i++)
	{
		for(int j = 1; j <= N; j++)
			cout << A[i][j] << " ";
		cout << endl;
	}*/
	for(int k = 1; k <= N; k++)
		for(int u = 1; u <= N; u++)
			for(int v = 1; v <= N; v++)
				A[u][v] = min(A[u][v], A[u][k] + A[k][v]);
	/*for(int i = 1; i <= N; i++)
	{
		for(int j = 1; j <= N; j++)
			cout << A[i][j] << " ";
		cout << endl;
	}*/
	for(int i = 1; i <= N; i++)
		A[i][i] = 0;
	for(int u = 1; u <= N; u++)
		for(int i = 1; i <= M; i++)
		{
			int k = save[i].u;
			int v = save[i].v;
			int w = save[i].w;
			if(A[u][k] + w == A[u][v])
				cnt[u][v]++;
			swap(k, v);
			if(A[u][k] + w == A[u][v])
				cnt[u][v]++;
		}
	for(int u = 1; u <= N; u++)
		for(int v = u + 1; v <= N; v++)
		{
			int sum = 0;
			for(int k = 1; k <= N; k++)
				if(A[u][k] + A[k][v] == A[u][v])
					sum += cnt[u][k];
			cout << sum << " ";
		}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 //   freopen(task".inp", "r", stdin);
 //   freopen(task".out", "w", stdout);
    Input();
    Output();
    return 0;
}


#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;
#define pb(x)                       push_back(x)
#define ts(x)                       to_string(x)
#define ti(x)                       stoi(x)
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define mine(v)                     *min_element(all(v))
#define maxe(v)                     *max_element(all(v))
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"
inline ll input(){ll n; cin >> n ; return n;}
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const int MAXN = 500 + 10;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const ll INF = 8e17;
ll dis[MAXN][MAXN];
ll dp[MAXN][MAXN];
vector<pair<pll, ll> > edges;
ll n,m;
vector<ll> vec[MAXN][MAXN];
ll ans[MAXN][MAXN];
int main()
{
    fast_io;
    cin >> n >> m;
    ll a,b,w;
    for (int i = 1;i <= n;i++){
        for (int j = 1;j <= n;j++){
            if (i != j)
                dis[i][j] = INF;
        }
    }
    for (int i = 0;i < m;i++){
        cin >> a >> b >> w;
        dis[a][b] = w;
        dis[b][a] = w;
        edges.push_back({{a,b},w});
    }
    for(int k = 1;k <= n;k++){
        for (int j = 1;j <= n;j++){
            for (int i = 1;i <= n;i++){
                dis[i][j] = min(dis[i][j],dis[i][k] + dis[k][j]);
            }
        }
    }

    /*for (int i = 1; i<=n;i++){
        for (int j = 1;j<=n;j++){
            cout << i << tab << j << tab << dis[i][j] << endl;
        }
    }*/
    for(int i = 0;i < edges.size();i++){
        a = edges[i].F.F;
        b = edges[i].F.S;
        w = edges[i].S;
        for(int j = 1;j <= n;j++){
            if (dis[j][a] + w == dis[j][b]){
                dp[j][b]++;
            }
            if (dis[j][b] + w == dis[j][a]){
                dp[j][a]++;
            }
        }
    }
    for (int i = 1; i <= n;i++){
        for (int j = 1;j <= n;j++){
            for (int k = 1; k <= n;k++){
                if (dis[i][k] + dis[k][j] == dis[i][j]){
                    ans[i][j] += dp[i][k];
                }
            }
        }
    }
    for (int i = 1; i <= n;i++){
        for (int j = i + 1; j <= n;j++){
            cout << ans[i][j] << sep;
        }
    }
}


#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<ll,ll>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;
#define pb(x)                       push_back(x)
#define ts(x)                       to_string(x)
#define ti(x)                       stoi(x)
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define mine(v)                     *min_element(all(v))
#define maxe(v)                     *max_element(all(v))
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"
inline ll input(){ll n; cin >> n ; return n;}
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 500 + 10;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 8e17;
bool mark[MAXN][MAXN];
ll dis[MAXN][MAXN];
vector<pll> adj[MAXN];
vector<ll> w[MAXN];
set<ll> st[MAXN][MAXN];
ll n,m;

void memoize(ll v,ll u){
    ll nv,nu,w1,w2;
    ll dist = dis[v][u];
    for(ll v1 = 0;v1 < adj[v].size();v1++){
        nv = adj[v][v1].F;
        w1 = w[v][v1];
        for (ll u1 = 0;u1 < adj[u].size();u1++){
            nu = adj[u][u1].F;
            w2 = w[u][u1];
            if(nv == u and nu == v and w1 == dis[v][u]){
                st[v][u].insert(adj[u][u1].S);
                st[u][v].insert(adj[u][u1].S);
                mark[v][u] = true;
                mark[u][v] = true;
            }
            else{
                if(w1 + dis[nv][nu] + w2 > dis[v][u]){
                    continue;
                }
            }
            if(!mark[nv][nu]){
                memoize(nv,nu);
            }
            for(auto k:st[nv][nu]){
                st[v][u].insert(k);
            }
            st[v][u].insert(adj[u][u1].S);
            st[v][u].insert(adj[v][v1].S);
        }
    }
    for (auto k:st[v][u]){
        st[u][v].insert(k);
    }
    mark[v][u] = mark[u][v] = true;
}

int main()
{
    fast_io;
    cin >> n >> m;
    ll a,b,wei;
    for (ll i = 1;i <= n;i++){
        for(ll j = 1;j <= n;j++){
            if (i != j)
                dis[i][j] = INF;
        }
    }
    for (ll i = 1;i <= m;i++){
        cin >> a >> b >> wei;
        adj[a].push_back({b,i});
        adj[b].push_back({a,i});
        w[a].push_back(wei);
        w[b].push_back(wei);
        dis[a][b] = dis[b][a] = wei;
    }
    for (ll k = 1;k <= n;k++){
        for (ll j = 1;j <= n;j++){
            for (ll i = 1; i <= n;i++){
                dis[i][j] = min(dis[i][j],dis[i][k] + dis[k][j]);
            }
        }
    }
    for (ll i = 1;i <= n;i++){
        for (ll j = 1;j <= n;j++){
            if (!mark[i][j]){
                memoize(i,j);
            }
        }
    }
    for (ll i = 1;i <= n;i++){
        for (ll j = i + 1;j <= n;j++){
            cout << st[i][j].size() << sep;
        }
    }
}


#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<ll,ll>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;
#define pb(x)                       push_back(x)
#define ts(x)                       to_string(x)
#define ti(x)                       stoi(x)
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define mine(v)                     *min_element(all(v))
#define maxe(v)                     *max_element(all(v))
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"
inline ll input(){ll n; cin >> n ; return n;}
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 500 + 10;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 8e17;
bool mark[MAXN][MAXN];
ll dis[MAXN][MAXN];
vector<pll> adj[MAXN];
vector<ll> w[MAXN];
vector<ll> st[MAXN][MAXN];

ll n,m;
void memoize(ll v,ll u){
    bool mark2[MAXN * MAXN];
    memset(mark2,0,sizeof(mark2));
    ll nv,nu,w1,w2;
    ll dist = dis[v][u];
    for(ll v1 = 0;v1 < adj[v].size();v1++){
        nv = adj[v][v1].F;
        w1 = w[v][v1];
        if(nv == u and w1 == dis[v][u]){
            if (!mark2[adj[v][v1].S]){
                st[v][u].push_back(adj[v][v1].S);
                mark2[adj[v][v1].S] = true;
            }
            mark[v][u] = true;
            mark[u][v] = true;
        }
        else{
            if(w1 + dis[nv][u] > dis[v][u]){
                continue;
            }
        }
        if(!mark[nv][u]){
            memoize(nv,u);
        }
        for(auto k:st[nv][u]){
            if (!mark2[k]){
                st[v][u].push_back(k);
                mark2[k] = true;
            }
        }
        if (!mark2[adj[v][v1].S]){
            st[v][u].push_back(adj[v][v1].S);
            mark2[adj[v][v1].S] = true;
        }
    }
    for (auto k:st[v][u]){
        st[u][v].push_back(k);
    }
    mark[v][u] = mark[u][v] = true;
}

int main()
{
    fast_io;
    cin >> n >> m;
    ll a,b,wei;
    for (ll i = 1;i <= n;i++){
        for(ll j = 1;j <= n;j++){
            if (i != j)
                dis[i][j] = INF;
        }
    }
    for (ll i = 1;i <= m;i++){
        cin >> a >> b >> wei;
        adj[a].push_back({b,i});
        adj[b].push_back({a,i});
        w[a].push_back(wei);
        w[b].push_back(wei);
        dis[a][b] = dis[b][a] = wei;
    }
    for (ll k = 1;k <= n;k++){
        for (ll j = 1;j <= n;j++){
            for (ll i = 1; i <= n;i++){
                dis[i][j] = min(dis[i][j],dis[i][k] + dis[k][j]);
            }
        }
    }
    for (ll i = 1;i <= n;i++){
        for (ll j = i + 1;j <= n;j++){
            if (!mark[i][j]){
                memoize(i,j);
            }
        }
    }
    for (ll i = 1;i <= n;i++){
        for (ll j = i + 1;j <= n;j++){
            cout << st[i][j].size() << sep;
        }
    }
}


#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<ll,ll>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;
#define pb(x)                       push_back(x)
#define ts(x)                       to_string(x)
#define ti(x)                       stoi(x)
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define mine(v)                     *min_element(all(v))
#define maxe(v)                     *max_element(all(v))
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"
inline ll input(){ll n; cin >> n ; return n;}
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 500 + 10;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 8e17;
bool mark[MAXN][MAXN];
ll dis[MAXN][MAXN];
vector<pll> adj[MAXN];
vector<ll> w[MAXN];
vector<ll> st[MAXN][MAXN];

ll n,m;
void memoize(ll v,ll u){
    bool mark2[MAXN * MAXN];
    memset(mark2,0,sizeof(mark2));
    ll nv,nu,w1,w2;
    ll dist = dis[v][u];
    for(ll v1 = 0;v1 < adj[v].size();v1++){
        nv = adj[v][v1].F;
        w1 = w[v][v1];
        if(nv == u and w1 == dis[v][u]){
            if (!mark2[adj[v][v1].S]){
                st[v][u].push_back(adj[v][v1].S);
                mark2[adj[v][v1].S] = true;
            }
            mark[v][u] = true;
            mark[u][v] = true;
        }
        else{
            if(w1 + dis[nv][u] > dis[v][u]){
                continue;
            }
        }
        if(!mark[nv][u]){
            memoize(nv,u);
        }
        for(auto k:st[nv][u]){
            if (!mark2[k]){
                st[v][u].push_back(k);
                mark2[k] = true;
            }
        }
        if (!mark2[adj[v][v1].S]){
            st[v][u].push_back(adj[v][v1].S);
            mark2[adj[v][v1].S] = true;
        }
    }
    //st[v][u].resize(unique(all(st[v][u])) - st[v][u].begin());
    for (auto k:st[v][u]){
        st[u][v].push_back(k);
    }
    mark[v][u] = mark[u][v] = true;
}

int main()
{
    fast_io;
    cin >> n >> m;
    ll a,b,wei;
    for (ll i = 1;i <= n;i++){
        for(ll j = 1;j <= n;j++){
            if (i != j)
                dis[i][j] = INF;
        }
    }
    for (ll i = 1;i <= m;i++){
        cin >> a >> b >> wei;
        adj[a].push_back({b,i});
        adj[b].push_back({a,i});
        w[a].push_back(wei);
        w[b].push_back(wei);
        dis[a][b] = dis[b][a] = wei;
    }
    for (ll k = 1;k <= n;k++){
        for (ll j = 1;j <= n;j++){
            for (ll i = 1; i <= n;i++){
                dis[i][j] = min(dis[i][j],dis[i][k] + dis[k][j]);
            }
        }
    }
    for (ll i = 1;i <= n;i++){
        for (ll j = 1;j <= n;j++){
            if (!mark[i][j]){
                memoize(i,j);
            }
        }
    }
    for (ll i = 1;i <= n;i++){
        for (ll j = i + 1;j <= n;j++){
            cout << st[i][j].size() << sep;
        }
    }
    cout << endl;
}


#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<ll,ll>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;
#define pb(x)                       push_back(x)
#define ts(x)                       to_string(x)
#define ti(x)                       stoi(x)
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define mine(v)                     *min_element(all(v))
#define maxe(v)                     *max_element(all(v))
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"
inline ll input(){ll n; cin >> n ; return n;}
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 500 + 10;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 8e17;
bool mark[MAXN][MAXN];
ll dis[MAXN][MAXN];
vector<pll> adj[MAXN];
vector<ll> w[MAXN];
set<ll> st[MAXN][MAXN];
ll n,m;

void memoize(ll v,ll u){
    ll nv,nu,w1,w2;
    ll dist = dis[v][u];
    for(ll v1 = 0;v1 < adj[v].size();v1++){
        nv = adj[v][v1].F;
        w1 = w[v][v1];
        if(nv == u and w1 == dis[v][u]){
            st[v][u].insert(adj[v][v1].S);
            st[u][v].insert(adj[v][v1].S);
            mark[v][u] = true;
            mark[u][v] = true;
        }
        else{
            if(w1 + dis[nv][u] > dis[v][u]){
                continue;
            }
        }
        if(!mark[nv][u]){
            memoize(nv,u);
        }
        for(auto k:st[nv][u]){
            st[v][u].insert(k);
        }
        st[v][u].insert(adj[v][v1].S);
    }
    for (auto k:st[v][u]){
        st[u][v].insert(k);
    }
    mark[v][u] = mark[u][v] = true;
}

int main()
{
    fast_io;
    cin >> n >> m;
    ll a,b,wei;
    for (ll i = 1;i <= n;i++){
        for(ll j = 1;j <= n;j++){
            if (i != j)
                dis[i][j] = INF;
        }
    }
    for (ll i = 1;i <= m;i++){
        cin >> a >> b >> wei;
        adj[a].push_back({b,i});
        adj[b].push_back({a,i});
        w[a].push_back(wei);
        w[b].push_back(wei);
        dis[a][b] = dis[b][a] = wei;
    }
    for (ll k = 1;k <= n;k++){
        for (ll j = 1;j <= n;j++){
            for (ll i = 1; i <= n;i++){
                dis[i][j] = min(dis[i][j],dis[i][k] + dis[k][j]);
            }
        }
    }
    for (ll i = 1;i <= n;i++){
        for (ll j = 1;j <= n;j++){
            if (!mark[i][j]){
                memoize(i,j);
            }
        }
    }
    for (ll i = 1;i <= n;i++){
        for (ll j = i + 1;j <= n;j++){
            cout << st[i][j].size() << sep;
        }
    }
}


#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<int,int>                 pint;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;
#define pb(x)                       push_back(x)
#define ts(x)                       to_string(x)
#define ti(x)                       stoi(x)
#define aint(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define mine(v)                     *min_element(aint(v))
#define maxe(v)                     *max_element(aint(v))
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"
inline int input(){int n; cin >> n ; return n;}
int poww(int a, int b, int md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const int MAXN = 500 + 10;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const int INF = 1e9;
bool mark[MAXN][MAXN];
int dis[MAXN][MAXN];
vector<pint> adj[MAXN];
vector<int> w[MAXN];
vector<int> st[MAXN][MAXN];

int n,m;
void memoize(int v,int u){
    bool mark2[MAXN * MAXN];
    memset(mark2,0,sizeof(mark2));
    int nv,nu,w1,w2;
    int dist = dis[v][u];
    for(int v1 = 0;v1 < adj[v].size();v1++){
        nv = adj[v][v1].F;
        w1 = w[v][v1];
        if(nv == u and w1 == dis[v][u]){
            if (!mark2[adj[v][v1].S]){
                st[v][u].push_back(adj[v][v1].S);
                mark2[adj[v][v1].S] = true;
            }
            mark[v][u] = true;
            mark[u][v] = true;
        }
        else{
            if(w1 + dis[nv][u] > dis[v][u]){
                continue;
            }
        }
        if(!mark[nv][u]){
            memoize(nv,u);
        }
        for(auto k:st[nv][u]){
            if (!mark2[k]){
                st[v][u].push_back(k);
                mark2[k] = true;
            }
        }
        if (!mark2[adj[v][v1].S]){
            st[v][u].push_back(adj[v][v1].S);
            mark2[adj[v][v1].S] = true;
        }
    }
    for (auto k:st[v][u]){
        st[u][v].push_back(k);
    }
    mark[v][u] = mark[u][v] = true;
}

int main()
{
    fast_io;
    cin >> n >> m;
    int a,b,wei;
    for (int i = 1;i <= n;i++){
        for(int j = 1;j <= n;j++){
            if (i != j)
                dis[i][j] = INF;
        }
    }
    for (int i = 1;i <= m;i++){
        cin >> a >> b >> wei;
        adj[a].push_back({b,i});
        adj[b].push_back({a,i});
        w[a].push_back(wei);
        w[b].push_back(wei);
        dis[a][b] = dis[b][a] = wei;
    }
    for (int k = 1;k <= n;k++){
        for (int j = 1;j <= n;j++){
            for (int i = 1; i <= n;i++){
                dis[i][j] = min(dis[i][j],dis[i][k] + dis[k][j]);
            }
        }
    }
    for (int i = 1;i <= n;i++){
        for (int j = i + 1;j <= n;j++){
            if (!mark[i][j]){
                memoize(i,j);
            }
        }
    }
    for (int i = 1;i <= n;i++){
        for (int j = i + 1;j <= n;j++){
            cout << st[i][j].size() << sep;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=1;i<=n;i++)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)

typedef long long ll;
typedef pair<int,int> pii;
const int N = 510;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}

ll G[N][N],in[N][N];
int u[N],v[N];
ll INF = 1e13+2;
ll w[N];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1,n,i,j,k,m;
    int x,y;
    cin>>n>>m;
    fr(i,n)fr(j,n)G[i][j]=INF;
    fr(i,n)G[i][i]=0;
    fr(i,m){
        cin>>x>>y>>w[i];
        u[i]=x;
        v[i]=y;
        G[x][y]=min(G[x][y],w[i]);
        G[y][x]=G[x][y];
    }
    fr(k,n)fr(i,n)fr(j,n){
        if((G[i][k]+G[k][j]) < G[i][j])G[i][j]=(G[i][k]+G[k][j]);
    }
    fr(i,n){
            fr(k,m){
                int st=u[k],en=v[k];
                if((G[i][st]+w[k]) == G[i][en])in[i][en]++;
                if((G[i][en]+w[k]) == G[i][st])in[i][st]++;
                 }
            }

    fr(i,n){
        for(int j=i+1;j<=n;j++){
            int ans = 0;
            if(G[i][j]!=INF){
                fr(k,n){
                    if(G[i][k]+G[k][j] == G[i][j])ans+=in[i][k];

                 }
            }
            cout<<ans<<" ";
    }
    }
   cout<<"\n";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=1;i<=n;i++)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)

typedef long long ll;
typedef pair<int,int> pii;
const int N = 510;
const int M = 300010;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}

ll G[N][N],in[N][N];
int u[M],v[M];
ll INF = 1e13+2;
ll w[M];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1,n,i,j,k,m;
    int x,y;
    cin>>n>>m;
    fr(i,n)fr(j,n)G[i][j]=INF;
    fr(i,n)G[i][i]=0;
    fr(i,m){
        cin>>x>>y>>w[i];
        u[i]=x;
        v[i]=y;
        G[x][y]=min(G[x][y],w[i]);
        G[y][x]=G[x][y];
    }
    fr(k,n)fr(i,n)fr(j,n){
        if((G[i][k]+G[k][j]) < G[i][j])G[i][j]=(G[i][k]+G[k][j]);
    }
    fr(i,n){
            fr(k,m){
                int st=u[k],en=v[k];
                if((G[i][st]+w[k]) == G[i][en])in[i][en]++;
                if((G[i][en]+w[k]) == G[i][st])in[i][st]++;
                 }
            }

    fr(i,n){
        for(int j=i+1;j<=n;j++){
            int ans = 0;
            if(G[i][j]!=INF){
                fr(k,n){
                    if(G[i][k]+G[k][j] == G[i][j])ans+=in[i][k];

                 }
            }
            cout<<ans<<" ";
    }
    }
   cout<<"\n";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int n,m,u,v,w,d[569][2];
typedef pair<int,int> ii;
vector <ii> edge[569];
priority_queue <ii, vector <ii> , greater <ii> > Q;
void cal(int s){
    int u,v;
    for (int i=1;i<=n;i++) d[i][0]=1000000000,d[i][1]=0;
    d[s][0]=1;
    d[s][1]=0;
    Q.push(ii(0,s));
    while (Q.size()){
        u=Q.top().second;
        if (Q.top().first>d[u][0]){
            Q.pop();
            continue;
        }
        Q.pop();
        for (int i=0;i<edge[u].size();i++){
            v=edge[u][i].first;
            if (d[v][0]>d[u][0]+edge[u][i].second){
                d[v][0]=d[u][0]+edge[u][i].second;
                d[v][1]=d[u][1]+1;
                Q.push(ii(d[v][0],v));
            }
            else if (d[v][0]==d[u][0]+edge[u][i].second){
                d[v][1]+=(d[u][1]+1);
            }
        }
    }
    for (int i=s+1;i<=n;i++) cout<<d[i][1]<<" ";
}
int main(){
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++){
        scanf("%d%d%d",&u,&v,&w);
        edge[u].push_back(ii(v,w));
        edge[v].push_back(ii(u,w));
    }
    for (int i=1;i<=n;i++){
        cal(i);
    }
}


/// BFR is here!

#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007

using namespace std;

typedef long long ll;

int add(int a, int b)
{
    ll x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

int n, m, cost[502][502];

int dist[502][502];

vector<pair<int, int> >v[502];

struct cmp
{
    bool operator()(pair<int, int> a, pair<int, int> b)
    {
        return a.first > b.first;
    }
};
priority_queue<pair<int, int>, vector<pair<int, int> >, cmp>q;
bool was[50002];
void djk(int st)
{
    for(int i = 1; i <= n; ++i)
        dist[st][i] = (1<<30);
    dist[st][st] = 0;
    q.push({0, st});
    memset(was, 0, sizeof(was));
    while(!q.empty())
    {
        pair<int, int> nod = q.top();
        q.pop();
        if(was[nod.second])
            continue;
        was[nod.second] = 1;
        for(int i = 0; i < v[nod.second].size(); ++i)
        {
            pair<int, int> vecin = v[nod.second][i];
            if(nod.first + vecin.second < dist[st][vecin.first])
            {
                dist[st][vecin.first] = nod.first + vecin.second;
                q.push({dist[st][vecin.first], vecin.first});
            }
        }
    }
}

int ct[502][502], counter[502][502];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= m; ++i)
    {
        int a, b, c;
        cin >> a >> b >> c;
        v[a].pb({b, c});
        v[b].pb({a, c});
        cost[a][b] = cost[b][a] = c;
    }
    for(int i = 1; i <= n; ++i)
        djk(i);
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= n; ++j)
            for(int k = 1; k <= n; ++k)
                if(cost[i][k])
                    if(dist[i][j] == cost[i][k] + dist[j][k])
                        ct[i][j]++;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++)
            for(int k = 1; k <= n; k++)
                if(dist[i][j] == dist[i][k] + dist[k][j])
                    counter[i][j] += ct[k][i] + ct[k][j];
    for(int i = 1; i <= n; ++i)
        for(int j = i+1; j <= n; ++j)
            cout << counter[i][j] / 2 << " ";
    return 0;
}


/// BFR is here!

#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007

using namespace std;

typedef long long ll;

int add(int a, int b)
{
    ll x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

ll n, m, cost[502][502];

ll dist[502][502];

vector<pair<int, int> >v[502];

struct cmp
{
    bool operator()(pair<int, int> a, pair<int, int> b)
    {
        return a.first > b.first;
    }
};
priority_queue<pair<int, int>, vector<pair<int, int> >, cmp>q;
bool was[50002];
void djk(int st)
{
    for(int i = 1; i <= n; ++i)
        dist[st][i] = (1<<30);
    dist[st][st] = 0;
    q.push({0, st});
    memset(was, 0, sizeof(was));
    while(!q.empty())
    {
        pair<int, int> nod = q.top();
        q.pop();
        if(was[nod.second])
            continue;
        was[nod.second] = 1;
        for(int i = 0; i < v[nod.second].size(); ++i)
        {
            pair<int, int> vecin = v[nod.second][i];
            if(nod.first + vecin.second < dist[st][vecin.first])
            {
                dist[st][vecin.first] = nod.first + vecin.second;
                q.push({dist[st][vecin.first], vecin.first});
            }
        }
    }
}

int ct[502][502], counter[502][502];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= m; ++i)
    {
        int a, b, c;
        cin >> a >> b >> c;
        v[a].pb({b, c});
        v[b].pb({a, c});
        cost[a][b] = cost[b][a] = c;
    }
    for(int i = 1; i <= n; ++i)
        djk(i);
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= n; ++j)
            for(int k = 1; k <= n; ++k)
                if(cost[i][k])
                    if(dist[i][j] == cost[i][k] + dist[j][k])
                        ct[i][j]++;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++)
            for(int k = 1; k <= n; k++)
                if(dist[i][j] == dist[i][k] + dist[k][j])
                    counter[i][j] += ct[k][i] + ct[k][j];
    for(int i = 1; i <= n; ++i)
        for(int j = i+1; j <= n; ++j)
            cout << counter[i][j] / 2 << " ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 500 + 10, INF = (int) 1e9;
int dp[MAX_N][MAX_N], cnt[MAX_N][MAX_N], ans[MAX_N][MAX_N];
vector<pair<int, int>> adj[MAX_N];
int n, m;

void read_input() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (i != j)
				dp[i][j] = INF;
	for (int i = 0; i < m; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		u--, v--;

		adj[u].push_back({v, w});
		adj[v].push_back({u, w});
		dp[u][v] = w;
		dp[v][u] = w;
	}
}

void fill_dp() {
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			for (int k = 0; k < n; k++) {
				dp[j][k] = min(dp[j][k], dp[j][i] + dp[i][k]);
			}
}

void fill_cnt() {
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			for (auto k: adj[j]) {
				int v = k.first, w = k.second;
				if (dp[i][v] + w == dp[i][j])
					cnt[i][j]++;
			}
}

void fill_ans() {
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			for (int k = 0; k < n; k++)
				if (dp[i][k] + dp[k][j] == dp[i][j])
					ans[i][j] += cnt[i][k];
}

void solve() {
	fill_dp();
	fill_cnt();
	fill_ans();
}

void print_output() {
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			cout << ans[i][j] << ' ';
}

int main() {
	read_input();
	solve();
	print_output();
}


// In The Name Of Allah
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e10;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;
const ll mod = 1e9 + 7;

void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const ll M = 500 + 10;
const ll N = 200 * 1000 + 10;

ll dist[M][M], dp[M][M];
vector <pair <int, pii> > edge;

int main()
{
	faster();
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if(i == j)
			{
				dist[i][j] = 0;
			}
			else
			{
				dist[i][j] = inf;
			}
			dp[i][j] = 0;
		}
	}
	for (int i = 0; i < m; i++)
	{
		ll v, u, w;
		cin >> v >> u >> w;
		v--;
		u--;
		edge.push_back({w, {v, u}});
		dist[v][u] = min(dist[v][u], w);
		dist[u][v] = dist[v][u];
	}
	for (int k = 0; k < n; k++)
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
	for (auto e : edge)
	{
		for (int v = 0; v < n; v++)
		{
			if(dist[v][e.second.first] + e.first == dist[v][e.second.second])
			{
				dp[v][e.second.second]++;
			}
			if(dist[v][e.second.first] == dist[v][e.second.second] + e.first)
			{
				dp[v][e.second.first]++;
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			ll ans = 0;
			for (int k = 0; k < n; k++)
			{
				if(dist[i][k] + dist[k][j] == dist[i][j])
					ans += dp[i][k];
			}
			cout << ans << " ";
		}
	}
	cout << endl;
}


// In The Name Of Allah
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e10;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;
const ll mod = 1e9 + 7;

void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const ll M = 500 + 10;
const ll N = 200 * 1000 + 10;

ll dist[M][M], dp[M][M];
vector <pii> adj[M];

ll solve(int v, int u)
{
	if(dp[v][u] != -1)
		return dp[v][u];
	dp[v][u] = 0;
	for (int i = 0; i < adj[v].size(); i++)
	{
		int w = adj[v][i].first, to = adj[v][i].second;
		if(w + dist[to][u] == dist[v][u])
		{
			dp[v][u] += 1 + solve(to, u);
		}
	}
	return dp[v][u];
}

void de_bug(int n)
{
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cout << dist[i][j] << " ";
		}
		cout << endl;
	}
}

int main()
{
	faster();
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if(i == j)
				dist[i][j] = 0;
			else
				dist[i][j] = inf;
		}
	}
	for (int i = 0; i < m; i++)
	{
		ll v, u, w;
		cin >> v >> u >> w;
		v--;
		u--;
		adj[v].push_back({w, u});
		adj[u].push_back({w, v});
		dist[v][u] = min(dist[v][u], w);
		dist[u][v] = dist[v][u];
	}
	for (int k = 0; k < n; k++)
	{
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < n; j++)
				dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
		}
	}
//	de_bug(n);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if(i == j)
				dp[i][j] = 0;
			else
				dp[i][j] = -1;
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			dp[i][j] = solve(i, j);
			cout << dp[i][j] << " ";
		}
	}
	cout << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
const int mod = 1e9 + 7;
typedef long double f80;
#define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 505;
int dp[N][N];
int e[N * N][3];
int cnt[N];

signed main(){
    IO;
    //freopen("inp.txt", "r", stdin);
    // clock_t clk = clock();
    int n, m;
    cin >> n >> m;
    fr(i, 1, n){
        fr(j, 1, n){
            dp[i][j] = 1e9;
            if(i == j)
                dp[i][j] = 0;
        }
    }
    int u, v, w;
    fr(i, 1, m){
        cin >> u >> v >> w;
        dp[u][v] = w;
        dp[v][u] = w;
        e[i][0] = u, e[i][1] = v, e[i][2] = w;
    }
    fr(k, 1, n){
        fr(i, 1, n){
            fr(j, 1, n){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    fr(i, 1, n){
        fr(j, 1, n){
            cnt[j] = 0;
        }
        fr(j, 1, m){
            if(dp[i][e[j][0]] + e[j][2] == dp[i][e[j][1]])
                cnt[e[j][1]]++;
            if(dp[i][e[j][1]] + e[j][2] == dp[i][e[j][0]])
                cnt[e[j][0]]++;
        }
        fr(j, i + 1, n){
            int ans = 0;
            fr(k, 1, n){
                if(dp[i][j] == dp[i][k] + dp[k][j])
                    ans += cnt[k];
            }
            cout << ans << " ";
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
// #define int long long int
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
const int mod = 1e9 + 7;
typedef long double f80;
#define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 505;
pii dp[N][N];

inline pii operator +(const pii &a, const pii &b){
    return {a.fi + b.fi, a.se + b.se};
}
inline pii min(const pii &a, const pii &b){
    return ((a.fi < b.fi) ? a : b);
}

signed main(){
    IO;
    //freopen("inp.txt", "r", stdin);
    // clock_t clk = clock();
    int n, m;
    cin >> n >> m;
    fr(i, 1, n){
        fr(j, 1, n){
            if(i == j)
                dp[i][j] = {0, 0};
            else
                dp[i][j] = {1e9, 1e9};
        }
    }
    fr(i, 1, m){
        int u, v, w;
        cin >> u >> v >> w;
        dp[u][v] = {w, 1};
        dp[v][u] = {w, 1};
    }
    fr(k, 1, n){
        fr(i, 1, n){
            fr(j, 1, n){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    fr(i, 1, n){
        fr(j, i + 1, n){
            if(dp[i][j].fi == 1e9) dp[i][j].se = 0;
            cout << dp[i][j].se << " ";
        }
    }
    // cout << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
// #define int long long int
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
const int mod = 1e9 + 7;
typedef long double f80;
#define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 505;
const int NN = 120007;
int dp[N][N];
int e[N * N][3];
int mm[N][NN];

signed main(){
    IO;
    // freopen("inp.txt", "r", stdin);
    // clock_t clk = clock();
    int n, m;
    cin >> n >> m;
    fr(i, 1, n){
        fr(j, 1, n){
            dp[i][j] = 1e9;
            if(i == j)
                dp[i][j] = 0;
        }
    }
    int u, v, w;
    fr(i, 1, m){
        cin >> u >> v >> w;
        dp[u][v] = w;
        dp[v][u] = w;
        e[i][0] = u, e[i][1] = v, e[i][2] = w;
    }
    fr(k, 1, n){
        fr(i, 1, n){
            fr(j, 1, n){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    fr(i, 1, n){
        fr(j, 1, m){
            mm[e[j][1]][(dp[i][e[j][0]] + e[j][2]) % NN]++;
            mm[e[j][0]][(dp[i][e[j][1]] + e[j][2]) % NN]++;
        }
        fr(j, i + 1, n){
            int ans = 0;
            fr(k, 1, n){
                if(dp[i][j] - dp[k][j] >= 0){
                    ans += mm[k][(dp[i][j] - dp[k][j]) % NN];
                }
            }
            cout << ans << " ";
        }
        fr(j, 1, m){
            mm[e[j][1]][(dp[i][e[j][0]] + e[j][2]) % NN]--;
            mm[e[j][0]][(dp[i][e[j][1]] + e[j][2]) % NN]--;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
// #define int long long int
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
const int mod = 1e9 + 7;
typedef long double f80;
#define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 505;
const int NN = 200003;
int dp[N][N];
int e[N * N][3];
int mm[N][NN];

signed main(){
    IO;
    // freopen("inp.txt", "r", stdin);
    // clock_t clk = clock();
    int n, m;
    cin >> n >> m;
    fr(i, 1, n){
        fr(j, 1, n){
            dp[i][j] = 1e9;
            if(i == j)
                dp[i][j] = 0;
        }
    }
    int u, v, w;
    fr(i, 1, m){
        cin >> u >> v >> w;
        dp[u][v] = w;
        dp[v][u] = w;
        e[i][0] = u, e[i][1] = v, e[i][2] = w;
    }
    fr(k, 1, n){
        fr(i, 1, n){
            fr(j, 1, n){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    fr(i, 1, n){
        fr(j, 1, m){
            mm[e[j][1]][(dp[i][e[j][0]] + e[j][2]) % NN]++;
            mm[e[j][0]][(dp[i][e[j][1]] + e[j][2]) % NN]++;
        }
        fr(j, i + 1, n){
            int ans = 0;
            fr(k, 1, n){
                if(dp[i][j] - dp[k][j] >= 0){
                    ans += mm[k][(dp[i][j] - dp[k][j]) % NN];
                }
            }
            cout << ans << " ";
        }
        fr(j, 1, m){
            mm[e[j][1]][(dp[i][e[j][0]] + e[j][2]) % NN]--;
            mm[e[j][0]][(dp[i][e[j][1]] + e[j][2]) % NN]--;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
// #define int long long int
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
const int mod = 1e9 + 7;
typedef long double f80;
#define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 505;
const int NN =  399989;
int dp[N][N];
int e[N * N][3];
int mm[N][NN];

signed main(){
    IO;
    // freopen("inp.txt", "r", stdin);
    // clock_t clk = clock();
    int n, m;
    cin >> n >> m;
    fr(i, 1, n){
        fr(j, 1, n){
            dp[i][j] = 1e9;
            if(i == j)
                dp[i][j] = 0;
        }
    }
    int u, v, w;
    fr(i, 1, m){
        cin >> u >> v >> w;
        dp[u][v] = w;
        dp[v][u] = w;
        e[i][0] = u, e[i][1] = v, e[i][2] = w;
    }
    fr(k, 1, n){
        fr(i, 1, n){
            fr(j, 1, n){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    fr(i, 1, n){
        fr(j, 1, m){
            mm[e[j][1]][(dp[i][e[j][0]] + e[j][2]) % NN]++;
            mm[e[j][0]][(dp[i][e[j][1]] + e[j][2]) % NN]++;
        }
        fr(j, i + 1, n){
            int ans = 0;
            fr(k, 1, n){
                if(dp[i][j] - dp[k][j] >= 0){
                    ans += mm[k][(dp[i][j] - dp[k][j]) % NN];
                }
            }
            cout << ans << " ";
        }
        fr(j, 1, m){
            mm[e[j][1]][(dp[i][e[j][0]] + e[j][2]) % NN]--;
            mm[e[j][0]][(dp[i][e[j][1]] + e[j][2]) % NN]--;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
const int mod = 1e9 + 7;
typedef long double f80;
#define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 505;
int dp[N][N];
int e[N * N][3];
map<int,int> mm[N];

signed main(){
    IO;
    //freopen("inp.txt", "r", stdin);
    // clock_t clk = clock();
    int n, m;
    cin >> n >> m;
    fr(i, 1, n){
        fr(j, 1, n){
            dp[i][j] = 1e9;
            if(i == j)
                dp[i][j] = 0;
        }
    }
    int u, v, w;
    fr(i, 1, m){
        cin >> u >> v >> w;
        dp[u][v] = w;
        dp[v][u] = w;
        e[i][0] = u, e[i][1] = v, e[i][2] = w;
    }
    fr(k, 1, n){
        fr(i, 1, n){
            fr(j, 1, n){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    fr(i, 1, n){
        fr(j, 1, n)
            mm[j].clear();
        fr(j, 1, m){
            mm[e[j][1]][dp[i][e[j][0]] + e[j][2]]++;
            mm[e[j][0]][dp[i][e[j][1]] + e[j][2]]++;
        }
        fr(j, i + 1, n){
            int ans = 0;
            fr(k, 1, n){
                ans += mm[k][dp[i][j] - dp[k][j]];
            }
            cout << ans << " ";
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
// #define int long long int
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
const int mod = 1e9 + 7;
typedef long double f80;
#define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 505;
int dp[N][N];
int e[N * N][3];
unordered_map<int,int> mm[N];

signed main(){
    IO;
    // freopen("inp.txt", "r", stdin);
    // clock_t clk = clock();
    int n, m;
    cin >> n >> m;
    fr(i, 1, n){
        fr(j, 1, n){
            dp[i][j] = 1e9;
            if(i == j)
                dp[i][j] = 0;
        }
    }
    int u, v, w;
    fr(i, 1, m){
        cin >> u >> v >> w;
        dp[u][v] = w;
        dp[v][u] = w;
        e[i][0] = u, e[i][1] = v, e[i][2] = w;
    }
    fr(k, 1, n){
        fr(i, 1, n){
            fr(j, 1, n){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    fr(i, 1, n){
        fr(j, 1, n)
            mm[j].clear();
        fr(j, 1, m){
            mm[e[j][1]][dp[i][e[j][0]] + e[j][2]]++;
            mm[e[j][0]][dp[i][e[j][1]] + e[j][2]]++;
        }
        fr(j, i + 1, n){
            int ans = 0;
            fr(k, 1, n){
                ans += mm[k][dp[i][j] - dp[k][j]];
            }
            cout << ans << " ";
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
// #define int long long int
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
const int mod = 1e9 + 7;
typedef long double f80;
#define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 505;
const int NN = 65011;
const int NN1 = 65027;
int dp[N][N];
int e[N * N][3];
int mm[N][NN], mm1[N][NN1];

signed main(){
    IO;
    //freopen("inp.txt", "r", stdin);
    // clock_t clk = clock();
    int n, m;
    cin >> n >> m;
    fr(i, 1, n){
        fr(j, 1, n){
            dp[i][j] = 1e9;
            if(i == j)
                dp[i][j] = 0;
        }
    }
    int u, v, w;
    fr(i, 1, m){
        cin >> u >> v >> w;
        dp[u][v] = w;
        dp[v][u] = w;
        e[i][0] = u, e[i][1] = v, e[i][2] = w;
    }
    fr(k, 1, n){
        fr(i, 1, n){
            fr(j, 1, n){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    fr(i, 1, n){
        fr(j, 1, m){
            mm[e[j][1]][(dp[i][e[j][0]] + e[j][2]) % NN]++;
            mm[e[j][0]][(dp[i][e[j][1]] + e[j][2]) % NN]++;
            mm1[e[j][1]][(dp[i][e[j][0]] + e[j][2]) % NN1]++;
            mm1[e[j][0]][(dp[i][e[j][1]] + e[j][2]) % NN1]++;
        }
        fr(j, i + 1, n){
            int ans = 0;
            fr(k, 1, n){
                if(dp[i][j] - dp[k][j] >= 0){
                    ans += min(mm[k][(dp[i][j] - dp[k][j]) % NN], mm1[k][(dp[i][j] - dp[k][j]) % NN1]);
                }
            }
            cout << ans << " ";
        }
        fr(j, 1, m){
            mm[e[j][1]][(dp[i][e[j][0]] + e[j][2]) % NN]--;
            mm[e[j][0]][(dp[i][e[j][1]] + e[j][2]) % NN]--;
            mm1[e[j][1]][(dp[i][e[j][0]] + e[j][2]) % NN1]--;
            mm1[e[j][0]][(dp[i][e[j][1]] + e[j][2]) % NN1]--;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
// #define int long long int
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
const int mod = 1e9 + 7;
typedef long double f80;
#define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 505;
const int NN = 130007;
int dp[N][N];
int e[N * N][3];
int mm[N][NN];

signed main(){
    IO;
    // freopen("inp.txt", "r", stdin);
    // clock_t clk = clock();
    int n, m;
    cin >> n >> m;
    fr(i, 1, n){
        fr(j, 1, n){
            dp[i][j] = 1e9;
            if(i == j)
                dp[i][j] = 0;
        }
    }
    int u, v, w;
    fr(i, 1, m){
        cin >> u >> v >> w;
        dp[u][v] = w;
        dp[v][u] = w;
        e[i][0] = u, e[i][1] = v, e[i][2] = w;
    }
    fr(k, 1, n){
        fr(i, 1, n){
            fr(j, 1, n){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    fr(i, 1, n){
        fr(j, 1, m){
            mm[e[j][1]][(dp[i][e[j][0]] + e[j][2]) % NN]++;
            mm[e[j][0]][(dp[i][e[j][1]] + e[j][2]) % NN]++;
        }
        fr(j, i + 1, n){
            int ans = 0;
            fr(k, 1, n){
                if(dp[i][j] - dp[k][j] >= 0){
                    ans += mm[k][(dp[i][j] - dp[k][j]) % NN];
                }
            }
            cout << ans << " ";
        }
        fr(j, 1, m){
            mm[e[j][1]][(dp[i][e[j][0]] + e[j][2]) % NN]--;
            mm[e[j][0]][(dp[i][e[j][1]] + e[j][2]) % NN]--;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
const int mod = 1e9 + 7;
typedef long double f80;
#define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 505;
int dp[N][N];
int e[N * N][3];
map<int,int> mm[N];

signed main(){
    IO;
    // freopen("inp.txt", "r", stdin);
    // clock_t clk = clock();
    int n, m;
    cin >> n >> m;
    fr(i, 1, n){
        fr(j, 1, n){
            dp[i][j] = 1e9;
            if(i == j)
                dp[i][j] = 0;
        }
    }
    int u, v, w;
    fr(i, 1, m){
        cin >> u >> v >> w;
        dp[u][v] = w;
        dp[v][u] = w;
        e[i][0] = u, e[i][1] = v, e[i][2] = w;
    }
    fr(k, 1, n){
        fr(i, 1, n){
            fr(j, 1, n){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    fr(i, 1, n){
        fr(j, 1, n)
            mm[j].clear();
        fr(j, 1, m){
            mm[e[j][1]][dp[i][e[j][0]] + e[j][2]]++;
            mm[e[j][0]][dp[i][e[j][1]] + e[j][2]]++;
        }
        fr(j, i + 1, n){
            int ans = 0;
            fr(k, 1, n){
                ans += mm[k][dp[i][j] - dp[k][j]];
            }
            cout << ans << " ";
        }
    }
    return 0;
}


#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
// #define int long long int
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
const int mod = 1e9 + 7;
typedef long double f80;
#define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 505;
const int NN = 65011;
const int NN1 = 65027;
int dp[N][N];
int e[3][N * N];
int mm[N][NN], mm1[N][NN1];

signed main(){
    IO;
    //freopen("inp.txt", "r", stdin);
    // clock_t clk = clock();
    int n, m;
    cin >> n >> m;
    fr(i, 1, n){
        fr(j, 1, n){
            dp[i][j] = 1e9;
            if(i == j)
                dp[i][j] = 0;
        }
    }
    int u, v, w;
    fr(i, 1, m){
        cin >> u >> v >> w;
        dp[u][v] = w;
        dp[v][u] = w;
        e[0][i] = u, e[1][i] = v, e[2][i] = w;
    }
    fr(k, 1, n){
        fr(i, 1, n){
            fr(j, 1, n){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    fr(i, 1, n){
        fr(j, 1, m){
            mm[e[1][j]][(dp[i][e[0][j]] + e[2][j]) % NN]++;
            mm[e[0][j]][(dp[i][e[1][j]] + e[2][j]) % NN]++;
            mm1[e[1][j]][(dp[i][e[0][j]] + e[2][j]) % NN1]++;
            mm1[e[0][j]][(dp[i][e[1][j]] + e[2][j]) % NN1]++;
        }
        fr(j, i + 1, n){
            int ans = 0;
            fr(k, 1, n){
                if(dp[i][j] - dp[k][j] >= 0){
                    ans += min(mm[k][(dp[i][j] - dp[k][j]) % NN], mm1[k][(dp[i][j] - dp[k][j]) % NN1]);
                }
            }
            cout << ans << " ";
        }
        fr(j, 1, m){
            mm[e[1][j]][(dp[i][e[0][j]] + e[2][j]) % NN]--;
            mm[e[0][j]][(dp[i][e[1][j]] + e[2][j]) % NN]--;
            mm1[e[1][j]][(dp[i][e[0][j]] + e[2][j]) % NN1]--;
            mm1[e[0][j]][(dp[i][e[1][j]] + e[2][j]) % NN1]--;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
// #define int long long int
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
const int mod = 1e9 + 7;
typedef long double f80;
#define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 505;
int dp[N][N];
int e[N * N][3];
map<int,int> mm[N];

signed main(){
    IO;
    //freopen("inp.txt", "r", stdin);
    // clock_t clk = clock();
    int n, m;
    cin >> n >> m;
    fr(i, 1, n){
        fr(j, 1, n){
            dp[i][j] = 1e9;
            if(i == j)
                dp[i][j] = 0;
        }
    }
    int u, v, w;
    fr(i, 1, m){
        cin >> u >> v >> w;
        dp[u][v] = w;
        dp[v][u] = w;
        e[i][0] = u, e[i][1] = v, e[i][2] = w;
    }
    fr(k, 1, n){
        fr(i, 1, n){
            fr(j, 1, n){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    fr(i, 1, n){
        fr(j, 1, n)
            mm[j].clear();
        fr(j, 1, m){
            mm[e[j][1]][dp[i][e[j][0]] + e[j][2]]++;
            mm[e[j][0]][dp[i][e[j][1]] + e[j][2]]++;
        }
        fr(j, i + 1, n){
            int ans = 0;
            fr(k, 1, n){
                ans += mm[k][dp[i][j] - dp[k][j]];
            }
            cout << ans << " ";
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; i--)
#define REP(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define FORE(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fi   first
#define se   second
#define all(a) a.begin(), a.end()
#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)
#define endl '\n'

const int N = 505, oo = 1e9;
int mat[N][N], n, ans[N][N], edges[N], G[N][N];

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	clock_t tStart = clock();

	int m;
	cin >> n >> m;
	FOR(i, 1, n) FOR(j, 1, n) if (i != j) mat[i][j] = oo, G[i][j] = oo;
	FOR(i, 1, m) {
		int u, v, w;
		cin >> u >> v >> w;
		mat[u][v] = mat[v][u] = w;
		G[u][v] = G[v][u] = w;
	}
	FOR(k, 1, n) FOR(i, 1, n) FOR(j, 1, n) mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j]);
	FOR(i, 1, n) {
		memset(edges, 0, sizeof edges);
		FOR(j, 1, n) {
			FOR(k, 1, n) if (mat[i][k] + G[k][j] == mat[i][j] && k != j && mat[i][k] != oo && G[k][j] != oo) edges[j]++;
		}
		FOR(j, i + 1, n) {
			vector <int> V;
			V.clear();
			FOR(k, 1, n) if (mat[i][k] + mat[k][j] == mat[i][j] && mat[i][k] != oo && mat[k][j] != oo && mat[i][j] != oo) {
				V.push_back(k);
			}
			for (int v : V) {
				ans[i][j] += edges[v];
			}
		}
	}
	FOR(i, 1, n) FOR(j, i + 1, n) cout << ans[i][j] << ' ';

	fprintf(stderr, "Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
	return 0;
}


import java.util.Arrays;
import java.util.Scanner;

public class E {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		int[][] graph = new int[n][n];
		for (int i = 0; i < n; i++)
			Arrays.fill(graph[i], Integer.MAX_VALUE);
		for (int k = 0; k < m; k++) {
			int i = sc.nextInt() - 1, j = sc.nextInt() - 1, len = sc.nextInt();
			graph[i][j] = len;
			graph[j][i] = len;
		}
		sc.close();

		// floyd[i][j] = shortest path from i to j
		int[][] floyd = new int[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++)
				floyd[i][j] = graph[i][j];
			floyd[i][i] = 0;
		}
		for (int k = 0; k < n; k++)
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++)
					floyd[i][j] = Math.min(floyd[i][j], floyd[i][k]
							+ floyd[k][j]);

		// edge[i][j] = number of i's adjacent edges on shortest path to j
		int[][] edge = new int[n][n];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				for (int k = 0; k < n; k++)
					if (graph[i][k] < Integer.MAX_VALUE
							&& graph[i][k] + floyd[k][j] == floyd[i][j])
						edge[i][j]++;

		int[][] res = new int[n][n];
		for (int i = 0; i < n; i++)
			for (int j = i + 1; j < n; j++) {
				for (int k = 0; k < n; k++)
					if (floyd[i][k] + floyd[k][j] == floyd[i][j])
						res[i][j] += edge[k][j];
				System.out.print(res[i][j] + " ");
			}
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class E {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		int[][] graph = new int[n][n];
		for (int i = 0; i < n; i++)
			Arrays.fill(graph[i], Integer.MAX_VALUE);
		for (int k = 0; k < m; k++) {
			int i = sc.nextInt() - 1, j = sc.nextInt() - 1, len = sc.nextInt();
			graph[i][j] = len;
			graph[j][i] = len;
		}
		sc.close();

		// floyd[i][j] = shortest path from i to j
		int[][] floyd = new int[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++)
				floyd[i][j] = graph[i][j];
			floyd[i][i] = 0;
		}
		for (int k = 0; k < n; k++)
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++)
					if (floyd[i][k] < Integer.MAX_VALUE
							&& floyd[k][j] < Integer.MAX_VALUE)
						floyd[i][j] = Math.min(floyd[i][j], floyd[i][k]
								+ floyd[k][j]);

		// edge[i][j] = number of i's adjacent edges on shortest path to j
		int[][] edge = new int[n][n];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				for (int k = 0; k < n; k++)
					if (graph[i][k] < Integer.MAX_VALUE
							&& graph[i][k] + floyd[k][j] == floyd[i][j])
						edge[i][j]++;

		int[][] res = new int[n][n];
		for (int i = 0; i < n; i++)
			for (int j = i + 1; j < n; j++) {
				for (int k = 0; k < n; k++)
					if (floyd[i][k] + floyd[k][j] == floyd[i][j])
						res[i][j] += edge[k][j];
				System.out.print(res[i][j] + " ");
			}
	}
}


import java.io.BufferedReader;
import java.io.IOError;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Div2TaskE {

    FastIO scan = new FastIO();
    PrintWriter cout = new PrintWriter(System.out);

    void run() {

        int n = scan.nextInt();
        int m = scan.nextInt();

        int[][] graph = new int[n][n];
        int[][] floyd = new int[n][n];
        int[][] count = new int[n][n];
        int[][] answer = new int[n][n];
        final int INF = 1000000000;

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                floyd[i][j] = INF;
                graph[i][j] = INF;
            }
            floyd[i][i] = 0;
        }

        for (int i = 0; i < m; i++) {
            int u = scan.nextInt() - 1;
            int v = scan.nextInt() - 1;
            int w = scan.nextInt();
            graph[u][v] = graph[v][u] = w;
            floyd[u][v] = floyd[v][u] = w;
        }

        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (floyd[k][j] == INF || floyd[i][k] == INF)
                        continue;
                    floyd[i][j] = Math.min(floyd[i][j], floyd[i][k] + floyd[k][j]);
                }
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    if (floyd[k][j] == INF || floyd[i][j] == INF)
                        continue;
                    if (graph[i][k] + floyd[k][j] == floyd[i][j]) {
                        // System.out.println(k + " " +i + " " + j);
                        count[i][j]++;
                    }
                }
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    if (floyd[i][k] == INF || floyd[i][k] == INF || floyd[i][j] == INF)
                        continue;
                    if (floyd[i][k] + floyd[k][j] == floyd[i][j]) {
                        answer[i][j] += count[k][j];
                    }
                }
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                System.out.print(answer[i][j] + " ");
            }
        }
        System.out.println();

    }

    public static void main(String args[]) {
        new Div2TaskE().run();
    }

    public class FastIO {
        BufferedReader br;
        StringTokenizer st;
        PrintWriter out;

        public FastIO(InputStream in, OutputStream o) {
            br = new BufferedReader(new InputStreamReader(in));
            out = new PrintWriter(new OutputStreamWriter(o));
            eat("");
        }

        public FastIO() {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
            eat("");
        }

        public void eat(String s) {
            st = new StringTokenizer(s);
        }

        public String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                throw new IOError(e);
            }
        }

        public boolean hasNext() {
            while (!st.hasMoreTokens()) {
                String s = nextLine();
                if (s == null)
                    return false;
                eat(s);
            }
            return true;
        }

        public String next() {
            hasNext();
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public void print(String ans) {
            out.print(ans);
            out.flush();
        }

        public void println(String ans) {
            out.println(ans);
            out.flush();
        }

        public void close() {
            out.close();
        }

    }
}


import java.io.BufferedReader;
import java.io.IOError;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Div2TaskE {

	FastIO scan = new FastIO();
	PrintWriter cout = new PrintWriter(System.out);

	void run() {

		int n = scan.nextInt();
		int m = scan.nextInt();

		int[][] graph = new int[n][n];
		int[][] floyd = new int[n][n];
		int[][] count = new int[n][n];
		int[][] answer = new int[n][n];
		final int INF = 1000000000;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				floyd[i][j] = INF;
				graph[i][j] = INF;
			}
			floyd[i][i] = 0;
		}

		for (int i = 0; i < m; i++) {
			int u = scan.nextInt() - 1;
			int v = scan.nextInt() - 1;
			int w = scan.nextInt();
			graph[u][v] = graph[v][u] = w;
			floyd[u][v] = floyd[v][u] = w;
		}

		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					floyd[i][j] = Math.min(floyd[i][j], floyd[i][k] + floyd[k][j]);
				}
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					if (graph[i][k] + floyd[k][j] == floyd[i][j]) {
						count[i][j]++;
					}
				}
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				for (int k = 0; k < n; k++) {
					if (floyd[i][k] + floyd[k][j] == floyd[i][j]) {
						answer[i][j] += count[k][j];
					}
				}
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				System.out.print(answer[i][j] + " ");
			}
		}
		System.out.println();

	}

	public static void main(String args[]) {
		new Div2TaskE().run();
	}

	public class FastIO {
		BufferedReader br;
		StringTokenizer st;
		PrintWriter out;

		public FastIO(InputStream in, OutputStream o) {
			br = new BufferedReader(new InputStreamReader(in));
			out = new PrintWriter(new OutputStreamWriter(o));
			eat("");
		}

		public FastIO() {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			eat("");
		}

		public void eat(String s) {
			st = new StringTokenizer(s);
		}

		public String nextLine() {
			try {
				return br.readLine();
			} catch (IOException e) {
				throw new IOError(e);
			}
		}

		public boolean hasNext() {
			while (!st.hasMoreTokens()) {
				String s = nextLine();
				if (s == null)
					return false;
				eat(s);
			}
			return true;
		}

		public String next() {
			hasNext();
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public void print(String ans) {
			out.print(ans);
			out.flush();
		}

		public void println(String ans) {
			out.println(ans);
			out.flush();
		}

		public void close() {
			out.close();
		}

	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Main mainClass = new Main();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	public String next() throws Exception {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	public int nextInt() throws Exception {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws Exception {
		return Double.parseDouble(next());
	}

	public long nextLong() throws Exception {
		return Long.parseLong(next());
	}

	public Main() throws Exception {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(new OutputStreamWriter(System.out));

		solve();
		out.close();
	}

	static class Edge {
		int u, v, d;
	}
	public final static int INF = 1 << 29;

	int [][] runFloyd(int n, ArrayList<Edge> graph) {
		int [][] d = new int[n][n];
		for (int i = 0 ; i < n ; i++) {
			Arrays.fill(d[i], INF);
			d[i][i] = 0;
		}

		for (Edge e : graph) {
			d[e.u][e.v] = e.d;
			d[e.v][e.u] = e.d;
		}
		/*
		for (int i = 0 ; i < n ; i ++) {
			for (int j = 0 ; j < n ; j ++) {
				out.print(d[i][j] + " ");
			}
			out.println();
		}
		*/
		for (int k = 0 ; k < n ; k++) {
			for (int i = 0; i < n ; i++) {
				for (int j = 0 ; j < n ; j++) {

					if (d[i][k] < INF && d[k][j] < INF && d[i][k] + d[k][j] < d[i][j]) {
						d[i][j] = d[i][k] + d[k][j];
						//out.println("updating " + i + "," + j + " with " + d[i][j] + " through " + k);
					}
				}
			}
		}
		return d;
	}

	int n, m;
	ArrayList<Edge> graph;

	public void solve() throws Exception {
		n = nextInt(); m = nextInt();
		graph = new ArrayList<Edge>();
		for (int i = 0 ; i < m ; i++) {
			Edge e = new Edge();
			e.u = nextInt()-1;
			e.v = nextInt()-1;
			e.d = nextInt();
			graph.add(e);
		}
		int [][] d = runFloyd(n, graph);
		/*
		for (int i = 0 ; i < n ; i ++) {
			for (int j = 0 ; j < n ; j ++) {
				out.print(d[i][j] + " ");
			}
			out.println();
		}
		*/
		int [][] nextCount = new int[n][n];

		for (int x = 0 ; x < n ; x ++) {
			for (Edge e : graph) {
				if (d[x][e.u] < INF && d[x][e.v] < INF && d[x][e.u] == d[x][e.v] + e.d) {
					// that means v is next node on shortest path from x to u
					nextCount[e.u][x] ++;
				}
				if (d[x][e.u] < INF && d[x][e.v] < INF && d[x][e.v] == d[x][e.u] + e.d) {
					// that means v is next node on shortest path from x to u
					nextCount[e.v][x] ++;
				}
			}
		}

		int ans[][] = new int [n][n];

		for (int s = 0 ; s < n ; s ++) {
			for (int t = s + 1 ; t < n ; t ++) {
				if (d[s][t] >= INF)
					continue;
				for (int v = 0 ; v < n ; v ++) {
					if (d[s][v] >= INF || d[v][t] >= INF)
						continue;
					// if v is on shortest path between s and t,
					// increment ans[s][t] by nextCount[v][s] + nextCount[v][t]
					if (d[s][v] + d[v][t] == d[s][t]) {

						ans[s][t] += nextCount[v][s] + nextCount[v][t];

					}
				}
			}
		}
		for (int s = 0 ; s < n ; s ++) {
			for (int t = s + 1 ; t < n ; t ++) {
				out.print( (ans[s][t]/2) + " " );
			}
		}
		out.println();
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Main mainClass = new Main();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	public String next() throws Exception {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	public int nextInt() throws Exception {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws Exception {
		return Double.parseDouble(next());
	}

	public long nextLong() throws Exception {
		return Long.parseLong(next());
	}

	public Main() throws Exception {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(new OutputStreamWriter(System.out));

		solve();
		out.close();
	}

	static class Edge {
		int u, v, d;
	}
	public final static int INF = 1 << 29;

	int [][] runFloyd(int n, ArrayList<Edge> graph) {
		int [][] d = new int[n][n];
		for (int i = 0 ; i < n ; i++) {
			Arrays.fill(d[i], INF);
			d[i][i] = 0;
		}

		for (Edge e : graph) {
			d[e.u][e.v] = e.d;
			d[e.v][e.u] = e.d;
		}
		/*
		for (int i = 0 ; i < n ; i ++) {
			for (int j = 0 ; j < n ; j ++) {
				out.print(d[i][j] + " ");
			}
			out.println();
		}
		*/
		for (int i = 0; i < n ; i++) {
			for (int j = 0 ; j < n ; j++) {
				for (int k = 0 ; k < n ; k++) {
					if (d[i][k] < INF && d[k][j] < INF && d[i][k] + d[k][j] < d[i][j]) {
						d[i][j] = d[i][k] + d[k][j];
						//out.println("updating " + i + "," + j + " with " + d[i][j] + " through " + k);
					}
				}
			}
		}
		return d;
	}

	int n, m;
	ArrayList<Edge> graph;

	public void solve() throws Exception {
		n = nextInt(); m = nextInt();
		graph = new ArrayList<Edge>();
		for (int i = 0 ; i < m ; i++) {
			Edge e = new Edge();
			e.u = nextInt()-1;
			e.v = nextInt()-1;
			e.d = nextInt();
			graph.add(e);
		}
		int [][] d = runFloyd(n, graph);
		/*
		for (int i = 0 ; i < n ; i ++) {
			for (int j = 0 ; j < n ; j ++) {
				out.print(d[i][j] + " ");
			}
			out.println();
		}
		*/
		int [][] nextCount = new int[n][n];

		for (int x = 0 ; x < n ; x ++) {
			for (Edge e : graph) {
				if (d[x][e.u] == d[x][e.v] + e.d) {
					// that means v is next node on shortest path from x to u
					nextCount[e.u][x] ++;
				}
				if (d[x][e.v] == d[x][e.u] + e.d) {
					// that means v is next node on shortest path from x to u
					nextCount[e.v][x] ++;
				}
			}
		}

		int ans[][] = new int [n][n];

		for (int s = 0 ; s < n ; s ++) {
			for (int t = s + 1 ; t < n ; t ++) {
				for (int v = 0 ; v < n ; v ++) {
					// if v is on shortest path between s and t,
					// increment ans[s][t] by nextCount[v][s] + nextCount[v][t]
					if (d[s][v] + d[v][t] == d[s][t]) {
						ans[s][t] += nextCount[v][s] + nextCount[v][t];
					}
				}
			}
		}
		for (int s = 0 ; s < n ; s ++) {
			for (int t = s + 1 ; t < n ; t ++) {
				out.print( (ans[s][t]/2) + " " );
			}
		}
		out.println();
	}
}


import java.util.*;
import java.io.*;

public class Main{

  BufferedReader in;
  StringTokenizer str = null;
  PrintWriter out;

  private String next() throws Exception{
    while(str == null || !str.hasMoreElements())
      str = new StringTokenizer(in.readLine());
    return str.nextToken();
  }

  private int nextInt() throws Exception{
    return Integer.parseInt(next());
  }

  final static int oo = Integer.MAX_VALUE/2;
  int n,m;
  int [][]g;

  public void run() throws Exception{
    in = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);
    n = nextInt();
    m = nextInt();
    g = new int[n][n];
    for(int i=0;i<n;i++){
      Arrays.fill(g[i], oo);
    }

    for(int i=0;i<m;i++){
      int a = nextInt()-1, b = nextInt()-1;
      int cost = nextInt();
      g[a][b] = g[b][a] = cost;
    }
    /*
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        System.out.print(g[i][j] + " " );
      }
      System.out.println();
    }
    System.out.println();
    */
    int [][]d = new int[n][n];
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        d[i][j] = g[i][j];
      }
      d[i][i] = 0;
    }
    /*
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        System.out.print(g[i][j] + " " );
      }
      System.out.println();
    }
    */

    for(int k=0;k<n;k++){
      for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
          if (d[i][k] < oo && d[k][j] < oo){
            d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);
          }
        }
      }
    }

    int c[][] = new int[n][n];
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        for(int k=0;k<n;k++){
          if (d[i][j] < oo && g[i][k] < oo && d[k][j] < oo){
            if (g[i][k] + d[k][j] == d[i][j]){
              c[i][j]++;
            }
          }
        }
      }
    }

    int r[][] = new int[n][n];
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        if (d[i][j] < oo){
          for(int k=0;k<n;k++){
            if (d[i][k] < oo && d[k][j] < oo){
              if (d[i][j] == d[i][k] + d[k][j]){
                r[i][j]+=c[k][j];
              }
            }
          }
        }
      }
    }

    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        out.print(r[i][j] + " ");
      }
    }
    out.println();
    out.close();
  }

  public static void main(String args[]) throws Exception{
    new Main().run();
  }
}


import java.util.*;
import java.io.*;

public class Main{

  BufferedReader in;
  StringTokenizer str = null;
  PrintWriter out;

  private String next() throws Exception{
    while(str == null || !str.hasMoreElements())
      str = new StringTokenizer(in.readLine());
    return str.nextToken();
  }

  private int nextInt() throws Exception{
    return Integer.parseInt(next());
  }

  final static int oo = Integer.MAX_VALUE/2;
  int n,m;
  int [][]g;

  public void run() throws Exception{
    in = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);
    n = nextInt();
    m = nextInt();
    g = new int[n][n];
    for(int i=0;i<n;i++){
      Arrays.fill(g[i], oo);
    }

    for(int i=0;i<m;i++){
      int a = nextInt()-1, b = nextInt()-1;
      int cost = nextInt();
      g[a][b] = g[b][a] = cost;
    }

    for(int i=0;i<n-1;i++){
      int []f = dijkstra(i);
      for(int j=i+1;j<n;j++){
        out.print(f[j]+ " ");
      }
    }

    out.println();
    out.close();
  }

  private int[] dijkstra(int s){
    //System.out.println("Starting new Dijkstra");
    int []f = new int[n];
    f[s] = 0;

    boolean used[] = new boolean[n];
    int d[] = new int[n];
    Arrays.fill(d, oo);
    d[s] = 0;
    used[s] = true;

    while(true){
      /*
      System.out.println("Before");
      System.out.println(Arrays.toString(d));
      System.out.println(Arrays.toString(f));
      */
      for(int i=0;i<n;i++) if (!used[i]){
        if (d[i] >= d[s] + g[s][i]){
          if (d[i] == d[s] + g[s][i]){
            f[i]+=f[s]+1;
          }else{
            d[i] = d[s] + g[s][i];
            f[i] = f[s]+1;
          }
        }
      }
      /*
      System.out.println("After");
      System.out.println(Arrays.toString(d));
      System.out.println(Arrays.toString(f));
      */
      int idx = -1;
      int min = oo;
      for(int i=0;i<n;i++){
        if (!used[i] && min > d[i]){
          min = d[i];
          idx = i;
        }
      }
      if (idx == -1) break;
      used[idx] = true;
      s = idx;
    }

    for(int i=0;i<n;i++){
      if(d[i] == oo) f[i] = 0;
    }

    return f;
  }

  public static void main(String args[]) throws Exception{
    new Main().run();
  }
}