#include <bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int k=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}
	return k*f;
}
void write(int x){
	if(x<0)putchar('-'),x=-x;if(x>9)write(x/10);
	putchar(x%10+'0');
}
inline void writeln(int x){
	write(x);puts("");
}
const int N=1010,MOD=998244353;
int nedge=0,p[2*N],nex[2*N],head[2*N];
inline void addedge(int a,int b){
	p[++nedge]=b;nex[nedge]=head[a];head[a]=nedge;
}
int f[410][410],ans[410][410],vis[410],n,m;
inline void work(int a,int b){
	int x=a;memset(vis,0,sizeof vis);
	while(x!=b){
		int ss=0,ps=0;vis[x]=1;
		for(int k=head[x];k;k=nex[k])if(f[x][b]==f[p[k]][b]+1){
			ss++;ps=p[k];
		}
		if(ss>1){printf("0 ");return;}
		x=ps;
	}vis[b]=1;
	int ans=1;
	for(int i=1;i<=n;i++)if(!vis[i]){
		int cnt=0;
		for(int k=head[i];k;k=nex[k])if(f[a][p[k]]==f[a][i]-1&&f[b][p[k]]==f[b][i]-1)cnt++;
		ans=ans*cnt%MOD;
	}
	write(ans);putchar(' ');
}
signed main()
{
	n=read();m=read();
	memset(f,0x3f,sizeof f);
	for(int i=1;i<=m;i++){
		int x=read(),y=read();
		addedge(x,y);addedge(y,x);
		f[x][y]=f[y][x]=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++)work(i,j);
		puts("");
	}
	return 0;
}