#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> v(N, -1);
  int digit, num;
  bool can = true;
  for (int i = 0; i < M; i++) {
    cin >> digit >> num;
    digit--;
    if (v[digit] != -1 && v[digit] != num) {
      can = false;
      break;
    }
    v[digit] = num;
  }
  if (N >= 2 && v[0] == 0) can = false;
  if (can == false) {
    cout << -1 << '\n';
  } else {
    for (int i = 0; i < N; i++) {
      if (v[i] != -1) {
        cout << v[i];
      } else if (i == 0) {
        cout << 1;
      } else {
        cout << 0;
      }
    }
    cout << '\n';
  }
}
