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).
#include <bits/stdc++.h>
#pragma GCC optimize("-O3")
using namespace std;
long long MOD = 998244353;
long long mpow(long long a, long long b) {
  if (b >= (MOD - 1)) b %= (MOD - 1);
  if (b == 0) return 1;
  long long t1 = mpow(a, b / 2);
  t1 *= t1;
  t1 %= MOD;
  if (b % 2) t1 *= a;
  t1 %= MOD;
  return t1;
}
long long mpow(long long a, long long b, long long p) {
  if (b == 0) return 1;
  long long t1 = mpow(a, b / 2, p);
  t1 *= t1;
  t1 %= p;
  if (b % 2) t1 *= a;
  t1 %= p;
  return t1;
}
long long modinverse(long long a, long long m) {
  long long m0 = m;
  long long y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long q = a / m;
    long long t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
long long range(long long l, long long r) { return l + rand() % (r - l + 1); }
const int INF = 2e9 + 5;
struct graph {
  typedef int flow_type;
  typedef int cost_type;
  struct edge {
    int src, dst;
    flow_type capacity, flow;
    cost_type cost;
    size_t rev;
  };
  vector<edge> edges;
  void add_edge(int src, int dst, flow_type cap, cost_type cost) {
    adj[src].push_back({src, dst, cap, 0, cost, adj[dst].size()});
    adj[dst].push_back({dst, src, 0, 0, -cost, adj[src].size() - 1});
  }
  int n;
  vector<vector<edge>> adj;
  graph(int n) : n(n), adj(n) {}
  pair<flow_type, cost_type> min_cost_max_flow(int s, int t) {
    flow_type flow = 0;
    cost_type cost = 0;
    for (int u = 0; u < n; ++u)
      for (auto &e : adj[u]) e.flow = 0;
    vector<cost_type> p(n, 0);
    auto rcost = [&](edge e) { return e.cost + p[e.src] - p[e.dst]; };
    for (int iter = 0;; ++iter) {
      vector<int> prev(n, -1);
      prev[s] = 0;
      vector<cost_type> dist(n, INF);
      dist[s] = 0;
      if (iter == 0) {
        vector<int> count(n);
        count[s] = 1;
        queue<int> que;
        for (que.push(s); !que.empty();) {
          int u = que.front();
          que.pop();
          count[u] = -count[u];
          for (auto &e : adj[u]) {
            if (e.capacity > e.flow && dist[e.dst] > dist[e.src] + rcost(e)) {
              dist[e.dst] = dist[e.src] + rcost(e);
              prev[e.dst] = e.rev;
              if (count[e.dst] <= 0) {
                count[e.dst] = -count[e.dst] + 1;
                que.push(e.dst);
              }
            }
          }
        }
        for (int i = 0; i < n; i++) p[i] = dist[i];
        continue;
      } else {
        priority_queue<pair<cost_type, int>, vector<pair<cost_type, int>>,
                       greater<pair<cost_type, int>>>
            que;
        que.push({0, s});
        while (!que.empty()) {
          pair<cost_type, int> a = que.top();
          que.pop();
          if (a.second == t) break;
          if (dist[a.second] > a.first) continue;
          for (auto e : adj[a.second]) {
            if (e.capacity > e.flow && dist[e.dst] > a.first + rcost(e)) {
              dist[e.dst] = dist[e.src] + rcost(e);
              prev[e.dst] = e.rev;
              que.push({dist[e.dst], e.dst});
            }
          }
        }
      }
      if (prev[t] == -1) break;
      for (int u = 0; u < n; ++u)
        if (dist[u] < dist[t]) p[u] += dist[u] - dist[t];
      function<flow_type(int, flow_type)> augment = [&](int u, flow_type cur) {
        if (u == s) return cur;
        edge &r = adj[u][prev[u]], &e = adj[r.dst][r.rev];
        flow_type f = augment(e.src, min(e.capacity - e.flow, cur));
        e.flow += f;
        r.flow -= f;
        return f;
      };
      flow_type f = augment(t, INF);
      flow += f;
      cost += f * (p[t] - p[s]);
    }
    return {flow, cost};
  }
};
void solve() {
  int n, m;
  cin >> n >> m;
  vector<string> out(n, string(n, '0'));
  vector<long long> deg(n, 0);
  int x, y;
  for (long long i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    out[x][y] = '1';
    deg[x]++;
  }
  long long r = n * (n - 1) / 2 - m;
  graph mat(n + r + 2);
  long long curr = n;
  vector<pair<long long, long long>> mts;
  for (long long i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (out[i][j] != '1' && out[j][i] != '1') {
        mat.add_edge(i, curr, 1, 0);
        mat.add_edge(j, curr, 1, 0);
        curr++;
        mts.push_back(make_pair(i, j));
      }
    }
  }
  for (long long i = 0; i < r; i++) {
    mat.add_edge(n + i, n + r + 1, 1, 0);
  }
  for (long long i = 0; i < n; i++) {
    for (int j = deg[i]; j < n - 1; j++) {
      mat.add_edge(n + r, i, 1, j);
    }
  }
  pair<long long, long long> ans = mat.min_cost_max_flow(n + r, n + r + 1);
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < mat.adj[i].size(); j++) {
      if (mat.adj[i][j].flow == 1 && mat.adj[i][j].dst >= n) {
        pair<long long, long long> tp = mts[mat.adj[i][j].dst - n];
        long long b = (tp.first != i) ? tp.first : tp.second;
        out[i][b] = '1';
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    cout << out[i] << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  for (long long i = 0; i < t; i++) {
    solve();
  }
  return 0;
}
