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

#define gc getchar

int gi() {
	int x = 0, c = gc();
	bool f = 0;
	for(; !isdigit(c); c = gc()) if(c == '-') f = 1;
	for(; isdigit(c); c = gc()) x = x * 10 + (c & 15);
	return f ? -x : x;
}

const int N = 405;
const int M = 605;
const int mod = 998244353;

int n, m, u[M], v[M], f[N][N], ind[N];

void solve(int x, int y) {
	int cnt = 0;
	for(int i = 1; i <= m; ++i) {
		if(min(f[x][u[i]] + f[v[i]][y], f[x][v[i]] + f[u[i]][y]) == f[x][y] - 1) {
			cnt++;
		}
	}
//	printf("solve(%d, %d) %d %d\n", x, y, cnt, f[x][y]);
	if(cnt > f[x][y]) {
		printf("0"); return;
	}
	memset(ind, 0, sizeof(ind));
	for(int i = 1; i <= m; ++i) {
		if(f[x][u[i]] + 1 == f[x][v[i]] && f[y][u[i]] + 1 == f[y][v[i]]) {
			++ind[v[i]];
		}
		if(f[x][v[i]] + 1 == f[x][u[i]] && f[y][v[i]] + 1 == f[y][u[i]]) {
			++ind[u[i]];
		}
	}
	int ans = 1;
	for(int i = 1; i <= n; ++i) {
		if(f[x][i] + f[i][y] > f[x][y]) {
			ans = 1ll * ans * ind[i] % mod;
		}
	}
	printf("%d", ans);
}
int main() {
	n = gi(); m = gi();
	memset(f, 0x3f, sizeof(f));
	for(int i = 1; i <= m; ++i) {
		u[i] = gi(); v[i] = gi();
		f[u[i]][v[i]] = 1;
		f[v[i]][u[i]] = 1;
	}
	for(int i = 1; i <= n; ++i) {
		f[i][i] = 0;
	}
	for(int k = 1; k <= n; ++k) {
		for(int i = 1; i <= n; ++i) {
			for(int j = 1; j <= n; ++j) {
				f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
			}
		}
	}
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) {
			solve(i, j); printf(" ");
		}
		puts("");
	}
	return 0;
}