#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int INF = 0x3f3f3f3f;
long long ksm(long long x, long long n) {
  long long ans = 1;
  while (n) {
    if (n & 1) ans = (ans * x) % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return ans;
}
using namespace std;
double pi = atan(1.0) * 4;
const int mxn = 1e3 + 7;
int n, t, m, k, l, r;
long long phi[mxn];
int a[11];
long long exgcd(long long a, long long b, long long &x, long long &y) {
  if (!a && !b) return -1;
  if (!b) {
    x = 1, y = 0;
    return a;
  }
  long long d = exgcd(b, a % b, y, x);
  y -= a / b * x;
  return d;
}
string str;
int vis[mxn][mxn];
struct node {
  string str;
  int k;
} no[mxn];
int main() {
  cin >> n >> m;
  if (n == 1 && !m) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i <= 10; i++) a[i] = -1;
  bool f1 = 0;
  for (int i = 1; i <= m; i++) {
    cin >> l >> r;
    if (l == 1 && !r)
      f1 = 1;
    else if (a[l] == -1)
      a[l] = r;
    else {
      if (a[l] == r)
        f1 = 0;
      else
        f1 = 1;
    }
  }
  if (f1) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == -1) {
      if (i == 1)
        a[i] = 1;
      else
        a[i] = 0;
    }
    cout << a[i];
  }
  cout << endl;
}
