#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> number(n, -1);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (number.at(s - 1) == -1) {
      number.at(s - 1) = c;
    } else {
      if (c == number.at(s - 1)) {
        continue;
      } else {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  bool flag = true;
  for (int i = 0; i < n; i++) {
    if (number.at(i) == -1) {
      if (flag) {
        number.at(i) = 1;
        flag = false;
      } else {
        number.at(i) = 0;
      }
    } else {
      flag = false;
      continue;
    }
  }
  bool f = true;
  for (int i = 0; i < n; i++) {
    if (number.at(i) != 0) f = false;
  }
  if (f) {
    cout << -1 << endl;
    return 0;
  } else {
    bool g = false;
    for (int i = 0; i < n; i++) {
      if (number.at(i) != 0) flag = true;
      if (flag) cout << number.at(i);
    }
    return 0;
  }
  for (int i = 0; i < n; i++) cout << number.at(i);
  cout << endl;
}
