#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll n,m,s,c;
	cin>>n>>m;
	vector<int> arr(n,-1);
	vector<bool> ok(n,1);
	bool tmp=1;
	map<ll,ll> mp;
	for(auto i=0;i<m;++i){
		cin>>s>>c;
		if(ok[s-1]){
			arr[s-1]=c;
			ok[s-1]=0;
			mp[s-1]=c;
		}
		if(!ok[s-1] && mp[s-1]!=c)tmp=0;
	}
	for(auto i=0;i<n;++i){
		if(ok[i]){
			if(i==0)arr[i]=1;
			else
				arr[i]=0;
		}
	}
	if(arr[0]==0 && n>1){
		cout<<"-1\n";
		return 0;
	}
	else
		if(n===1 && ok[0]){cout<<0<<'\n'; return 0;}
	if(tmp){
		for(auto i=0;i<n;++i)cout<<arr[i];
	}
	else
		cout<<"-1";
	cout<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}