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