#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <map>
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-10;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll maxn = 1e6 + 5;

int main(){
	int n,m,a[10],s,c;
	map<int,int>mp;
	cin>>n>>m;
	bool flag=false;
	memset(a,-1,sizeof(a));
	while(m--){
		cin>>s>>c;
		if(a[s]==-1){
			q[s]=c;
			a[s]=c;
		}else{
			flag=true;
		}
	}
	if(a[1]==0 && n>1) flag=true;
	if(flag) cout<<-1;
	else{
		if(n>1){
			for(int i=1;i<=n;i++){
				if(a[i]==-1 && i==1) cout<<1;
				else if(a[i]==-1 && i>1) cout<<0;
				else cout<<a[i];
			}
		}else{
			if(a[1]==-1) cout<<0;
			else cout<<a[1];
		}
	}
	return 0;
}