#include <bits/stdc++.h>
using namespace std;
int n, m;
int pos[4], ans[4];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= 3; i++) pos[i] = -1;
  for (int i = 1; i <= m; i++) {
    int s, c;
    cin >> s >> c;
    if (pos[s] != -1 && pos[s] != c) {
      cout << -1;
      return 0;
    }
    pos[s] = c;
  }
  bool ok = false;
  for (int i = 1; i <= n; i++) {
    if (pos[i] == -1) {
      if (ok)
        ans[i] = 0;
      else {
        ans[i] = 1;
        ok = true;
      }
    } else {
      ans[i] = pos[i];
      if (!pos[i] && !ok) {
        cout << -1;
        return 0;
      }
      ok = true;
    }
  }
  for (int i = 1; i <= n; i++) cout << ans[i];
}
