#include<bits/stdc++.h>
#define ll long long
#define db double
#define int long long
using namespace std;
inline int read() {
	int x = 0; bool op = false;
	char c = getchar();
	while(!isdigit(c))op |= (c == '-'), c = getchar();
	while(isdigit(c))x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return op ? -x : x;
}
const int N = 410;
const int M = 610;
const int Mod = 998244353;
int n, m, tot;
int head[N], to[M * 2], nxt[M * 2], dis[N][N], ans[N][N];
void addedge(int u, int v) {
	to[++tot] = v; nxt[tot] = head[u]; head[u] = tot;
	return ;
}
void getdis(int st) {
	dis[st][st] = 0; 
	queue<int> q;
	q.push(st);
	while(q.empty() == false) {
		int u = q.front(); q.pop();
		for(int i = head[u]; i; i = nxt[i]) {
			if(dis[st][to[i]] > dis[st][u] + 1) {
				dis[st][to[i]] = dis[st][u] + 1;
				q.push(to[i]);
			}
		}
	}
	return ;
}
signed main() {
	n = read(); m = read();
	for(int i = 1; i <= m; i++) {
		int u = read(), v = read();
		addedge(u, v); addedge(v, u);
	}
	memset(dis, 0x3f, sizeof(dis));
	for(int i = 1; i <= n; i++)getdis(i);
//	for(int i = 1; i <= n; i++) {
//		for(int j = 1; j <= n; j++) {
//			printf("%d ", dis[i][j]);
//		}
//		puts("");
//	}
	for(int i = 1; i <= n; i++) {
		for(int j = i; j <= n; j++) {
			int cnt = 0;
			for(int k = 1; k <= n; k++) {
				if(dis[i][k] + dis[k][j] == dis[i][j]) {
					cnt++;
				}
			}
			if(cnt > dis[i][j] + 1) {
//				printf("W:%d %d %d\n", i, j, cnt);
				ans[i][j] = 0;
			}
			else {
				ans[i][j] = 1;
				for(int k = 1; k <= n; k++) {
					if(dis[i][k] + dis[k][j] == dis[i][j])continue;
					int t = 0;
					for(int e = head[k]; e; e = nxt[e]) {
						if(dis[i][k] == dis[i][to[e]] + 1 && dis[j][k] == dis[j][to[e]] + 1) {
							t++;
						}
					}
					ans[i][j] = ans[i][j] * t % Mod;
				}
				ans[j][i] = ans[i][j];
			}
		}
	}
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			printf("%lld ", ans[i][j]);
		}
		puts("");
	}
	return 0;
}
