#include <bits/stdc++.h>
using namespace std;
int n, m, a[5], b[5];
void run() {
  if (n == 1) {
    cout << 0;
  } else {
    cout << 1;
    for (int i = 1; i < n; i++) cout << 0;
    cout << endl;
  }
  return;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (!b[s]) {
      a[s] = c;
      b[s] = 1;
    } else {
      if (a[s] != c) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  if (m == 0) {
    run();
  } else {
    if (a[1] == 0) {
      if (n == 1)
        cout << 0 << endl;
      else
        cout << -1 << endl;
      return 0;
    }
    for (int i = 1; i <= n; i++) cout << a[i];
    cout << endl;
  }
  return 0;
}
