#include <bits/stdc++.h>
#include <cmath>
using namespace std;

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];
  }
   for (int j = 0;j < M;j++) {
   	for (int k = 0;k < M;k++) {
    	if (S[j] == S[k]) {
        cout << -1 << endl;
        return 0;}
    }
   }
  vector<int> ans(N,0);
  for (int l = 0;l < M;l++) {
  ans[S[i]-1] = C[i];
  }
  if (ans[0] == 0) {
  ans[0] = 1;
  }
  for (int m = 0;m < N;m++) {
  cout << ans[m];
  }
  cout << endl;
}
