#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1);
const long long int inf = 1e18, M = 1e9 + 7;
const long long int N = 1;
void solve() {
  long long int n, m;
  cin >> n >> m;
  long long int a[n];
  memset(a, -1, sizeof(a));
  for (long long int i = 0; i < m; ++i) {
    long long int s, c;
    cin >> s >> c;
    if (s == 1 && c == 0 && n != 1) {
      cout << -1;
      return;
    }
    --s;
    if (a[s] == -1)
      a[s] = c;
    else {
      if (a[s] == c)
        ;
      else {
        cout << -1;
        return;
      }
    }
  }
  for (long long int i = 0; i < n; ++i) {
    if (a[i] == -1) {
      if (!i)
        a[i] = 1;
      else
        a[i] = 0;
    }
    cout << a[i];
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
