#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const int MOD = 998244353;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return (c>r||c<0) ? 0:fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

int dist[400][400];
int n, m;
vector<int> v[400];
int p[400];

int find(int a) {
    if (p[a] == -1) return a;
    return p[a] = find(p[a]);
}

void merge(int a, int b) {
    a = find(a); b = find(b);
    if (a == b) return;
    p[b] = a;
}

void bfs(int st, int di[]) {
    queue<int> q;
    memset(di, -1, sizeof(dist[0]));
    di[st] = 0;
    q.push(st);

    while (!q.empty()) {
        int tv = q.front();
        q.pop();

        for (int i : v[tv]) {
            if (di[i] == -1) {
                q.push(i);
                di[i] = di[tv] + 1;
            }
        }
    }
}

int main() {
    scanf("%d %d", &n, &m);

    for (int i = 0; i < m; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    for (int i = 0; i < n; i++) bfs(i, dist[i]);

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            memset(p, -1, sizeof(p));
            ll ret = 1;
            merge(i, j);

            int cc = i != j;

            for (int k = 0; k < n; k++)
                if (k != i && k != j && dist[i][k] + dist[k][j] == dist[i][j]) {
                    merge(k, i);
                    cc++;
                }

            // printf("\n%d %d : %d / %d\n", i, j, dist[i][j], cc);
            if (cc != dist[i][j]) {
                printf("0 ");
                continue;
            }

            for (int k = 0; k < n; k++) {
                ll cnt = 0;
                if (find(i) == find(k)) continue;
                for (int l : v[k]) {
                    if (dist[i][k] == dist[i][l] + 1 && dist[j][k] == dist[j][l] + 1)
                        cnt++;
                }
                ret = ret * cnt % MOD;
            }

            printf("%lld ", ret);
        }
        printf("\n");
    }
}

// author: rdd6584