#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep1(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define rep0(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define re return
#define mp map<int,int>
#define N 200005
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int s[m],c[m],ans[n]={1};
	if(n==1) ans[0]=0;
	rep0(i,0,m) {
	    cin>>s[i]>>c[i];
	    if(ans[s[i]-1]==0) {
	      ans[s[i]-1]=c[i];
	    }
		else if(ans[0]==1&&s[i]==1){
			ans[s[i]-1]=c[i];
		}
		else {
			cout<<"-1";
			re 0;
		}
	}
	if(ans[0]==0&&n>1) {
		cout << "-1";
		re 0;
	}
	rep0(i,0,n) cout<<ans[i];
	re 0;
}