#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
  int N, M;
  cin >> N >> M;
  if (M == 0) {
    cout << pow(10, N - 1) << "\n";
    return 0;
  }
  vector<int> C(M);
  vector<int> S(M);
  for (int i = 0; i < (M); i++) cin >> S[i] >> C[i];
  for (int n1 = pow(10, N - 1); n1 < (pow(10, N)); n1++) {
    string n = to_string(n1);
    bool flg = true;
    for (int m = 0; m < (M); m++) {
      if (S[m] > n.size()) {
        flg = false;
        break;
      }
      if (n.at(S[m] - 1) != (char)(C[m] + '0')) {
        flg = false;
        break;
      }
    }
    if (flg) {
      cout << n << "\n";
      return 0;
    }
  }
  cout << -1 << "\n";
}
