// C - Guess The Number
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,M; cin>>N>>M;
	string T(N,'-');
	while(M--){
		int s; char c; cin>>s>>c; s--;
		if(T[s]!='-' && T[s]!=c || N!=1 && s==0 && c=='0'){
			puts("-1"); return 0;
		}
		T[s] = c;
	}
	while(N--) if(T[N]=='-') T[N] = T.size()==1? '0': N!=0? '0': '1';
	cout<< stoi(T) <<endl;
}