#include<bits/stdc++.h>

#define ce(i, r) i==r?'\n':' '
using namespace std;
const int N = 405, M = 605, MOD = 998244353;
int head[N], ver[M << 1], Next[M << 1], tot;
int d[N][N], cnt[N][N], n, m;
queue<int> q;

inline void add(int x, int y) {
    ver[++tot] = y;
    Next[tot] = head[x];
    head[x] = tot;
}


inline void bfs(int s) {
    memset(d[s], 0x3f, sizeof(int) * (n + 1));
    d[s][s] = 0, cnt[s][s] = 1, q.push(s);
    while (!q.empty()) {
        int x = q.front();
        q.pop();
        for (int i = head[x], y; i; i = Next[i]) {
            y = ver[i];
            if (d[s][y] > d[s][x] + 1) {
                d[s][y] = d[s][x] + 1;
                cnt[s][y] = cnt[s][x];
                q.push(y);
            } else if (d[s][y] == d[s][x] + 1)
                cnt[s][y] += cnt[s][x];
        }
    }
}


inline int calc(int x, int y) {
    int res = 1;
    for (int u = 1, t, v; u <= n; u++) {
        if (d[x][u] + d[u][y] == d[x][y])continue;
        t = 0;
        for (int i = head[u]; i; i = Next[i]) {
            v = ver[i];
            if (d[x][v] + 1 == d[x][u] && d[y][v] + 1 == d[y][u])
                t++;
        }
        res = (1ll * res * t) % MOD;
    }
    return res;
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1, x, y; i <= m; i++) {
        scanf("%d%d", &x, &y);
        add(x, y), add(y, x);
    }
    for (int x = 1; x <= n; x++)bfs(x);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            printf("%d%c", cnt[i][j] > 1 ? 0 : calc(i, j), ce(j, n));
    return 0;
}