#include <bits/stdc++.h>
#define i64 long long
#define sz(a) int ((a).size())
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define per(i, a, b) for (int i = (b) - 1; i >= (a); --i)
using namespace std;
const int inf32 = 0x3f3f3f3f;
const i64 inf64 = 0x3f3f3f3f3f3f3f3f;

const int M = 998244353;

struct mint {
	int x;
	mint (int x = 0) : x(x) {}
	friend mint operator +
	(const mint a, const mint &b) {
		int x = a.x + b.x;
		return mint (x >= M ? x - M : x);
	}
	friend mint operator - 
	(const mint a, const mint &b) {
		int x = a.x - b.x;
		return mint (x < 0 ? x + M : x);
	}
	friend mint operator *
	(const mint a, const mint &b) {
		return mint (1ll * a.x * b.x % M);
	}
};

int Pw(int a, int x = M - 2, int res = 1) {
	for (; x; x >>= 1, a = (mint (a) * a).x)
		if (x & 1) res = (mint (res) * a).x;
	return res;
}

const int N = 400;
int n, m, d[N][N];
bool b[N];
vector<int> f[N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	rep(u, 0, n) {
		rep(v, 0, n) {
			if (u == v) {
				d[u][v] = 0;
			} else {
				d[u][v] = n;
			}
		}
	}
	rep(i, 0, m) {
		int u, v;
		cin >> u >> v, --u, --v;
		d[u][v] = d[v][u] = 1;
	}	
	rep(w, 0, n) {
		rep(u, 0, n) {
			rep(v, 0, n) {
				d[u][v] = min(d[u][v], d[u][w] + d[w][v]);
			}
		}
	}
	rep(u, 0, n) {
		rep(v, 0, n) {
			f[v].clear();
		}
		rep(v, 0, n) {
			rep(w, 0, n) if (d[v][w] == 1) {
				if (d[u][v] + 1 == d[u][w]) {
					f[w].push_back(v);
				}
			}
		}
		rep(v, 0, n) {
			rep(w, 0, n) {
				b[w] = false;
			}
			bool mp = false;
			for (int w = v; ; w = f[w][0]) {
				if (sz(f[w]) > 1) {
					mp = true;
					break;
				}
				b[w] = true;
				if (w == u) break; 
			}
			if (mp) {
				cout << 0 << ' ';
			} else {
				int res = 1;
				rep(w, 0, n) if (not b[w]) {
					int cf = 0;
					for (int x : f[w]) {
						if (d[v][x] + 1 == d[v][w]) {
							cf += 1;
						}
					}
					res = (mint (res) * cf).x;
				}
				cout << res << ' ';
			}
		}
		cout << '\n';
	}
	return 0;
}

/*
	* Read Carefully! Multiple cases? Data range?
	* Transformation? Special cases? Brute & Regularities?
	* Don't get stuck! New directions! Record thoughts!
	* Int overflow? Array bounds? N = 1?
*/