#include <bits/stdc++.h>
using namespace std;
void yes() {
  cout << "Yes" << endl;
  exit(0);
}
void no() {
  cout << -1 << endl;
  exit(0);
}
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n, -1), s(m), c(m);
  for (long long i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  for (long long i = 0; i < m; i++) {
    if (a[s[i]] == -1) {
      a[s[i]] = c[i];
    } else if (a[s[i]] != c[i]) {
      no();
    }
  }
  if (n > 1) {
    if (a[0] == 0) {
      no();
    } else if (a[0] == -1) {
      a[0] = 1;
    }
  }
  for (long long i = 1; i < n; i++) {
    if (a[i] == -1) {
      a[i] = 0;
    }
  }
  for (long long i = 0; i < n; i++) {
    cout << a[i];
  }
  cout << endl;
}
