#include <bits/stdc++.h>
using namespace std;
const int MR = 55;
const int MN = 1350;
const long long INF = 1e16;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;
template <class T>
T poll(pqg<T>& x) {
  T y = x.top();
  x.pop();
  return y;
}
template <int SZ>
struct mcmf {
  const __int128 INF = 1e26;
  struct Edge {
    int to, rev;
    __int128 flow, cap;
    __int128 cost;
    int id;
  };
  vector<Edge> adj[SZ];
  void addEdge(int u, int v, __int128 cap, __int128 cost) {
    assert(cap >= 0);
    Edge a{v, int(adj[v].size()), 0, cap, cost},
        b{u, int(adj[u].size()), 0, 0, -cost};
    adj[u].push_back(a);
    adj[v].push_back(b);
  }
  int N, s, t;
  int curEdge[SZ], act_count;
  pair<__int128, __int128> cost[SZ];
  bitset<SZ> act;
  __int128 totCost, curCost, costMult, price[SZ];
  __int128 totFlow, error, excess[SZ];
  int nxt[SZ], prv[SZ], head;
  bool push(int u, int id) {
    if (excess[u] <= 0) return false;
    Edge& e = adj[u][id];
    if (e.cap - e.flow <= 0) {
      return false;
    }
    if (e.cost - price[u] + price[e.to] >= 0) {
      return false;
    }
    __int128 d = min(excess[u], e.cap - e.flow);
    e.flow += d;
    int v = e.to;
    adj[v][e.rev].flow -= d;
    totCost += e.cost * d;
    excess[u] -= d;
    excess[v] += d;
    if (excess[u] <= 0) {
      act.reset(u);
      act_count--;
    }
    if (excess[v] > 0) {
      if (!act[v]) {
        act_count++;
      }
      act.set(v);
    }
    return true;
  }
  __int128 rget(int a, int b) {
    for (int i = 0; i < adj[a].size(); i++) {
      if (adj[a][i].to == b) {
        return adj[a][i].flow;
      }
    }
    return -INF;
  }
  bool price_update(int u) {
    if (excess[u] <= 0) return false;
    __int128 nprice = INF;
    for (auto& e : adj[u]) {
      int v = e.to;
      if ((e.cap - e.flow > 0) && (e.cost - price[u] + price[v] < 0)) {
        return false;
      }
      if (e.cap - e.flow <= 0) continue;
      nprice = min(nprice, price[v] + e.cost + error);
    }
    price[u] = nprice;
    return true;
  }
  void move_front(int u) {
    if (u == head) return;
    if (prv[u] != -1) {
      nxt[prv[u]] = nxt[u];
    }
    if (nxt[u] != -1) {
      prv[nxt[u]] = prv[u];
    }
    nxt[u] = head;
    prv[head] = u;
    prv[u] = -1;
    head = u;
  }
  bool pushup(int u) {
    if (excess[u] <= 0) {
      return false;
    }
    if (!push(u, curEdge[u])) {
      if (curEdge[u] != adj[u].size() - 1) {
        curEdge[u]++;
      } else {
        curEdge[u] = 0;
        price_update(u);
      }
    }
    return true;
  }
  bool discharge(int u) {
    if (excess[u] <= 0) return false;
    __int128 cur_price = price[u];
    while (excess[u] > 0 && price[u] == cur_price) {
      pushup(u);
      if (price[u] == INF) {
        break;
      }
    }
    if (price[u] > cur_price) {
      int ret = nxt[u];
      move_front(u);
      return true;
    }
    return false;
  }
  void decycle() {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < adj[i].size(); j++) {
        int v = adj[i][j].to;
        __int128 cost_p = adj[i][j].cost - price[i] + price[v];
        __int128 rid = adj[i][j].rev;
        if (cost_p > 0) {
          __int128 mf = adj[v][rid].cap - adj[v][rid].flow;
          adj[v][rid].flow += mf;
          adj[i][j].flow -= mf;
          totCost += mf * adj[v][rid].cost;
          excess[i] += mf;
          excess[v] -= mf;
        }
        if (cost_p < 0) {
          __int128 mf = adj[i][j].cap - adj[i][j].flow;
          adj[i][j].flow += mf;
          adj[v][rid].flow -= mf;
          totCost += mf * adj[i][j].cost;
          excess[i] -= mf;
          excess[v] += mf;
        }
        if (excess[i] > 0) {
          if (!act[i]) {
            act_count++;
          }
          act.set(i);
        } else {
          if (act[i]) {
            act_count--;
          }
          act.reset(i);
        }
        if (excess[v] > 0) {
          if (!act[v]) {
            act_count++;
          }
          act.set(v);
        } else {
          if (act[v]) {
            act_count--;
          }
          act.reset(v);
        }
      }
    }
  }
  void refine() {
    decycle();
    while (1) {
      int i = head;
      while (i >= 0) {
        int nx = nxt[i];
        discharge(i);
        i = nx;
      }
      if (act_count == 0) {
        break;
      }
      bool end_inf = true;
      for (int i = 0; i < N; i++) {
        if (price[i] != INF) {
          end_inf = false;
        }
      }
      if (end_inf) {
        break;
      }
    }
  }
  void resetList() {
    head = 0;
    for (int i = 0; i < N; i++) {
      prv[i] = i - 1;
      nxt[i] = i + 1;
      curEdge[i] = 0;
    }
    nxt[N - 1] = -1;
  }
  pair<__int128, __int128> calc(int _N, int _s, int _t, int _flow) {
    N = _N;
    s = _s;
    t = _t;
    costMult = 2 * N;
    error = 0;
    memset(excess, 0, sizeof(excess));
    excess[s] = _flow;
    excess[t] = -_flow;
    act_count = 1;
    act.set(s);
    resetList();
    for (int i = 0; i < N; i++) {
      price[i] = 0;
      for (auto& u : adj[i]) {
        u.cost *= costMult;
        error = max(error, u.cost);
      }
    }
    refine();
    while (error >= 1) {
      resetList();
      refine();
      error = (3 * error) / 4;
    }
    return {_flow + excess[t], totCost / costMult};
  }
};
int res[MR][MR];
int cv[MR];
pair<int, int> hm[MN];
int main() {
  int n, m;
  cin >> n >> m;
  memset(res, -1, sizeof(res));
  memset(cv, 0, sizeof(cv));
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    res[a][b] = 1;
    res[b][a] = 0;
    cv[a]++;
  }
  mcmf<MN> bs;
  int s = MN - 2, t = MN - 1;
  for (int i = 0; i < n; i++) {
    bs.addEdge(s, n + i, n, i);
  }
  for (int i = 0; i < n; i++) {
    for (int j = cv[i]; j < n; j++) {
      bs.addEdge(n + j, i, 1, 0);
    }
  }
  int id = 2 * n;
  int fl = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (res[i][j] == -1) {
        bs.addEdge(i, id, 1, 0);
        bs.addEdge(j, id, 1, 0);
        bs.addEdge(id, t, 1, 0);
        hm[id] = {i, j};
        id++;
        fl++;
      }
    }
  }
  pair<long long, long long> rval = bs.calc(MN, s, t, fl);
  for (int i = n; i < id; i++) {
    int u = hm[i].first, v = hm[i].second;
    int val = bs.rget(i, u);
    if (val != 0) {
      res[u][v] = 1;
      res[v][u] = 0;
    } else {
      res[u][v] = 0;
      res[v][u] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    res[i][i] = 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cout << res[i][j];
    }
    cout << '\n';
  }
}
