#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 5, N = 105, inf = 1e9;
int n, m, num, S, T, Map[N][N];
int read() {
  int x = 0, y = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') y = (ch == '-') ? -1 : 1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * y;
}
int tot = 1, first[M];
struct Edge {
  int nxt, to, w, c;
} e[M << 1];
void add(int x, int y, int w, int c) {
  e[++tot] = (Edge){first[x], y, w, c};
  first[x] = tot;
}
void addedge(int x, int y, int w, int c) { add(x, y, w, c), add(y, x, 0, -c); }
queue<int> Q;
int dis[M], pre[M], minn[M];
bool vis[M];
bool spfa() {
  while (!Q.empty()) Q.pop();
  for (int i = 0; i <= num; i++) dis[i] = inf, vis[i] = 0;
  Q.push(S), dis[S] = 0, minn[S] = inf, vis[S] = 1;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    vis[u] = 0;
    for (int i = first[u]; i; i = e[i].nxt) {
      int v = e[i].to, w = e[i].w, c = e[i].c;
      if (w && dis[v] > dis[u] + c) {
        pre[v] = i;
        dis[v] = dis[u] + c;
        minn[v] = min(minn[u], w);
        if (!vis[v]) vis[v] = 1, Q.push(v);
      }
    }
  }
  return dis[T] < inf;
}
void EK() {
  while (spfa()) {
    int u = T;
    while (u != S) {
      int i = pre[u];
      e[i].w -= minn[T], e[i ^ 1].w += minn[T];
      u = e[i ^ 1].to;
    }
  }
}
void solve() {
  n = read(), m = read();
  S = 0, T = 1, num = n + 1;
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    Map[x][y] = 1, Map[y][x] = -1;
    addedge(S, x + 1, 1, 0);
  }
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (Map[i][j] == 0)
        Map[i][j] = Map[j][i] = ++num, addedge(S, num, 1, 0),
        addedge(num, i + 1, 1, 0), addedge(num, j + 1, 1, 0);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) addedge(i + 1, T, 1, -j);
  EK();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j)
        printf("0");
      else {
        int x = Map[i][j], flag = 0;
        if (x == 1)
          printf("1");
        else if (x == -1)
          printf("0");
        else {
          for (int k = first[x]; k; k = e[k].nxt) {
            int v = e[k].to;
            if (v == i + 1 && !e[k].w) flag = 1;
          }
          printf("%d", flag);
        }
      }
    }
    printf("\n");
  }
}
signed main() { solve(); }
