#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int an[n];
  for (int i = 0; i < (int)(n); i++) an[i] = -1;
  int s, c;
  for (int i = 0; i < (int)(m); i++) {
    cin >> s >> c;
    if (an[s - 1] == -1) {
      an[s - 1] = c;
    } else if (an[s - 1] != c) {
      cout << -1;
      return 0;
    }
  }
  if (an[0] == 0) {
    if (n == 1)
      cout << 0;
    else
      cout << -1;
    return 0;
  }
  for (int i = 0; i < (int)(n); i++) {
    if (an[i] == -1) {
      if (i == 0)
        an[i] = 1;
      else
        an[i] = 0;
    }
    cout << an[i];
  }
}
