#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int from, to, capacity, cost, compete;
};
vector<vector<int>> adj, cost, capacity;
const int INF = 1e9;
void shortest_paths(int n, int v0, vector<int>& d, vector<int>& p) {
  d.assign(n, INF);
  d[v0] = 0;
  vector<bool> inq(n, false);
  queue<int> q;
  q.push(v0);
  p.assign(n, -1);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    inq[u] = false;
    for (int v : adj[u]) {
      if (capacity[u][v] > 0 && d[v] > d[u] + cost[u][v]) {
        d[v] = d[u] + cost[u][v];
        p[v] = u;
        if (!inq[v]) {
          inq[v] = true;
          q.push(v);
        }
      }
    }
  }
}
int min_cost_flow(int N, vector<Edge> edges, int K, int s, int t) {
  adj.assign(N, vector<int>());
  cost.assign(N, vector<int>(N, 0));
  capacity.assign(N, vector<int>(N, 0));
  for (Edge e : edges) {
    adj[e.from].push_back(e.to);
    adj[e.to].push_back(e.from);
    cost[e.from][e.to] = e.cost;
    cost[e.to][e.from] = -e.cost;
    capacity[e.from][e.to] = e.capacity;
  }
  int flow = 0;
  int cost = 0;
  vector<int> d, p;
  while (flow < K) {
    shortest_paths(N, s, d, p);
    if (d[t] == INF) break;
    int f = K - flow;
    int cur = t;
    while (cur != s) {
      f = min(f, capacity[p[cur]][cur]);
      cur = p[cur];
    }
    flow += f;
    cost += f * d[t];
    cur = t;
    while (cur != s) {
      capacity[p[cur]][cur] -= f;
      capacity[cur][p[cur]] += f;
      cur = p[cur];
    }
  }
  if (flow < K)
    return -1;
  else
    return cost;
}
int main() {
  int nw[55], w[55];
  int g[55][55];
  int s = 0, t = 3002;
  char ch[55][55];
  int n, m;
  cin >> n >> m;
  vector<Edge> edges;
  memset(w, 0, sizeof(w));
  memset(nw, 0, sizeof(nw));
  memset(g, 0, sizeof(g));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) ch[i][j] = '0';
  }
  int u, v;
  for (int i = 1; i <= m; i++) {
    cin >> u >> v;
    w[u]++;
    g[u][v] = 1;
    ch[u][v] = '1', ch[v][u] = '0';
    g[v][u] = 1;
  }
  int mnode = n + 1;
  int K = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (j != i && g[j][i] == 0 && g[i][j] == 0) {
        Edge ed, ed2, ed3;
        ed.from = s, ed.to = mnode, ed.cost = 0, ed.capacity = 1,
        ed.compete = -1;
        edges.push_back(ed);
        ed2.from = mnode, ed2.to = i, ed2.cost = 0, ed2.capacity = 1,
        ed2.compete = j;
        ed3.from = mnode, ed3.to = j, ed3.cost = 0, ed3.capacity = 1,
        ed3.compete = i;
        edges.push_back(ed2), edges.push_back(ed3);
        nw[i]++, nw[j]++;
        g[j][i] = 1;
        g[i][j] = 1;
        mnode++;
        K++;
      }
    }
  }
  int cnt = mnode;
  for (int i = 1; i <= n; i++) {
    cnt += nw[i];
  }
  t = cnt;
  for (int i = 1; i <= n; i++) {
    int val = 1;
    for (int j = 1; j <= nw[i]; j++) {
      Edge ed;
      ed.from = i, ed.to = mnode, ed.capacity = 1, ed.cost = 2 * w[i] + val,
      ed.compete = -1;
      Edge ed2;
      ed2.from = mnode, ed2.to = t, ed2.capacity = 1, ed2.cost = 0,
      ed2.compete = -1;
      edges.push_back(ed);
      edges.push_back(ed2);
      mnode++;
      val = val + 2;
    }
  }
  int sum = min_cost_flow(t + 5, edges, K, s, t);
  for (auto ed : edges) {
    int x = ed.from, y = ed.to, z = ed.compete;
    if (y >= 1 && y <= n && z >= 1 && z <= n) {
      if (capacity[x][y] == 0)
        ch[y][z] = '1';
      else
        ch[y][z] = '0';
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) cout << ch[i][j];
    cout << endl;
  }
  return 0;
}
