// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast,unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")

#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <complex>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
#include <iomanip>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

// typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define emb emplace_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uint unsigned int
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <typename T> inline T range(T l, T r) {
    return uniform_int_distribution<T>(l, r)(rng);
}

template <typename T> void Min(T &a, T b) {
    a = min(a, b);
}

template <typename T> void Max(T &a, T b) {
    a = max(a, b);
}

const ll INF = 2e18;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const int N = 5e2 + 15;
int n, m, d[N][N];
int ans;
vector <int> g[N];

inline int add(int a, int b) {
	a += b;
	return a >= mod ? a - mod : a;
}

inline void add_t(int &a, int b) {
	a = add(a, b);
}

inline int mul(int a, int b) {
	return 1LL * a * b % mod;
}

int main() {
	memset(d, 0x3f, sizeof(d));
	for(int i = 0; i < N; ++i)
		d[i][i] = 0;
	ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	// freopen("input.txt", "r", stdin);
	cin >> n >> m;
	for(int i = 1; i <= m; ++i) {
		int a, b;
		cin >> a >> b;
		d[a][b] = d[b][a] = 1;
		g[a].pb(b);
		g[b].pb(a);
	}
	for(int k = 1; k <= n; ++k)
		for(int i = 1; i <= n; ++i)
			for(int j = 1; j <= n; ++j)
				Min(d[i][j], d[i][k] + d[k][j]);
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) {
			int cnt = 0;
			for(int k = 1; k <= n; ++k)
				cnt += d[i][k] + d[k][j] == d[i][j];
			if(cnt != d[i][j] + 1) {
				cout << 0 << ' ';
				continue;
			}
			int cur = 1;
			for(int k = 1; k <= n; ++k) {
				int val = 0;
				for(int to : g[k])
					if(d[i][k] - 1 == d[i][to] && d[j][k] - 1 == d[j][to])
						++val;
				if(d[i][k] + d[k][j] != d[i][j])
					cur = mul(cur, val);
			}
			cout << cur << ' ';
		}
		cout << endl;
	}
    return 0;
}	