#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  vector<vector<int>> g(n, vector<int>(n, -1));
  vector<int> deg(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u][v] = 1;
    g[v][u] = 0;
    deg[u]++;
  }
  vector<vector<int>> edges(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++)
      if (g[i][j] == -1) {
        edges[i].push_back(j);
        edges[j].push_back(i);
        g[i][j] = 0;
        g[j][i] = 1;
        deg[j]++;
      }
    g[i][i] = 0;
  }
  while (true) {
    vector<int> cur;
    vector<int> was(n);
    function<bool(int, int)> dfs = [&](int u, int cs) {
      was[u] = 1;
      cur.push_back(u);
      if (deg[u] < cs - 1) return true;
      for (int v : edges[u]) {
        if (!g[u][v] || was[v]) continue;
        assert(g[u][v]);
        if (dfs(v, cs)) return true;
      }
      cur.pop_back();
      return false;
    };
    auto solve = [&](int v) {
      fill(was.begin(), was.end(), 0);
      cur.clear();
      return dfs(v, deg[v]);
    };
    bool change = false;
    for (int i = 0; i < n; i++) {
      if (solve(i)) {
        change = true;
        for (int j = 0; j < (int)cur.size() - 1; j++) {
          int u = cur[j], v = cur[j + 1];
          assert(g[u][v]);
          g[u][v] ^= 1;
          g[v][u] ^= 1;
          deg[u]--;
          deg[v]++;
        }
      }
    }
    if (!change) break;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) cout << g[i][j];
    cout << endl;
  }
  return 0;
}
