#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vec(n, -1);
  int ans = 0;
  int s, c;
  for (int i = 0; i < (int)(m); i++) {
    cin >> s >> c;
    if (vec[s - 1] == -1)
      vec[s - 1] = c;
    else if (vec[s - 1] != c)
      ans = 1;
  }
  if (vec[0] == -1) {
    if (n > 1)
      vec[0] = 1;
    else
      vec[0] = 0;
  }
  for (int i = 1; i < n; i++) {
    if (vec[i] == -1) vec[i] = 0;
  }
  if (n > 1) {
    if (vec[0] == 0 || ans == 1)
      cout << -1 << endl;
    else {
      for (int i = 0; i < (int)(n); i++) {
        cout << vec[i];
      }
      cout << endl;
    }
  } else
    cout << vec[0] << endl;
}
