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