#include <bits/stdc++.h>
using namespace std;
int mp[100][100];
int ori[100][100];
int ori_cnt[100];
int cnt[100], vis[100];
mt19937 rd(486);
int main() {
  auto t = clock();
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    mp[a][b] = 1;
    mp[b][a] = -1;
    cnt[a]++;
    ori[a][b] = ori[b][a] = 1;
    ori_cnt[a]++;
  }
  auto print = [&] {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (i == j)
          cout << 0;
        else
          cout << (mp[i][j] == 1);
      }
      cout << endl;
    }
  };
  for (int i = 1; i <= n; i++) {
    int maxn = -1, pos = -1;
    for (int j = 1; j <= n; j++) {
      if (!vis[j] && cnt[j] > maxn) {
        maxn = cnt[j], pos = j;
      }
    }
    vis[pos] = 1;
    int a[50];
    for (int i = 1; i <= n; i++) a[i] = i;
    random_shuffle(a + 1, a + n + 1);
    int now = maxn;
    for (int k = 1; k <= n; k++) {
      int j = a[k];
      if (pos == j || mp[pos][j]) continue;
      if (now < (n - 1) / 2) {
        mp[pos][j] = 1;
        mp[j][pos] = -1;
        now++;
        cnt[pos]++;
      } else {
        mp[pos][j] = -1;
        mp[j][pos] = 1;
        cnt[j]++;
      }
    }
  }
  auto now_time = [&] { return (clock() - t) / CLOCKS_PER_SEC; };
  while (now_time() < 0.95) {
    int now = rd() % n + 1;
    if (cnt[now] == ori_cnt[now]) continue;
    for (int i = 1; i <= n; i++) {
      if (i == now || ori[now][i]) continue;
      if (mp[now][i] == 1 && cnt[now] > cnt[i]) {
        cnt[now]--;
        cnt[i]++;
        mp[now][i] = -1;
        mp[i][now] = 1;
      }
    }
  }
  print();
}
