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;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
using cost_type = long long;
const cost_type COST_INF = (int)1e18;
const int FLOW_INF = (int)1e9;
struct MinCost {
  explicit MinCost(int n) { g.resize(n); }
  struct edge {
    int from, to;
    int cap;
    cost_type cost;
    int flow;
  };
  vector<edge> edges;
  vector<vector<int>> g;
  void add_edge(int from, int to, cost_type cost, int cap) {
    edge e = {from, to, cap, cost, 0};
    g[from].push_back(edges.size());
    edges.push_back(e);
    edge e2 = {to, from, 0, -cost, 0};
    g[to].push_back(edges.size());
    edges.push_back(e2);
  }
  pair<int, cost_type> min_cost(int n, int s, int t, bool need_max_flow,
                                int max_flow_value = FLOW_INF) {
    cost_type cost = 0;
    int flow = 0;
    vector<cost_type> potential;
    {
      vector<int> p(n, -1);
      vector<cost_type> d(n);
      d[s] = 0;
      p[s] = s;
      bool changed = true;
      while (changed) {
        changed = false;
        for (size_t i = 0; i < edges.size(); ++i) {
          edge &e = edges[i];
          if (e.cap == e.flow || p[e.from] == -1) continue;
          if (p[e.to] == -1 || d[e.to] > d[e.from] + e.cost) {
            d[e.to] = d[e.from] + e.cost;
            p[e.to] = i;
            changed = true;
          }
        }
      }
      potential = std::move(d);
    }
    while (flow < max_flow_value) {
      vector<cost_type> d(n);
      vector<int> p(n, -1);
      using queue_type = pair<cost_type, int>;
      priority_queue<queue_type, vector<queue_type>, greater<queue_type>> q;
      q.push({0, s});
      while (!q.empty()) {
        int v = q.top().second;
        cost_type oldD = q.top().first;
        q.pop();
        if (oldD != d[v]) continue;
        for (int id : g[v]) {
          edge &e = edges[id];
          if (e.to == s) continue;
          if (e.cap > e.flow) {
            cost_type newd =
                d[v] + e.cost + potential[e.from] - potential[e.to];
            if (p[e.to] == -1 || d[e.to] > newd) {
              d[e.to] = newd;
              p[e.to] = id;
              q.push({d[e.to], e.to});
            }
          }
        }
      }
      if (p[t] == -1) {
        break;
      }
      if (d[t] + potential[t] >= 0 && !need_max_flow) {
        break;
      }
      int cur = t;
      int maxAdd = max_flow_value - flow;
      while (cur != s) {
        edge &e = edges[p[cur]];
        cur = e.from;
        maxAdd = min(maxAdd, e.cap - e.flow);
      }
      flow += maxAdd;
      cost += (potential[t] + d[t]) * maxAdd;
      cur = t;
      while (cur != s) {
        int id = p[cur];
        edges[id].flow += maxAdd;
        edges[id ^ 1].flow -= maxAdd;
        cur = edges[id].from;
      }
      for (int i = 0; i < n; ++i) {
        if (i != s && p[i] == -1) {
          potential[i] = COST_INF;
        } else
          potential[i] = min(potential[i] + d[i], COST_INF);
      }
    }
    return make_pair(flow, cost);
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(n, -1));
  for (int i = 0; i < (int)(m); ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    a[x][y] = 1;
    a[y][x] = 0;
  }
  int S = 0, T = 1;
  int off0 = 2, off1 = off0 + n * (n - 1) / 2, off2 = off1 + n;
  auto mc = MinCost(off2);
  int p = off0;
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(i); ++j) {
      mc.add_edge(S, p, 0, 1);
      if (a[i][j] != 1) mc.add_edge(p, off1 + i, 0, 1);
      if (a[i][j] != 0) mc.add_edge(p, off1 + j, 0, 1);
      ++p;
    }
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(n); ++j) mc.add_edge(off1 + i, T, j, 1);
  auto w = mc.min_cost(off2, S, T, 1);
  cerr << w.first << ' ' << n * (n - 1) * (n - 2) / 6 - w.second << '\n';
  vector<vector<int>> res(n, vector<int>(n));
  p = off0;
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(i); ++j) {
      for (int e : mc.g[p]) {
        auto w = mc.edges[e];
        if (w.flow) {
          int x = w.to - off1;
          if (x < 0 || x >= n) continue;
          int y = i ^ j ^ x;
          res[y][x] = 1;
          break;
        }
      }
      ++p;
    }
  for (int i = 0; i < (int)(n); ++i) {
    for (int j = 0; j < (int)(n); ++j) {
      if (a[i][j] == 1) assert(res[i][j] == 1);
      cout << res[i][j];
    }
    cout << '\n';
  }
  return 0;
}