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;
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 aux = *se.begin();
        int dist = aux.first, v = aux.second;
        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;
  }
} mcmf;
int sursa, dest, ans[55][55], grad[55];
pair<int, int> what[1255];
int main() {
  int n, m, x, y, nodes = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    ans[x][y] = 1;
    grad[x]++;
  }
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (ans[i][j] + ans[j][i] == 0) {
        nodes++;
        mcmf.addEdge(sursa, nodes, 1, 0);
        what[nodes] = {i, j};
      }
  for (int i = 1; i <= nodes; i++) {
    mcmf.addEdge(i, nodes + what[i].first, 1, 0);
    mcmf.addEdge(i, nodes + what[i].second, 1, 0);
  }
  dest = nodes + n + 1;
  int nr = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n - 1 - grad[i]; j++)
      mcmf.addEdge(i + nodes, dest, 1, 2 * grad[i] + 2 * j - 1);
  int flow = mcmf.find(0, nodes + n + 1, nodes);
  for (int i = 1; i <= nodes; i++) {
    x = what[i].first;
    y = what[i].second;
    if (mcmf.e[2 * nodes + (i - 1) * 4].flow == 1)
      ans[x][y] = 1;
    else
      ans[y][x] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) printf("%d", ans[i][j]);
    printf("\n");
  }
  return 0;
}