#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, s, c;
  bool wrong = true;
  string t, d;
  vector<string> num;
  long long int i, j;
  cin >> n >> m;
  for (i = 0; i < (n); i++) {
    num.push_back("a");
  }
  for (i = 0; i < (m); i++) {
    cin >> s >> c;
    d = to_string(c);
    if ((num[s - 1] == "a") || (num[s - 1] == d)) {
      num[s - 1] = d;
    } else {
      wrong = false;
    }
  }
  if (num[0] == "a") {
    num[0] = "1";
  }
  for (i = 1; i < (n); i++) {
    if (num[i] == "a") {
      num[i] = "0";
    }
  }
  if (wrong == true) {
    if ((n != 1) && (num[0] == "0")) {
      cout << "-1" << endl;
    } else {
      for (i = 0; i < (n); i++) {
        cout << num[i];
      }
      cout << endl;
    }
  } else {
    cout << "-1" << endl;
  }
}
