Problem: A football league has recently begun in Beautiful land. There are n teams participating in the league. Let's enumerate them with integers from 1 to n.

There will be played exactly (n(n-1))/(2) matches: each team will play against all other teams exactly once. In each match, there is always a winner and loser and there is no draw.

After all matches are played, the organizers will count the number of beautiful triples. Let's call a triple of three teams (A, B, C) beautiful if a team A win against a team B, a team B win against a team C and a team C win against a team A. We look only to a triples of different teams and the order of teams in the triple is important.

The beauty of the league is the number of beautiful triples.

At the moment, m matches were played and their results are known.

What is the maximum beauty of the league that can be, after playing all remaining matches? Also find a possible results for all remaining (n(n-1))/(2) - m matches, so that the league has this maximum beauty.

Input

The first line contains two integers n, m (3 ≤ n ≤ 50, 0 ≤ m ≤ (n(n-1))/(2)) — the number of teams in the football league and the number of matches that were played.

Each of m following lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) denoting that the u-th team won against the v-th team. It is guaranteed that each unordered pair of teams appears at most once.

Output

Print n lines, each line having a string of exactly n characters. Each character must be either 0 or 1.

Let a_{ij} be the j-th number in the i-th line. For all 1 ≤ i ≤ n it should be true, that a_{ii} = 0. For all pairs of teams i ≠ j the number a_{ij} indicates the result of the match between the i-th team and the j-th team:

  * If a_{ij} is 1, the i-th team wins against the j-th team; 
  * Otherwise the j-th team wins against the i-th team; 
  * Also, it should be true, that a_{ij} + a_{ji} = 1. 



Also note that the results of the m matches that were already played cannot be changed in your league.

The beauty of the league in the output should be maximum possible. If there are multiple possible answers with maximum beauty, you can print any of them.

Examples

Input


3 1
1 2


Output


010
001
100


Input


4 2
1 2
1 3


Output


0110
0001
0100
1010

Note

The beauty of league in the first test case is equal to 3 because there exists three beautiful triples: (1, 2, 3), (2, 3, 1), (3, 1, 2).

The beauty of league in the second test is equal to 6 because there exists six beautiful triples: (1, 2, 4), (2, 4, 1), (4, 1, 2), (2, 4, 3), (4, 3, 2), (3, 2, 4).

Solution (in CPP):

Solution:
#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 = (error + 1) / 2;
    }
    resetList();
    refine();
    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';
  }
}