#include <bits/stdc++.h>
const long long mod = 998244353;
const long long INF = 0x3f3f3f3f;
const long long maxn = 1e6 + 5;
const double pi = acos(-1.0);
const double eps = 1e-9;
using namespace std;
long long qpow(long long a, long long b) {
  long long s = 1;
  while (b > 0) {
    if (b & 1) s = s * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return s;
}
int a[100];
int main() {
  int n, m;
  cin >> n >> m;
  memset(a, 0, sizeof(a));
  bool flag = true;
  while (m--) {
    int x, y;
    cin >> x >> y;
    if (a[x] != 0) {
      int z = a[x];
      if (z != y) {
        flag = false;
        break;
      } else {
        a[x] = y;
      }
    } else {
      a[x] = y;
    }
  }
  if (!flag)
    cout << "-1" << endl;
  else {
    if (a[1] == 0 && n == 1)
      cout << "-1" << endl;
    else if (a[1] == 0 && n != 1) {
      a[1] = 1;
      for (int i = 1; i <= n; i++) {
        cout << a[i];
      }
      cout << endl;
    } else {
      for (int i = 1; i <= n; i++) {
        cout << a[i];
      }
      cout << endl;
    }
  }
}
