#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
signed main() {
  long long n, m;
  cin >> n >> m;
  long long s[n];
  for (long long i = 0; i < n; i++) {
    s[i] = 11;
  }
  bool could = true;
  long long c[m], d[m];
  for (long long i = 0; i < m; i++) {
    cin >> c[i] >> d[i];
  }
  for (long long i = 0; i < m; i++) {
    long long a, b;
    a = c[i], b = d[i];
    a--;
    if (s[a] != 11 and s[a] != b) {
      could = false;
      break;
    }
    s[a] = b;
  }
  if (s[0] == 0 and n != 1) could = false;
  for (long long i = 0; i < n; i++)
    if (s[i] == 11) {
      if (i == 0)
        s[i] = 1;
      else
        s[i] = 0;
    }
  if (could) {
    for (long long i = 0; i < n; i++) cout << s[i];
    cout << endl;
  } else
    cout << -1 << endl;
}
