#include <bits/stdc++.h>
using namespace std;
struct Line {
  int nxt, t, c, l;
} g[20500];
int fir[2505], tl = 1;
void adl(int f, int t, int c, int cost) {
  g[++tl] = (Line){fir[f], t, c, cost};
  fir[f] = tl;
  g[++tl] = (Line){fir[t], f, 0, -cost};
  fir[t] = tl;
}
int S, T, tn, pre[2505], lp[2505], flow[2505], dis[2505];
bool in[2505];
queue<int> q;
int spfa() {
  for (int i = 1; i <= tn; i++) {
    dis[i] = 1000000000;
    flow[i] = 0;
  }
  flow[S] = 1000000000;
  dis[S] = 0;
  q.push(S);
  in[S] = 1;
  while (!q.empty()) {
    int u = q.front();
    in[u] = 0;
    q.pop();
    for (int i = fir[u], v; i; i = g[i].nxt)
      if (g[i].c && dis[v = g[i].t] > dis[u] + g[i].l) {
        dis[v] = dis[u] + g[i].l;
        flow[v] = min(flow[u], g[i].c);
        lp[v] = i;
        pre[v] = u;
        if (!in[v]) {
          in[v] = 1;
          q.push(v);
        }
      }
  }
  return flow[T];
}
int n, m, du[105], h[105][105], pl[105][105];
int main() {
  scanf("%d%d", &n, &m);
  S = n + 1;
  tn = T = n + 2;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) h[i][j] = 2;
  for (int i = 1; i <= n; i++) h[i][i] = 0;
  for (int i = 1, u, v; i <= m; i++) {
    scanf("%d%d", &u, &v);
    h[u][v] = 1;
    h[v][u] = 0;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (j < i && h[i][j] == 2) {
        adl(S, ++tn, 1, 0);
        adl(tn, i, 1, 0);
        pl[j][i] = tl;
        adl(tn, j, 1, 0);
        pl[i][j] = tl;
      } else
        pl[i][j] = -h[i][j];
      if (h[i][j] == 1) du[j]++;
    }
  for (int i = 1; i <= n; i++)
    for (int j = du[i]; j < n; j++) adl(i, T, 1, max(j, 0));
  int sav;
  while (sav = spfa()) {
    int u = T;
    while (u != S) {
      int las = pre[u];
      g[lp[u]].c -= sav;
      g[lp[u] ^ 1].c += sav;
      u = las;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++)
      if (pl[i][j] <= 0)
        printf("%d", -pl[i][j]);
      else
        printf("%d", g[pl[i][j]].c);
    puts("");
  }
  return 0;
}
