#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
	IOS;
	int n,m;
	cin>>n>>m;
	bool b[n]={false};
	int a[n]={0};
	a[0]=1;
	for(int i=0;i<m;i++){
		int x,y; cin>>x>>y;
		x--;
		if(b[x]==1&&a[x]!=y){cout<<-1<<endl; return 0;}
		else if(x==0&&y==0&&n>1){cout<<-1<<endl; return 0;}
		else{
			b[x]=1;
			a[x]=y;
		}
	}
	for(int i=0;i<n;i++) cout<<a[i];
}