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 N = 57;
int gr[N][N];
int add_e[N], cnt[N];
void init() {
  for (int i = 0; i < N; i++) {
    add_e[i] = 2 * i + 1;
  }
}
struct MinCostMaxFlow {
  struct Edge {
    int to, cap;
    int flow;
    int cost;
  };
  static const int MAX_V = 3003;
  static const int MAX_E = 2 * 333 * 333;
  static const int INF = 1e9 + 7;
  static const int MAX_COST = 1e9 + 7;
  int sz = 0;
  Edge e[MAX_E];
  vector<int> g[MAX_V];
  int dp[MAX_V];
  pair<int, int> prev[MAX_V];
  int phi[MAX_V];
  void addEdge(int v, int to, int cap, int cost) {
    g[v].push_back(sz);
    e[sz++] = {to, cap, 0, cost};
    g[to].push_back(sz);
    e[sz++] = {v, 0, 0, -cost};
  }
  void calcPhi(int start) {
    for (int i = 0; i < MAX_V; ++i) phi[i] = MAX_COST;
    phi[start] = 0;
    for (int k = 0; k < MAX_V; k++) {
      for (int v = 0; v < MAX_V; v++) {
        for (int to : g[v]) {
          Edge &ed = e[to];
          if (ed.cap == ed.flow) continue;
          phi[ed.to] = min(phi[ed.to], phi[v] + ed.cost);
        }
      }
    }
  }
  long long find(int start, int finish, int required_flow) {
    calcPhi(start);
    long long ans = 0;
    while (required_flow) {
      for (int i = 0; i < MAX_V; i++) dp[i] = INF, prev[i] = {-1, -1};
      dp[start] = 0;
      set<pair<int, int> > se;
      se.insert({0, start});
      while (!se.empty()) {
        auto [dist, v] = *se.begin();
        se.erase(se.begin());
        for (int to : g[v]) {
          auto ed = e[to];
          if (ed.flow < ed.cap &&
              dp[ed.to] > dp[v] + ed.cost - phi[ed.to] + phi[v]) {
            prev[ed.to] = {v, to};
            se.erase({dp[ed.to], ed.to});
            dp[ed.to] = dp[v] + ed.cost - phi[ed.to] + phi[v];
            se.insert({dp[ed.to], ed.to});
          }
        }
      }
      if (dp[finish] == INF) {
        return -1;
      }
      int max_flow = required_flow;
      int v = finish;
      while (1) {
        auto now = prev[v];
        if (now.first == -1) break;
        max_flow = min(max_flow, e[now.second].cap - e[now.second].flow);
        v = now.first;
      }
      ans += (dp[finish] + phi[finish]) * (long long)max_flow;
      v = finish;
      while (1) {
        auto now = prev[v];
        if (now.first == -1) break;
        e[now.second].flow += max_flow;
        e[now.second ^ 1].flow -= max_flow;
        v = now.first;
      }
      required_flow -= max_flow;
      int min_phi = 0;
      for (int i = 0; i < MAX_V; ++i) {
        if (dp[i] == INF) {
          min_phi = min(min_phi, phi[i]);
        } else {
          phi[i] += dp[i];
        }
      }
      for (int i = 0; i < MAX_V; ++i) {
        if (dp[i] == INF) {
          phi[i] -= min_phi;
        }
      }
    }
    return ans;
  }
} min_cost_max_flow;
int res[N][N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  init();
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int v, u;
    cin >> v >> u;
    v--, u--;
    cnt[v]++;
    gr[v][u] = 1;
    res[v][u] = 1;
  }
  int rem = n * (n - 1) / 2 - m;
  int lst = 0;
  int NN = rem + n + 2, s = NN - 1, t = NN - 2;
  vector<pair<int, int> > kek;
  for (int i = 0; i < n; i++) {
    ;
    for (int j = cnt[i]; j <= n; j++) {
      min_cost_max_flow.addEdge(i + rem, t, 1, add_e[j]);
    }
    for (int j = i + 1; j < n; j++) {
      if (gr[i][j] + gr[j][i] > 0) continue;
      min_cost_max_flow.addEdge(s, lst, 1, 0);
      min_cost_max_flow.addEdge(lst, i + rem, 1, 0);
      min_cost_max_flow.addEdge(lst++, j + rem, 1, 0);
      kek.push_back({i, j});
    }
  }
  assert(kek.size() == rem);
  min_cost_max_flow.find(s, t, rem);
  for (int i = 0; i < rem; i++) {
    for (int ed : min_cost_max_flow.g[i]) {
      auto edge = min_cost_max_flow.e[ed];
      if (edge.flow < 1) continue;
      int v = kek[i].first, u = kek[i].second;
      if (edge.to == u + rem) swap(v, u);
      res[v][u] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i != j && !res[i][j] && !res[j][i]) {
        assert(false);
      }
      cout << res[i][j];
    }
    cout << "\n";
  }
}