#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define pii pair<int,int>
const int N=1e6+10;
const int mod=998244353;
using namespace std;


void solve(){
    int n, m; scanf("%d %d", &n, &m);
    vector<vector<int> > mp(n+1, vector<int>(n+1, (int)(1e9)));
    vector<vector<int> > v(n+1, vector<int>());
    for(int i = 1; i <= n; ++i) mp[i][i] = 0;
    for(int i = 1; i <= m; ++i) {
        int x, y; scanf("%d %d", &x, &y);
        mp[x][y] = mp[y][x] = 1;
        v[x].pb(y), v[y].pb(x);
    }
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= n; ++j)
            for(int k = 1; k <= n; ++k)
                mp[j][k] = min(mp[j][k], mp[j][i] + mp[i][k]);
    vector<vector<int> > res(n+1, vector<int>(n+1, 0));
    for(int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            int ans = 1, cc = 0;
            for (int k = 1; k <= n; ++k) if(mp[i][k] + mp[k][j] == mp[i][j]) cc++;
            if(cc > mp[i][j] + 1) continue;
            for (int k = 1; k <= n; ++k) if(mp[i][k] + mp[k][j] != mp[i][j]) {
                int cnt = 0;
                for (auto e : v[k]) if(mp[k][i] == mp[e][i] + 1 && mp[k][j] == mp[e][j] + 1) cnt++;
                ans = 1ll * ans * cnt % mod;
            }
            res[i][j] = res[j][i] = ans;
        }
    }
    for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) printf("%d%c", res[i][j], " \n"[j==n]);
}
int main(){
    int T = 1;  //scanf("%d", &T);
    while(T--) solve();
    return 0;
}
/*

*/
