#include <bits/stdc++.h>
using namespace std;
double pi = acos(-1);
inline long long lowbit(long long x) { return x & (-x); }
inline long long min(long long a, long long b) { return a < b ? a : b; }
inline long long max(long long a, long long b) { return a > b ? a : b; }
const int INF = 0x3f3f3f3f, max_n = 200005;
const int mod = 998244353;
inline long long gcd(long long a, long long b) {
  return b == 0 ? a : gcd(b, a % b);
}
inline long long pow(long long a, long long b, long long mod) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
int a, b;
int data1[105];
int flag;
int vis[105];
void f() {
  if (vis[1] == 1) {
    cout << data1[1];
  } else if (vis[1] == 0) {
    cout << "0";
  }
}
int flag1;
int main() {
  int n, x;
  cin >> n >> x;
  for (int i = 1; i <= x; i++) {
    cin >> a >> b;
    if (a == 1 && b == 0) {
      if (n == 1) {
        cout << "0";
      } else
        cout << "-1";
      flag1 = 1;
    }
    if (vis[a] == 1) {
      if (data1[a] != b) {
        flag = 1;
      }
    } else if (vis[a] == 0) {
      data1[a] = b;
      vis[a] = 1;
    }
  }
  if (flag1) return 0;
  if (n == 1) {
    f();
    return 0;
  }
  if (vis[1] == 0) {
    data1[1] = 1;
  } else if (vis[1] != 0) {
    if (data1[1] == 0) flag = 1;
  }
  if (flag) {
    cout << "-1";
  } else {
    for (int i = 1; i <= n; i++) {
      cout << data1[i];
    }
  }
}
