#include <bits/stdc++.h>
const int MAXN = 5e5 + 5;
const int MAXM = 100 + 5;
namespace MCMF {
struct Edge {
  int fr, to, w, c, nxt;
} e[MAXN << 1];
int head[MAXN], cnt = 1;
inline void add(int u, int v, int w, int c) {
  e[++cnt] = (Edge){u, v, w, c, head[u]};
  head[u] = cnt;
  e[++cnt] = (Edge){v, u, 0, -c, head[v]};
  head[v] = cnt;
}
int dis[MAXN], pre[MAXN];
bool inq[MAXN];
int N, S, T;
inline bool spfa() {
  std::queue<int> q;
  for (int i = 0; i <= N; ++i) dis[i] = 1e9, pre[i] = -1;
  dis[S] = 0;
  pre[S] = 0;
  q.push(S);
  inq[S] = 1;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    inq[v] = 0;
    for (int i = head[v]; i; i = e[i].nxt) {
      if (e[i].w > 0 && dis[e[i].to] > dis[v] + e[i].c) {
        dis[e[i].to] = dis[v] + e[i].c;
        pre[e[i].to] = i;
        if (!inq[e[i].to]) q.push(e[i].to), inq[e[i].to] = 1;
      }
    }
  }
  return pre[T] != -1;
}
int maxFlow, minCost;
inline void work() {
  while (spfa()) {
    int flow = 1e9;
    for (int v = T; v != S; v = e[pre[v]].fr) {
      flow = std::min(flow, e[pre[v]].w);
    }
    maxFlow += flow;
    for (int v = T; v != S; v = e[pre[v]].fr) {
      minCost += flow * e[pre[v]].c;
      e[pre[v]].w -= flow;
      e[pre[v] ^ 1].w += flow;
    }
  }
}
}  // namespace MCMF
using namespace MCMF;
int n, m;
int a[MAXM][MAXM];
int bh[MAXM][MAXM];
int p[MAXN][2];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) a[i][j] = 2;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    a[u][v] = 1;
    a[v][u] = 0;
  }
  N = n;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= i - 1; ++j) {
      bh[i][j] = bh[j][i] = ++N;
    }
  }
  S = ++N;
  T = ++N;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= i - 1; ++j) {
      add(S, bh[i][j], 1, 0);
      if (a[i][j] != 0) add(bh[i][j], j, 1, 0), p[bh[i][j]][0] = cnt - 1;
      if (a[i][j] != 1) add(bh[i][j], i, 1, 0), p[bh[i][j]][1] = cnt - 1;
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j <= n - 1; ++j) add(i, T, 1, j);
  work();
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= i - 1; ++j) {
      if (a[i][j] == 2) {
        a[j][i] = !(a[i][j] = e[p[bh[i][j]][0]].w ? 0 : 1);
      }
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) {
      printf("%d", i == j ? 0 : a[i][j]);
      if (j == n) puts("");
    }
  return 0;
}
