#include <bits/stdc++.h>

#define LL long long
#define ull unsigned long long
#define F(i, j, k) for (int i = j; i <= k; ++i)
#define DF(i, j, k) for (int i = j; i >= k; --i)

using namespace std;

template <typename T> inline void read(T &n) {
    T w = 1;
    n = 0;
    char ch = getchar();
    while (!isdigit(ch) && ch != EOF) {
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (isdigit(ch) && ch != EOF) {
        n = (n << 3) + (n << 1) + (ch & 15);
        ch = getchar();
    }
    n *= w;
}

template <typename T> inline void write(T x) {
    T l = 0;
    ull y = 0;
    if (!x) { putchar(48); return; }
    if (x < 0) { x = -x; putchar('-'); }
    while (x) { y = y * 10 + x % 10; x /= 10; ++l; }
    while (l) { putchar(y % 10 + 48); y /= 10; --l; }
}

template <typename T> inline void writes(T x) {
    write(x);
    putchar(' ');
}

template <typename T> inline void writeln(T x) {
    write(x);
    puts("");
}

template <typename T> inline void checkmax(T &a, T b) { a = a > b ? a : b; }

template <typename T> inline void checkmin(T &a, T b) { a = a < b ? a : b; }

int cnt, dis[1100][1100], head[1100], nxt[1210], to[1210];

inline void addedge(int x, int y) {
    nxt[++cnt] = head[x];
    to[cnt] = y;
    head[x] = cnt;
}

int main() {
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    int n, m;
    read(n);
    read(m);
    F(i, 1, n)
        F(j, 1, n)
            if (i != j) dis[i][j] = 10000;
    F(i, 1, m) {
        int x, y;
        read(x);
        read(y);
        dis[x][y] = dis[y][x] = 1;
        addedge(x, y);
        addedge(y, x);
    }
    F(k, 1, n)
        F(i, 1, n)
            F(j, 1, n)
                checkmin(dis[i][j], dis[i][k] + dis[k][j]);
    F(i, 1, n)
        F(j, 1, n) {
            int ans = 1, num = 0;
            F(k, 1, n) {
                if (dis[i][k] + dis[j][k] == dis[i][j]) { ++num; continue; }
                int s = 0;
                for (int l = head[k]; l; l = nxt[l])
                    if (dis[i][to[l]] + 1 == dis[i][k] && dis[j][to[l]] + 1 == dis[j][k]) ++s;
                ans = (LL)s * ans % 998244353;
            }
            if (num != dis[i][j] + 1) ans = 0;
            if (j == n) writeln(ans);
            else writes(ans);
        }
    return 0;
}