#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int N, M;
int s[6], c[6];
string t = "000";
int num[4] = {-1, -1, -1};
int main() {
  cin >> N >> M;
  for (int i = (0); i < (M); i++) {
    cin >> s[i] >> c[i];
    if (num[s[i] - 1] == -1) {
      num[s[i] - 1] = c[i];
    } else {
      if (num[s[i] - 1] != c[i]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  if (N > 1 && num[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  if (N == 1 && M == 0) {
    cout << 0 << endl;
    return 0;
  }
  bool enc = false;
  for (int i = (0); i < (N); i++) {
    if (num[i] > -1) {
      if (!enc && num[i] == 0) {
        num[0] = 1;
        for (int j = (1); j < (i); j++) {
          num[j] = 0;
        }
      }
      enc = true;
    } else {
      if (i == 0) {
        num[i] = 1;
      } else {
        num[i] = 0;
      }
    }
  }
  for (int i = (0); i < (N); i++) {
    cout << num[i];
  }
  cout << endl;
  return 0;
}
