// COCI-2008-3
// 2008.12.13

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

#define VI vector<int>
#define int64 long long
#define VVI vector <vector<int> >

#define SZ(a) a.size()
#define MP make_pair
#define PII pair<int, int>
#define PB push_back
#define ALL(a) a.begin(), a.end()
#define CLA(a) memset(a, 0, sizeof(a))
#define FOR(i,n) for (int i = 0; i < int(n); i++)
#define FORE(i,a, b) for (int i = a; i <= b; i++)
#define FORR(i,n) for (int i = n - 1; i >=0; i--)
#define REP(n) for (int _foo = n - 1; _foo >= 0; _foo--)

#define INF 1000000000

int ri() {int t; scanf("%d", &t); return t;}
void rs(char *s) {scanf("%s", s);}
void pi(int n){printf("%d\n", n);}

int a[32][32], a0[32][32], n, m, res, e;

int fe[32][32];

int vv[32];

int ed[32][3];

int dfs(int v, int vto, int d, int f)
{
	if (d < 0) return 0;
	if (v == vto) return f;
	if (d <= 0) return 0;

	int fff[32]; CLA(fff);

	vv[v] = 1;
	int res = 0;
	
	FORE(t, 1, m) if (ed[t][0] == v && !vv[ed[t][1]] && !fff[ed[t][1]])
	{
		res += dfs(ed[t][1], vto, d - ed[t][2], f || (t == e));
		fff[ed[t][1]] = 1;
	}
	
	FORE(t, 1, m) if (ed[t][1] == v && !vv[ed[t][0]] && !fff[ed[t][0]])
	{
		res += dfs(ed[t][0], vto, d - ed[t][2], f || (t == e));
		fff[ed[t][0]] = 1;
	}
	
	vv[v] = 0;
	return res;
}

int main()
{
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
	n = ri();
	m = ri();
	for (e = 1; e <= m; e++)
	{
		int v1 = ri();
		int v2 = ri();
		int w = ri();
		ed[e][0] = v1;
		ed[e][1] = v2;
		ed[e][2] = w;
		a0[v1][v2] = a[v1][v2] = min(a[v1][v2] ? a[v1][v2] : INF, w);
//		fe[v1][v2] = e;
	}
	FORE(k, 1, n)FORE(i, 1, n) FORE(j, 1, n)
		if (a[i][k] && a[k][j])
			a[i][j] = min(a[i][j] ? a[i][j] : INF, a[i][k] + a[k][j]);

	for (e = 1; e <= m; e++)
	{
		res = 0;
		FORE(v1, 1, n) FORE(v2, 1, n) if (v1 != v2 && a[v1][v2] < INF)
		{
			CLA(vv);
			res += dfs(v1, v2, a[v1][v2], 0);
		}
		pi(res);
	}

}
