#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[m], b[m];
  for (int i = 0; i < m; i++) cin >> a[i] >> b[i];
  for (int i = pow(10, n - 1) + 1; i < pow(10, n) - 1; i++) {
    bool good = true;
    for (int j = 0; j < m; j++) {
      int cifra = i / pow(10, n - a[j]);
      cifra %= 10;
      if (cifra != b[j]) {
        good = false;
        break;
      }
    }
    if (good) {
      cout << i << "\n";
      return 0;
    }
  }
  puts("-1");
  return 0;
}
