#include <bits/stdc++.h>
using namespace std;
const int MN = 52, inf = 1000000005, mod = 1000000007;
const long long INF = 1000000000000000005LL;
bitset<MN> E[MN], F[MN], ust[MN];
int main() {
  srand(37325775);
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    E[u][v] = 1;
    ust[u][v] = ust[v][u] = 1;
  }
  vector<pair<int, int> > fajne;
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      if (!ust[i][j]) {
        if (rand() & 1)
          E[i][j] = 1;
        else
          E[j][i] = 1;
        fajne.push_back({i, j});
      }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (E[i][j] == 0) F[i][j] = 1;
  while (clock() < 0.9 * CLOCKS_PER_SEC) {
    random_shuffle((fajne).begin(), (fajne).end());
    for (auto e : fajne) {
      int a = e.first, b = e.second;
      int x = (E[a] & F[b]).count();
      int y = (E[b] & F[a]).count();
      if (E[a][b] == 1 && x > y) {
        E[a][b] = 0;
        E[b][a] = 1;
        F[a][b] = 1;
        F[b][a] = 0;
      }
      if (E[a][b] == 0 && x < y) {
        E[a][b] = 1;
        E[b][a] = 0;
        F[a][b] = 0;
        F[b][a] = 1;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) printf("%d", (int)E[i][j]);
    printf("\n");
  }
}
