#include <bits/stdc++.h>

using namespace std;

#ifdef NeverBeRed
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second



int main()
{
	#ifdef TurnRed
		freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, m;
	cin >> n >> m;
	vector<vector<int>> d(n, vector<int>(n, 1e9)), adj(n);
	for (int i = 0; i < n; ++i) d[i][i] = 0;

	for (int u, v; m--; )
	{
		cin >> u >> v;
		--u, --v;
		d[u][v] = d[v][u] = 1;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	for (int k = 0; k < n; ++k)
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

	const int mod = 998244353;
	for (int x = 0; x < n; ++x)
		for (int y = 0; y < n; ++y)
		{
			int ans = 1;
			vector<int> mark(n);
			for (int i = 0; i < n; ++i)
				if (d[x][i] + d[i][y] == d[x][y])
				{
					if (mark[d[x][i]])
					{
						ans = 0;
						break;
					}
					mark[d[x][i]] = 1;
				}


			if (ans)
			for (int i = 0; i < n; ++i)
				if (d[x][i] + d[i][y] > d[x][y])
				{
					int c = 0;
					for (auto j : adj[i])
						c += d[j][x] + 1 == d[i][x] && d[j][y] + 1 == d[i][y];
					ans = (ll)ans * c % mod;
				}
			cout << ans << " \n"[y+1==n];
		}

	return 0;
}
