#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int64_t N, M;
  int64_t s, c;
  string output = "---";
  bool check = true;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> s >> c;
    if ((output[s - 1] != '-') && (output[s - 1] != (c + '0'))) {
      check = false;
    } else {
      output[s - 1] = c + '0';
    }
    if (s > N) {
      check = false;
    }
  }
  if ((output[0] == '0') && (N > 1)) {
    cout << "-1\n";
    return 0;
  }
  if (check) {
    int i = 2;
    while (output[i] == '-') {
      output[i] = '\0';
    }
    for (i = 0; i < 2; i++) {
      if (output[i] == '-') {
        if (i == 0) {
          if (N == 1) {
            output[i] = 0 + '0';
          } else {
            output[i] = 1 + '0';
          }
        } else {
          output[i] = 0 + '0';
        }
      }
    }
    cout << output.substr(0, N) << "\n";
  } else {
    cout << "-1\n";
  }
  return 0;
}
