#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long int n, m;
  cin >> n >> m;
  long long int num = 0;
  long long int data[3];
  data[0] = (1LL << 50);
  data[1] = (1LL << 50);
  data[2] = (1LL << 50);
  for (int i = 0; i < m; i++) {
    long long int s, c;
    cin >> s >> c;
    s--;
    if (s > n) {
      cout << -1 << endl;
      return 0;
    }
    if (data[s] == (1LL << 50) || data[s] == c) {
      data[s] = c;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  if (data[0] == 0) {
    if (n == 1)
      cout << 0 << endl;
    else
      cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (data[i] == (1LL << 50)) {
      if (i != 0)
        data[i] = 0;
      else
        data[i] = 1;
    }
    cout << data[i];
  }
  cout << endl;
  return 0;
}
