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