#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

int N, M;

int main() {
  cin >> N >> M;
  int s[M], c[M];
  rep(i, M) {
    cin >> s[i] >> c[i];
  }
 
  int ans = -1;
  int count_correct;
  for (int i = pow(10, N-1); i < pow(10, N); i++) {
    count_correct = 0;
    rep(j, M) {
      int k = floor(i / pow(10, (N-s[j])));
      if (k%10 == c[j]) {
        count_correct++;
      }
    }
    if (count_correct == M) ans = i;
    if (ans != -1) break;
  }
  if(N==1 && c[0]==0) {
    ans = 0
  }
  
  cout << ans;
}
