#include <bits/stdc++.h>
using namespace std;
int n, m;
bool flag[51][51];
bool used[51][51];
int cnt[51];
bool route[51];
vector<int> vs;
bool dfs(int v) {
  vs.push_back(v);
  route[v] = true;
  if (cnt[v] > cnt[vs[0]] + 1) {
    for (int i = 0; i + 1 < vs.size(); i++) {
      flag[vs[i]][vs[i + 1]] = true;
      flag[vs[i + 1]][vs[i]] = false;
    }
    cnt[v]--;
    cnt[vs[0]]++;
    return true;
  }
  for (int i = 0; i < n; i++) {
    if (i == v) continue;
    if (route[i] || used[v][i] || flag[v][i]) continue;
    if (dfs(i)) {
      return true;
    }
  }
  vs.pop_back();
  return false;
}
int main(void) {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    flag[a][b] = true;
    used[a][b] = true;
    used[b][a] = true;
    cnt[a]++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (!used[i][j]) {
        flag[i][j] = true;
        cnt[i]++;
      }
    }
  }
  bool updated = true;
  while (updated) {
    updated = false;
    for (int i = 0; i < n; i++) {
      vs.clear();
      memset(route, false, sizeof(route));
      if (dfs(i)) {
        updated = true;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      printf("%d", flag[i][j] ? 1 : 0);
    }
    printf("\n");
  }
  return 0;
}
