#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=405;
const ll mod=998244353;
vector<int>e[N];
int n,m,d[N][N];ll ans[N][N];
int main()
{
	int i,j,x,y,k;
	// ios::sync_with_stdio(false);
	// cin.tie(0);
	memset(d,0x3f,sizeof(d));
	cin>>n>>m;
	for(i=1;i<=m;i++){
		cin>>x>>y;
		d[x][y]=d[y][x]=1;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	for(i=1;i<=n;i++)d[i][i]=0;
	for(k=1;k<=n;k++)
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++){
			vector<int>h(n+1);
			bool line=1;
			for(k=1;k<=n;k++)
				if(d[i][j]==d[i][k]+d[k][j]){
					if(!h[d[i][k]])h[d[i][k]]=1;
					else {line=0;break;}
				}
			for(k=0;k<=d[i][j];k++)if(!h[k]){line=0;break;}
			if(!line)continue;
			ans[i][j]=1;
			for(k=1;k<=n;k++){
				if(d[i][j]==d[i][k]+d[k][j])continue;
				ll cnt=0;
				for(auto x:e[k]){
					if(d[x][i]+1==d[k][i]&&d[x][j]+1==d[k][j])cnt++;
				}
				ans[i][j]=(ans[i][j]*cnt)%mod;
			}
		}
	for(i=1;i<=n;i++,cout<<'\n')
		for(j=1;j<=n;j++)cout<<ans[i][j]<<' ';
}
/*
8 9
1 2
1 3
1 4
2 7
3 5
3 6
4 8
2 3
3 4

*/