#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 1e16;
const long long MAX_N = 100010;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> v(n, -1);
  bool flag = false;
  for (long long loop = 0; loop < m; loop++) {
    long long s, c;
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0) {
      flag = true;
    }
    if (v[s] == -1) {
      v[s] = c;
    } else {
      if (v[s] != c) {
        flag = true;
      }
    }
  }
  if (flag) {
    cout << -1 << endl;
    return 0;
  }
  for (long long i = 0; i < n; i++) {
    if (v[i] == -1) {
      if (i == 0) {
        v[i] = 1;
      } else {
        v[i] = 0;
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    cout << v[i];
  }
  cout << endl;
  return 0;
}
