/*
N M
s1 c1

⋮

sM cM


*/

#include<iostream>
#include<string>
using namespace std;
 
int main(void) {
  	int N, M;
  	cin >> N >> M;
  	int s[M];
  	char c[M];
  	vector<int> v;
  
  	for (int m = 0; m < M; m++){ cin >> s[m] >> c[m]; }
  	
  	startnum = 1;
  	for (int n = 1; n < N; n++){
      startnum *= 10;
    }
  	int endnum = startnum*10 - 1;
  	
  	for (int i = 0; i < M; i++){
      for (int n = startnum; n <= endnum; n++){
        int kirisute = n;
		for (int count = 0; count < N - s[i]; count++){
          kirisute /= 10;
        }
        if (kirisute % 10 == c[i]) {cout << n << endl; return 0;}
      }
    }
  	cout << -1 << endl;
  
    return 0;
}