#include <bits/stdc++.h>
using namespace std;
vector<vector<bool>> c(3, vector<bool>(3));
int main() {
  int n, b, c, d;
  cin >> n >> b;
  map<int, int> a;
  for (int i = 0; i < b; i++) {
    cin >> c >> d;
    if (a.count(c)) {
      if (a.at(c) == d)
        ;
      else {
        cout << "-1";
        return 0;
      }
    }
    a[c] = d;
  }
  if (a.count(1)) {
    if (a[1] == 0) {
      cout << -1;
      return 0;
    }
  } else {
    if (n == 1) {
      cout << 0;
      return 0;
    } else
      a[1] = 1;
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i];
  }
}
