#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
 
#define F first
#define S second
 
const int MOD = 998244353;// XXX
const int C = 26;// XXX
 
void add(int &x, int y){
	x += y;
	while (x >= MOD) x -= MOD;
	while (x < 0) x += MOD;
}
 
int fix(int x){
	while (x >= MOD) x -= MOD;
	while (x < 0) x += MOD;
	return x;
}
 
int pw(int a, int b){
	int ret = 1;
	while (b){
		if (b & 1)
			ret = 1ll*ret*a%MOD;
		b >>= 1;
		a = 1ll*a*a%MOD;
	}
	return ret;
}

int mul(int a, int b) {
	return (ll) a * b % MOD;
}

const int MAXN = 405;
const int MAXE = 605;

int n, m, d[MAXN][MAXN], ans[MAXN][MAXN];
pii edges[MAXE];

int onPath[MAXN], foundLen[MAXN], numPar[MAXN];

void solve() {
	cin >> n >> m;
	memset(d, 63, sizeof(d));

	for(int i = 0; i < m; i++) {
		int a, b; cin >> a >> b; --a; --b;
		edges[i] = {a, b};
		d[a][b] = d[b][a] = 1;
	}
	for(int i = 0; i < n; i++)
		d[i][i] = 0;
	
	for(int k = 0; k < n; k++)
		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++)
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	
	for(int u = 0; u < n; u++) {
		for(int v = 0; v < n; v++) {
			bool ok = 1;
			int cnt = 1;
			memset(onPath, 0, sizeof(onPath));
			memset(numPar, 0, sizeof(numPar));
			memset(foundLen, 0, sizeof(foundLen));

			for(int w = 0; w < n; w++) {
				if(d[u][w] + d[v][w] == d[u][v]) {
					onPath[w] = 1;
					if(foundLen[d[u][w]]) 
						ok = 0;
					foundLen[d[u][w]] = 1;
				}
			}
			for(int len = 0; len <= d[u][v]; len++) 
				if(!foundLen[len]) 
					ok = 0;

			for(int e = 0; e < m; e++) {
				for(int rot = 0; rot < 2; rot++) {
					auto &[a, b] = edges[e];
					if(!onPath[a]) {
						if(d[u][a] == d[u][b] + 1 && d[v][a] == d[v][b] + 1) {
							++numPar[a];
						}
					}
					swap(a, b);
				}
			}
			for(int w = 0; w < n; w++) 
				if(!onPath[w])
					cnt = mul(cnt, numPar[w]);
			
			if(ok) 
				ans[u][v] = cnt;
		}
	}
	
	for(int u = 0; u < n; u++) {
		for(int v = 0; v < n; v++) {
			cout << ans[u][v] << " ";
		}
		cout << "\n";
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// cout << fixed << setprecision(6);
	
	int te = 1;	
	// cin >> te;
	for (int w = 1; w <= te; w++){
		// cout << "Case #" << w << ": ";
		solve();
	}
	return 0;
}
