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 MOD = 1e9 + 7;
const int MX = 2e5 + 5;
const long long INF = 1e18;
const long double PI = 4 * atan((long double)1);
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
namespace input {
template <class T>
void re(complex<T>& x);
template <class T1, class T2>
void re(pair<T1, T2>& p);
template <class T>
void re(vector<T>& a);
template <class T, size_t SZ>
void re(array<T, SZ>& a);
template <class T>
void re(T& x) {
  cin >> x;
}
void re(double& x) {
  string t;
  re(t);
  x = stod(t);
}
void re(long double& x) {
  string t;
  re(t);
  x = stold(t);
}
template <class T, class... Ts>
void re(T& t, Ts&... ts) {
  re(t);
  re(ts...);
}
template <class T>
void re(complex<T>& x) {
  T a, b;
  re(a, b);
  x = cd(a, b);
}
template <class T1, class T2>
void re(pair<T1, T2>& p) {
  re(p.first, p.second);
}
template <class T>
void re(vector<T>& a) {
  for (int i = (0); i < ((int)a.size()); ++i) re(a[i]);
}
template <class T, size_t SZ>
void re(array<T, SZ>& a) {
  for (int i = (0); i < (SZ); ++i) re(a[i]);
}
}  // namespace input
using namespace input;
namespace output {
void pr(int x) { cout << x; }
void pr(long x) { cout << x; }
void pr(long long x) { cout << x; }
void pr(unsigned x) { cout << x; }
void pr(unsigned long x) { cout << x; }
void pr(unsigned long long x) { cout << x; }
void pr(float x) { cout << x; }
void pr(double x) { cout << x; }
void pr(long double x) { cout << x; }
void pr(char x) { cout << x; }
void pr(const char* x) { cout << x; }
void pr(const string& x) { cout << x; }
void pr(bool x) { pr(x ? "true" : "false"); }
template <class T>
void pr(const complex<T>& x) {
  cout << x;
}
template <class T1, class T2>
void pr(const pair<T1, T2>& x);
template <class T>
void pr(const T& x);
template <class T, class... Ts>
void pr(const T& t, const Ts&... ts) {
  pr(t);
  pr(ts...);
}
template <class T1, class T2>
void pr(const pair<T1, T2>& x) {
  pr("{", x.first, ", ", x.second, "}");
}
template <class T>
void pr(const T& x) {
  pr("{");
  bool fst = 1;
  for (const auto& a : x) pr(!fst ? ", " : "", a), fst = 0;
  pr("}");
}
void ps() { pr("\n"); }
template <class T, class... Ts>
void ps(const T& t, const Ts&... ts) {
  pr(t);
  if (sizeof...(ts)) pr(" ");
  ps(ts...);
}
void pc() { pr("]\n"); }
template <class T, class... Ts>
void pc(const T& t, const Ts&... ts) {
  pr(t);
  if (sizeof...(ts)) pr(", ");
  pc(ts...);
}
}  // namespace output
using namespace output;
namespace io {
void setIn(string second) { freopen(second.c_str(), "r", stdin); }
void setOut(string second) { freopen(second.c_str(), "w", stdout); }
void setIO(string second = "") {
  cin.sync_with_stdio(0);
  cin.tie(0);
  if ((int)second.size()) {
    setIn(second + ".in"), setOut(second + ".out");
  }
}
}  // namespace io
using namespace io;
typedef decay<decltype(MOD)>::type T;
struct mi {
  T val;
  explicit operator T() const { return val; }
  mi() { val = 0; }
  mi(const long long& v) {
    val = (-MOD <= v && v <= MOD) ? v : v % MOD;
    if (val < 0) val += MOD;
  }
  friend void pr(const mi& a) { pr(a.val); }
  friend void re(mi& a) {
    long long x;
    re(x);
    a = mi(x);
  }
  friend bool operator==(const mi& a, const mi& b) { return a.val == b.val; }
  friend bool operator!=(const mi& a, const mi& b) { return !(a == b); }
  friend bool operator<(const mi& a, const mi& b) { return a.val < b.val; }
  mi operator-() const { return mi(-val); }
  mi& operator+=(const mi& m) {
    if ((val += m.val) >= MOD) val -= MOD;
    return *this;
  }
  mi& operator-=(const mi& m) {
    if ((val -= m.val) < 0) val += MOD;
    return *this;
  }
  mi& operator*=(const mi& m) {
    val = (long long)val * m.val % MOD;
    return *this;
  }
  friend mi pow(mi a, long long p) {
    mi ans = 1;
    assert(p >= 0);
    for (; p; p /= 2, a *= a)
      if (p & 1) ans *= a;
    return ans;
  }
  friend mi inv(const mi& a) {
    assert(a != 0);
    return pow(a, MOD - 2);
  }
  mi& operator/=(const mi& m) { return (*this) *= inv(m); }
  friend mi operator+(mi a, const mi& b) { return a += b; }
  friend mi operator-(mi a, const mi& b) { return a -= b; }
  friend mi operator*(mi a, const mi& b) { return a *= b; }
  friend mi operator/(mi a, const mi& b) { return a /= b; }
};
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 {
  struct Edge {
    int to, rev;
    long long flow, cap;
    long long cost;
  };
  vector<Edge> adj[SZ];
  void ae(int u, int v, long long cap, long long 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, second, t;
  pair<int, int> pre[SZ];
  pair<long long, long long> cost[SZ];
  long long totCost, curCost;
  long long totFlow;
  bool spfa() {
    for (int i = (0); i < (N); ++i)
      cost[i] = {numeric_limits<long long>::max(), 0};
    cost[second] = {0, numeric_limits<long long>::max()};
    pqg<pair<long long, int>> todo;
    todo.push({0, second});
    while ((int)todo.size()) {
      auto x = poll(todo);
      if (x.first > cost[x.second].first) continue;
      for (auto& a : adj[x.second])
        if (a.flow < a.cap && ckmin(cost[a.to].first, x.first + a.cost)) {
          pre[a.to] = {x.second, a.rev};
          cost[a.to].second = min(a.cap - a.flow, cost[x.second].second);
          todo.push({cost[a.to].first, a.to});
        }
    }
    return cost[t].second;
  }
  void backtrack() {
    long long df = cost[t].second;
    totFlow += df;
    curCost += cost[t].first;
    totCost += curCost * df;
    for (int x = t; x != second; x = pre[x].first) {
      adj[x][pre[x].second].flow -= df;
      adj[pre[x].first][adj[x][pre[x].second].rev].flow += df;
    }
    for (int i = (0); i < (N); ++i)
      for (auto& p : adj[i]) p.cost += cost[i].first - cost[p.to].first;
  }
  pair<long long, long long> calc(int _N, int _s, int _t) {
    N = _N;
    second = _s, t = _t;
    totFlow = totCost = curCost = 0;
    while (spfa()) backtrack();
    return {totFlow, totCost};
  }
};
MCMF<1500> M;
int n, m, win[51];
int res[51][51];
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  re(n, m);
  for (int i = (1); i < (n + 1); ++i)
    for (int j = (1); j < (n + 1); ++j) {
      if (i == j)
        res[i][j] = 0;
      else
        res[i][j] = -1;
    }
  for (int i = (0); i < (m); ++i) {
    int u, v;
    re(u, v);
    win[u]++;
    res[u][v] = 1, res[v][u] = 0;
  }
  for (int i = (1); i < (n + 1); ++i) {
    for (int j = (win[i]); j < (n); ++j) M.ae(i, 0, 1, j);
  }
  int cnt = n + 1, num = 0;
  for (int i = (1); i < (n + 1); ++i)
    for (int j = (i + 1); j < (n + 1); ++j)
      if (res[i][j] == -1) {
        cnt++;
        M.ae(cnt, i, 1, 0);
        M.ae(cnt, j, 1, 0);
        M.ae(n + 1, cnt, 1, 0);
        num++;
      }
  auto z = M.calc(cnt + 1, n + 1, 0);
  cnt = n + 1;
  for (int i = (1); i < (n + 1); ++i)
    for (int j = (i + 1); j < (n + 1); ++j)
      if (res[i][j] == -1) {
        cnt++;
        int up = 0;
        for (auto& t : M.adj[cnt])
          if (t.flow > 0) {
            int label = t.to;
            assert(label == i || label == j);
            res[label][i + j - label] = 1;
            res[i + j - label][label] = 0;
            up++;
          }
      }
  for (int i = (1); i < (n + 1); ++i) {
    for (int j = (1); j < (n + 1); ++j) pr(res[i][j]);
    ps();
  }
}