#include <bits/stdc++.h>
using namespace std;
bool all_0(int a, int b, int c) { return a == b && b == c && c == 0; }
int main() {
  int n, m;
  cin >> n >> m;
  vector<char> digits(n, -1);
  for (int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    if (digits[s - 1] != -1 && digits[s - 1] != c) {
      cout << "-1\n";
      return 0;
    }
    digits[s - 1] = c;
  }
  for (int i = 0; i < n; ++i) {
    if (digits[i] == -1)
      continue;
    else if (digits[i] == 0) {
      cout << "-1\n";
      return 0;
    } else {
      break;
    }
  }
  if (digits[0] == -1) {
    digits[0] = 1;
  }
  for (int i = 1; i < n; ++i) {
    if (digits[i] == -1) {
      digits[i] = 0;
    }
  }
  for (int d : digits) {
    cout << d;
  }
  cout << '\n';
  return 0;
}
