#include <bits/stdc++.h>
using namespace std;
int arr[3];
bool v[3];
int main() {
  for (int i = 0; i < (int)(3); i++) {
    arr[i] = -1;
    v[i] = false;
  }
  int n, m, i, bb;
  cin >> n >> m;
  for (int a = 0; a < (int)(m); a++) {
    cin >> i >> bb;
    if (n > 1 && 1 == i && 0 == bb) {
      cout << "-1" << endl;
      return (0);
    }
    if (v[i] && arr[i] != bb) {
      cout << "-1" << endl;
      return (0);
    }
    arr[i] = bb;
    v[i] = true;
  }
  for (int i = (1); i < (int)(n + 1); i++) {
    if (v[i]) {
      cout << arr[i];
    } else if (n > 1 && i == n) {
      cout << 1;
    } else {
      cout << 0;
    }
  }
  cout << endl;
}
