// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#define int long long int
#define ll long long
#define ld long double
#define getFaster ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define rep(i, init, n) for (int i = init; i < (int)n; i++)
#define rev(i, n, init) for (int i = (int)n; i >= init; i--)
#define MOD1 1e9 + 7
#define MOD2 998244353
#define f first
#define s second
#define endl '\n'
#define pii pair<int, int>
#define tii tuple<int, int>
#define all(v) v.begin(), v.end()
#define mt make_tuple
#define precise(i) cout << fixed << setprecision(i)
#define codejam cout << "Case #" << ii + 1 << ": ";
#define impossible cout << "IMPOSSIBLE" << endl;
#define error(s) throw runtime_error(s)
#define hash hash1
#define prev prev1
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
int myRand(int R)
{
     int val = rng() % R;
     assert(val >= 0);
     return val;
}

const long double PI = atan(1.0) * 4;
const int32_t INF32 = 2e9 + 7;
const int64_t INF64 = 3e18;
const int32_t LOG = 21;
int MOD = MOD1;

using namespace std;

//-------------------DEBUGGING-------------------------
void my_debugger(string s, int LINE_NUM) { cerr << endl; }
template <typename start, typename... end>
void my_debugger(string s, int LINE_NUM, start x, end... y)
{
     if (s.back() != ',')
     {
          s += ',';
          cerr << "LINE(" << LINE_NUM << "): ";
     }
     int i = s.find(',');
     cerr << s.substr(0, i) << " = " << x;
     s = s.substr(i + 1);
     if (!s.empty())
          cerr << ", ";
     my_debugger(s, LINE_NUM, y...);
}

#ifdef AJIT
#define debug(...) my_debugger(#__VA_ARGS__, __LINE__, __VA_ARGS__);
#else
#define debug(...) ;
#endif

void setMod(int mod_val)
{
     MOD = mod_val;
}

void files_init()
{
     freopen("maxflow.in", "r", stdin);
     freopen("maxflow.out", "w", stdout);
}

const int N = 2e5 + 5;
const int LOGN = 20;

//-----------------------------------------------------

int dist[405][405];
int prev[405][405];

void bfs(int src,vector<vector<int>>& g)
{
     queue<tuple<int,int,int>> q;
     int n=(int)g.size()-1;
     vector<bool> check(n+1,false);
     q.push({0,src,0});
     while(!q.empty())
     {
          int d,ver,par;
          tie(d,ver,par)=q.front();
          q.pop();
          if(check[ver])continue;
          check[ver]=true;
          dist[src][ver]=d;
          prev[src][ver]=par;
          for(auto it:g[ver])
          {
               if(check[it])
               continue;
               q.push({d+1,it,ver});
          }
     }
}

int solve(int i,int j,vector<vector<int>>& g)
{
     int ans=1;
     int n=(int)g.size()-1;

     vector<bool> check(n+1);
     int cur=j;
     while(cur)
     {
          check[cur]=true;
          cur=prev[i][cur];
     }

     rep(ver,1,n+1)
     {
          if(check[ver])
          continue;

          int common=0;
          for(auto it:g[ver])
          {
               if(dist[i][it]+1==dist[i][ver] && dist[j][it]+1==dist[j][ver])
               common++;
          }
          
          ans=(ans*common)%MOD;
     }
     return ans;
}

int32_t main()
{
     getFaster;
     //files_init();
     int tests = 1;
     //cin >> tests;
     rep(ii, 0, tests)
     {
          setMod(MOD2);

          int n,m;
          cin>>n>>m;
          vector<vector<int>> g(n+1);
          rep(i,0,m)
          {
               int x,y;
               cin>>x>>y;
               g[x].push_back(y);
               g[y].push_back(x);
          }

          rep(i,1,n+1)
          bfs(i,g);

          vector<vector<int>> ans(n+1,vector<int>(n+1));

          rep(i,1,n+1)
          {
               rep(j,1,n+1)
               {
                     if(i>j)
                     {
                          ans[i][j]=ans[j][i];
                          continue;
                     }
                     ans[i][j]=solve(i,j,g);
               }
          }

          rep(i,1,n+1)
          {
               rep(j,1,n+1)
               cout<<ans[i][j]<<" ";
               cout<<endl;
          }
     }

     return 0;
}