#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const long long INF = 1000000000000000000;
int s[10], c[10];
int ans[10];
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  for (int j = 0; j < 3; j++) {
    int num = mod;
    for (int i = 0; i < M; i++) {
      if (j == s[i]) {
        if (num == mod)
          num = c[i];
        else if (num != c[i]) {
          cout << -1 << endl;
          return 0;
        }
      }
    }
    if (num == mod) {
      if (j == 0)
        ans[j] = 1;
      else
        ans[j] = 0;
    } else {
      ans[j] = num;
    }
  }
  if (ans[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  if (N == 1 && M == 0) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i];
  }
  cout << endl;
}
