#include <bits/stdc++.h>
using namespace std;
long long int n, m, a, b, digits[10];
int main() {
  cin >> n >> m;
  memset(digits, -1, sizeof(digits));
  for (long long int i = 0; i < m; ++i) {
    cin >> a >> b;
    if (digits[a - 1] != -1 && digits[a - 1] != b) {
      cout << "-1" << endl;
      return 0;
    }
    if (a == 1 && b == 0 && n > 1) {
      cout << "-1" << endl;
      return 0;
    }
    digits[a - 1] = b;
  }
  if (digits[0] == -1) digits[0] = 1;
  for (long long int i = 0; i < n; ++i) {
    if (digits[i] == -1) digits[i] = 0;
  }
  for (long long int i = 0; i < n; ++i) cout << digits[i];
  return 0;
}
