#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vec(n);
  vector<bool> bo(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (!bo[a - 1]) {
      vec[a - 1] = b;
      bo[a - 1] = 1;
    } else if (bo[a - 1] && vec[a - 1] != b) {
      cout << "-1\n";
      return 0;
    }
  }
  if (vec[0] == 0) {
    cout << "-1\n";
    return 0;
  }
  if (!bo[0]) vec[0] = 1;
  if (!bo[1]) vec[1] = 0;
  if (!bo[2]) vec[2] = 0;
  for (auto c = vec.begin(); c != vec.end(); c++) {
    cout << *c;
  }
}
