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

const int Mod=998244353;
namespace modular{
	int add(int a,int b){return a+b>=Mod?a+b-Mod:a+b;}
	int mul(int a,int b){return 1ll*a*b%Mod;}
}using namespace modular;

typedef long long ll;
typedef pair<int,int> pii;
#define FR first
#define SE second

#define cout cerr
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)

inline void rd(int &x){
	x=0;char ch=getchar();int f=1;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	x*=f;
}

int n,m;
#define Maxn 605
int head[Maxn],v[Maxn<<1],nxt[Maxn<<1],tot=0;
inline void add_edge(int s,int e){
	tot++;v[tot]=e;nxt[tot]=head[s];head[s]=tot;
	tot++;v[tot]=s;nxt[tot]=head[e];head[e]=tot;
}

int Q[Maxn],hd,tl;
void Bfs(int *d,int S){
	d[S]=0;hd=tl=0;
	Q[tl++]=S;
	memset(d,-1,sizeof(int)*(n+1));d[S]=0;
	while(hd<tl){
		int u=Q[hd];hd++;
		for(int i=head[u];i;i=nxt[i])
			if(d[v[i]]<0){
				d[v[i]]=d[u]+1;
				Q[tl++]=v[i];
			}
	}
}

int dis[Maxn][Maxn];
int node[Maxn];
bool rel[Maxn][Maxn];
int Ans[Maxn][Maxn];
vector<int> g[Maxn];
int vis[Maxn],visT;
int calc(vector<pii> &a,int rt){
	int mx=0;
	for(int i=0;i<a.size();++i)mx=max(mx,a[i].FR);
	if(mx>(int)a.size())return 0;
	rep(i,0,mx)g[i].clear();
	g[0].push_back(rt);
	for(int i=0;i<a.size();++i)g[a[i].FR].push_back(a[i].SE);
	int res=1;
	rep(i,1,mx){
		if(g[i].size()==0)return 0;
		visT++;
		for(int j=0;j<g[i-1].size();++j)vis[g[i-1][j]]=visT;
		for(int j=0;j<g[i].size();++j){
			int u=g[i][j];int cur=0;
			for(int k=head[u];k;k=nxt[k])
				if(vis[v[k]]==visT)cur++;
			res=mul(res,cur);
		}
	}
	return res;
}

vector<pii> vec[Maxn];
void check(int x,int y){
	int D=dis[x][y];
	node[D]=y;node[0]=x;
	rep(i,1,D-1)node[i]=-1;
	rep(i,0,D)vec[i].clear();
	rep(i,1,n)
		if(i!=x&&i!=y){
			int t1=dis[i][x],t2=dis[i][y];
			if((t1+t2-D)%2==1)return;
			int p=(t1+t2-D)/2;
			if(p==0){
				if(node[t1]!=-1)return;
				node[t1]=i;
			}else{
				vec[t1-p].push_back(pii(p,i));
			}
		}
	rep(i,1,D-1)
		if(node[i]==-1)return;
	rep(i,0,D-1)
		if(!rel[node[i]][node[i+1]])return;
	int ans=1;
	rep(i,0,D)ans=mul(ans,calc(vec[i],node[i]));
	Ans[x][y]=Ans[y][x]=ans;
}

int main(){
	rd(n);rd(m);
	int s,e;
	rep(i,1,m){
		rd(s);rd(e);
		rel[s][e]=rel[e][s]=true;
		add_edge(s,e);
	}
	rep(i,1,n)Bfs(dis[i],i);
	rep(i,1,n)rep(j,i,n)check(i,j);
	rep(i,1,n){
		rep(j,1,n)printf("%d ",Ans[i][j]);
		puts("");
	}
	return 0;
}