#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9,
                inf = 1e18 + 7;
const long long infll = 1e18 + 7;
long long n, m;
string a;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    a[i] = '?';
  }
  while (m--) {
    long long x, y;
    cin >> x >> y;
    if (a[x] == '?') {
      a[x] = (char)('0' + y);
    } else if (a[x] != (char)('0' + y)) {
      cout << -1;
      return 0;
    }
  }
  if (a[1] == '?') a[1] = 1;
  if (n != 1 && a[1] == '0') return cout << -1, 0;
  ;
  for (long long i = 2; i <= n; i++) {
    if (a[i] == '?') a[i] = '0';
  }
  for (long long i = 1; i <= n; i++) cout << a[i];
}
