#include <bits/stdc++.h>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template <typename T>
void read(T &);
template <typename T>
void write(const T &);

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;

const int N = 405;
const int M = 605;
const int Mod = 998244353;

void bfs(int S);
int work(int u, int v);

std::vector<int> G[N];
int cnt[N][N], dis[N][N];
int n, m;

int main() {
  read(n), read(m);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    read(u), read(v);
    G[u].push_back(v), G[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) bfs(i);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (cnt[i][j] == 2) {
        write(0), SP;
        continue;
      }
      write(work(i, j)), SP;
    }
    EL;
  }
  return 0;
}

void bfs(int S) {
  for (int i = 1; i <= n; ++i) dis[S][i] = n + 1;
  dis[S][S] = 0;
  cnt[S][S] = 1;
  std::queue<int> q;
  q.push(S);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v : G[u]) {
      if (dis[S][u] + 1 < dis[S][v]) {
        dis[S][v] = dis[S][u] + 1;
        cnt[S][v] = cnt[S][u];
        q.push(v);
      } else if (dis[S][u] + 1 == dis[S][v]) {
        cnt[S][v] += cnt[S][u];
        cnt[S][v] = std::min(cnt[S][v], 2);
      }
    }
  }
}
int work(int u, int v) {
  int ans = 1;
  for (int i = 1; i <= n; ++i) {
    if (dis[u][i] + dis[i][v] == dis[u][v]) continue;
    int now = 0;
    for (int j : G[i]) {
      if (dis[u][j] + 1 == dis[u][i] && dis[v][j] + 1 == dis[v][i]) ++now;
    }
    ans = 1ll * ans * now % Mod;
  }
  return ans;
}

template <typename T>
void read(T &Re) {
  T k = 0;
  char ch = getchar();
  int flag = 1;
  while (!isNum(ch)) {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (isNum(ch)) k = (k << 1) + (k << 3) + ch - '0', ch = getchar();
  Re = flag * k;
}
template <typename T>
void write(const T &Wr) {
  if (Wr < 0) {
    putchar('-'), write(-Wr);
  } else {
    if (Wr < 10) {
      putchar(Wr + '0');
    } else {
      write(Wr / 10), putchar((Wr % 10) + '0');
    }
  }
}
