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