#include <bits/stdc++.h>
using namespace std;
int N, M, s[5], c[5];
string S;
int main() {
  cin >> N >> M;
  S = string(N, 0);
  for (int i = 0; i < M; i++) {
    cin >> s[i] >> c[i];
    s[i]--;
    if (s[i] == 0 && c[i] == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (S[s[i]] == 0 || S[s[i]] == '0' + c[i]) {
      S[s[i]] = '0' + c[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < N; i++) {
    if (S[i] == 0) {
      if (i == 0)
        cout << 1;
      else
        cout << 0;
    } else
      cout << S[i];
  }
  cout << endl;
}
