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

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;
 
#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define EACH(it, a) for(auto it = (a).begin(); it != (a).end(); ++it)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define MP make_pair

#define MOD 998244353

VInt E[1 << 9];
int D[1 << 9][1 << 9];
Int R[1 << 9][1 << 9];

Int f(int a, int b, int n)
{
    int i, j, k;
    Int res = 1;
    FOR(i, 0, n)
    {
        if(D[i][a] + D[i][b] > D[a][b])
        {
            int cnt = 0;
            for(int x : E[i])
                if(D[x][a] + 1 == D[i][a] && D[x][b] + 1 == D[i][b])
                    ++cnt;

            if(cnt == 0) return 0;
            res = (res * cnt) % MOD;
            continue;
        }

        int cnta = 0, cntb = 0;
        for(int x : E[i])
        {
            if(D[x][a] + 1 == D[i][a]) ++cnta;
            if(D[x][b] + 1 == D[i][b]) ++cntb;
        }

        if(cnta > 1 || cntb > 1) return 0;
    }

    return res;
}

void solve(int test)
{
    int n, m;
    cin >> n >> m;
    int i, j, k;
    FOR(i, 0, n)
        FOR(j, 0, n)
            D[i][j] = n;

    FOR(i, 0, n) D[i][i] = 0;
    FOR(i, 0, m)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        E[a].push_back(b);
        E[b].push_back(a);
        D[a][b] = D[b][a] = 1;
    }

    FOR(k, 0, n)
        FOR(i, 0, n)
            FOR(j, 0, n)
                D[i][j] = min(D[i][j], D[i][k] + D[k][j]);

    FOR(i, 0, n)
        FOR(j, 0, n)
            R[i][j] = f(i, j, n);

    FOR(i, 0, n)
    {
        FOR(j, 0, n) cout << R[i][j] << ' ';
        cout << endl;
    }
}

int main()
{
    int T = 1, t;
    //cin >> T;
    FOR(t, 0, T) 
    {
        //cerr << "Solving " << t << "/" << T << endl;
        solve(t);
    }
    return 0;
}
