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