#include <bits/stdc++.h>

using namespace std;


#define PI 3.14159265
#define int long long


int sqr(int x){
	return x * x;
}


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];
		if(s[i] > n){
			cout << -1 << endl; return 0;
		}
	}

	// string ans;

	
		for(int i = 0; i < m; i++){
			for(int j = 0; j < m; j++){
				if(s[i] == s[j] and c[i] != c[j]){
					cout << -1 << endl; return 0;
				}
			}
		}
	if(n == 1){
		cout << c[0] << endl; return 0;
	}

	string ans = "1";
	for(int i = 0; i < n - 1; i++) ans.push_back('0');

	for(int i = 0; i < m; i++){
		ans[s[i] - 1] = c[i] + '0';
	}

	if(ans[0] == '0'){
		cout << -1 << endl; return 0;
	}else{
		cout << ans << endl;
	}
	
	
	
	return 0;
}