#include <bits/stdc++.h>
using namespace std;
const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;
const double PI = acos(-1);
long long dx[] = {0, 0, -1, 1, -1, -1, 1, 1};
long long dy[] = {1, -1, 0, 0, 1, -1, -1, 1};
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}
void solve() {
  int n, m;
  cin >> n >> m;
  int a[n];
  memset(a, -1, sizeof(a));
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (a[s - 1] == c or a[s - 1] == -1) {
      a[s - 1] = c;
    } else if (a[s - 1] != c) {
      cout << -1 << '\n';
      return;
    }
  }
  if (n == 1 and a[0] == 0) {
    cout << 0;
    return;
  }
  if (n > 1) {
    if (a[0] == 0 or (a[0] == 0 and a[1] == 0) or
        (a[0] == 0 and a[1] == 0 and a[2] == 0)) {
      cout << -1 << '\n';
      return;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i == 0 and a[i] == -1) {
      a[i] = 1;
    } else if (a[i] == -1) {
      a[i] = 0;
    }
  }
  for (auto i : a) {
    cout << i;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
