#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m);
  vector<int> c(m);
  for (int i = 0; i < (m); ++i) {
    cin >> s[i] >> c[i];
  }
  int ans = -1;
  for (int i = pow(10, n - 1); i < pow(10, n) - 1; i++) {
    int ju = 1;
    for (int j = 0; j < m; j++) {
      if (int(fmod((i / pow(10, n - s[j])), 10)) != c[j]) {
        ju = 0;
      }
    }
    if (ju) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}
