#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 3;
string s, p;
char a[5];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t, i, j, n, m, l, r, f = 0, b[5];
  cin >> n >> m;
  memset(b, -1, sizeof(b));
  for (i = 0; i < m; i++) {
    cin >> l >> r;
    if (b[l] == -1) {
      a[l - 1] = (char)(r + 48);
      b[l] = r;
    } else {
      if (b[l] != r) {
        f = 1;
      }
    }
  }
  if (n > 1 && b[1] == 0) {
    f = 1;
  }
  if (f == 1) {
    cout << "-1\n";
  } else {
    for (i = 0; i < n; i++) {
      if (b[i + 1] == -1) {
        if (i > 0) {
          a[i] = '0';
        } else {
          a[i] = '1';
        }
      }
    }
    if (n == 1 && b[0] == -1) {
      a[0] = '0';
    }
    a[n] = '\n';
    cout << a << "\n";
  }
  return 0;
}
