#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 100000007
#define ll long long
#define F first
#define S second
#define pii pair<int,int>
#define FOR(i,k,n) for(int i=k;i<n+k;i++)
#define ALL(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);
#define deg(x) cout<<"--"<<x<<endl;
int II(){int q;scanf("%d",&q);return q;}
int dx[]={0,-1,0,1};
int dy[]={-1,0,1,0};
int dxx[]={0,-1,-1,-1,0,1,1,1};
int dyy[]={-1,-1,0,1,1,1,0,-1};
#define int ll
const int N=1000005;

void solve(){
	int n,m;cin>>n>>m;
	string s="";
	for(int i=1; i<=n; i++) s+='#';
	bool bo=0;
	for(int i=1; i<=m; i++){
		int x,y;cin>>x>>y;
		if(x==1 && y==0){
			bo=1;
			break;
		}
		if(s[x-1]=='#' or s[x-1]==(y+'0')){
			s[x-1]=(y+'0');
		}else{
			bo=1;
			break;
		}
	}
	if(bo==1){
		cout<<-1<<endl;
		return;
	}
	for(int i=0; i<n; i++) if(s[i]=='#') s[i]='0';
	cout<<s<<endl;
}
 
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int tt; tt=1;
    int cas=1;
    while(tt--){
        //printf("Case %d: ",cas++);
        solve();
    }
}