#include<bits/stdc++.h>
#define ll long long
#define pi 3.1415926535897932384626
using namespace std;
  
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(x!=a.x) return x<a.x;
    //if(y!=a.y)
    return y<a.y;
  };
};
 
int a,b,c,d,i,n,m,e,ee,k,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[555][555];
long long l[555][555];
int ss[1];
int dp[1];
long long x,y,z;
const long long mod=998244353,hf=(mod+1)/2;
  
  
  
  
//string r;
char r[551][555];
vector<int> v[551];
P u[1];
queue<int> q;
  
  
//multiset<int> s;
stack<int> s;
//unordered_
map<int,int> p;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng()
bool as(P a,P b)
{
  //if(a.x!=b.x)
  //return a.x<b.x;
  //if(a.y!=b.y) return a.y>b.y;
  return a.x>b.x;
}

void ini(int e)
{
  q.push(e);
  o[e][e]=0;
  for(;q.size();)
  {
    int n=q.front();
    q.pop();
    for(int h=0;h<v[n].size();h++)
    if(o[e][v[n][h]]<0)
    {
      o[e][v[n][h]]=o[e][n]+1;
      q.push(v[n][h]);
    }
  }
}

int main()
{
  scanf("%d %d",&a,&b);
  memset(o,-1,sizeof(o));
  for(int t=1;t<=b;t++)
  {
    scanf("%d %d",&n,&m);
    v[n].push_back(m);
    v[m].push_back(n);
  }
  for(int t=1;t<=a;t++)
    ini(t);
  for(int i=1;i<=a;i++,puts(""))
    for(int j=1;j<=a;j++)
    {
      x=1;
      d=0;
      for(int k=1;k<=a;k++)
      if(k!=i&&k!=j&&o[i][k]+o[k][j]==o[i][j])//o[i][j]+o[j][k]!=o[i][k]&&o[j][i]+o[i][k]!=o[j][k]&&o[i][j]!=o[i][k]+o[k][j])
      {
        d++;
        //if(i==6&&j==5) printf("!!%d# %d %d %d!!",k,o[i][j],o[i][k],o[k][j]);
      }
      if(d!=o[i][j]-1&&i!=j)
      {
        printf("0 ");
        goto qwe;
      }
      
      for(int k=1;k<=a;k++)
      if(o[i][k]+o[k][j]!=o[i][j])
      {
        e=0;
        for(int h=0;h<v[k].size();h++)
        {
          if(o[i][v[k][h]]+1==o[i][k]&&o[j][v[k][h]]+1==o[j][k]) e++;
          else if(o[i][v[k][h]]+1==o[i][k]&&o[j][v[k][h]]==o[j][k]+1&&o[i][j]==o[i][k]+o[k][j]&&o[i][j]==o[i][v[k][h]]+o[v[k][h]][j]) e++;
        }
        x*=e;
        x%=mod;
      }
      printf("%lld ",x);
      qwe:;
    }
}


