#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
using namespace std;
const long long maxn = 9e5 + 100;
const long long mod = 1e9 + 7;
const long double PI = 4 * atan((long double)1);
long long pw(long long a, long long b) {
  return (!b ? 1
             : (b & 1 ? a * pw(a * a % mod, b / 2) % mod
                      : pw(a * a % mod, b / 2) % mod));
}
int n, m;
int mark[100];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (int i = 0; i < 100; i++) {
    mark[i] = -1;
  }
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (mark[s] == -1) {
      mark[s] = c;
    } else if (c != mark[s]) {
      cout << -1;
      return (0);
      ;
    }
  }
  if (mark[0] == -1) {
    mark[0] = 1;
  }
  if (mark[0] == 0 and n > 1) {
    cout << -1;
    return (0);
    ;
  }
  for (int i = 0; i < n; i++) {
    if (mark[i] == -1) {
      mark[i] = 0;
    }
    cout << mark[i];
  }
  return (0);
}
