#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> digitnums(n);
  for (int i = 0; i < (int)(n); i++) {
    digitnums.at(i) = -1;
  }
  for (int i = 0; i < (int)(m); i++) {
    int a, b;
    cin >> a >> b;
    if ((digitnums[a - 1] != -1) && (digitnums[a - 1] != b)) {
      cout << -1 << endl;
      return 0;
    }
    if ((a == 1) && (b == 0)) {
      cout << -1 << endl;
      return 0;
    }
    digitnums[a - 1] = b;
  }
  string result = "";
  for (int i = 0; i < (int)(n); i++) {
    if (digitnums[i] == -1) {
      if (i == 0) {
        result += "1";
      } else {
        result += "0";
      }
    } else {
      result += to_string(digitnums[i]);
    }
  }
  cout << result << endl;
  return 0;
}
