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