#include <bits/stdc++.h>
using namespace std;
struct Dinic {
  static const int MXN = 10000;
  struct Edge {
    int v, f, re;
    Edge(int a, int b, int c) : v(a), f(b), re(c) {}
  };
  int n, s, t, level[MXN];
  vector<Edge> E[MXN];
  void init(int _n, int _s, int _t) {
    n = _n;
    s = _s;
    t = _t;
    for (int i = 0; i <= n; i++) E[i].clear();
  }
  void add_edge(int u, int v, int f) {
    E[u].push_back(Edge(v, f, E[v].size()));
    E[v].push_back(Edge(u, 0, E[u].size() - 1));
  }
  bool BFS() {
    memset(level, -1, sizeof(level));
    queue<int> que;
    que.push(s);
    level[s] = 0;
    while (!que.empty()) {
      int u = que.front();
      que.pop();
      for (auto it : E[u]) {
        if (it.f > 0 && level[it.v] == -1) {
          level[it.v] = level[u] + 1;
          que.push(it.v);
        }
      }
    }
    return level[t] != -1;
  }
  int DFS(int u, int nf) {
    if (u == t) return nf;
    int res = 0;
    for (auto &it : E[u]) {
      if (it.f > 0 && level[it.v] == level[u] + 1) {
        int tf = DFS(it.v, min(nf, it.f));
        res += tf;
        nf -= tf;
        it.f -= tf;
        E[it.v][it.re].f += tf;
        if (nf == 0) return res;
      }
    }
    if (!res) level[u] = -1;
    return res;
  }
  int flow(int res = 0) {
    while (BFS()) res += DFS(s, 2147483647);
    return res;
  }
} flow;
int tot[55];
int vis[55][55];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  pair<int, int> p[3000];
  for (int i = 0; i < m; i++) {
    int first, second;
    scanf("%d %d", &first, &second);
    tot[first]++;
    vis[first][second] = vis[second][first] = 1;
    p[i] = make_pair(first, second);
  }
  int Max = n, Min = 0;
  flow.init(n + n * n + 2, 0, n + n * n + 1);
  int cnt = n + 1;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (!vis[i][j]) {
        flow.add_edge(i, cnt, 1);
        flow.add_edge(j, cnt, 1);
        flow.add_edge(cnt, n + n * n + 1, 1);
        cnt++;
      }
    }
  }
  int res = 0;
  for (int t = 1; t < n; t++) {
    for (int i = 1; i <= n; i++) {
      if (tot[i] < t) {
        flow.add_edge(0, i, 1);
      }
    }
    res = flow.flow(res);
    if (res == cnt - n - 1) {
      break;
    }
  }
  cnt = n + 1;
  int ans[55][55];
  memset(ans, 0, sizeof(ans));
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (!vis[i][j]) {
        for (auto &it : flow.E[cnt]) {
          if (it.f && (it.v == i || it.v == j)) {
            ans[it.v][i + j - it.v] = 1;
            tot[it.v]++;
          }
        }
        cnt++;
      }
    }
  }
  for (int i = 0; i < m; i++) ans[p[i].first][p[i].second] = 1;
  long long rres = n * (n - 1) * (n - 2);
  for (int i = 1; i <= n; i++) {
    rres -= tot[i] * (tot[i] - 1) / 2 * 6;
  }
  for (int i = 1; i <= n; i++, printf("\n"))
    for (int j = 1; j <= n; j++) printf("%d", ans[i][j]);
}
