/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int a[1001],n,m,b[1001];
int c[1001];
int main()
{
	int i;
	cin>>n>>m;
	for(i=0;i<1001;i++) c[i]=-1;
	for(i=0;i<m;i++)
	{
		cin>>a[i]>>b[i];
		if(c[a[i]]!=-1){
			cout<<-1;return 0;
		}
		if(b[i]==0&&n==1) cout<<0;return 0;
		else if(b[i]==0&&n!=1) cout<<-1;return 0;
	}
	if(c[1]==-1){
		cout<<-1;return 0;
	}
	else{
	//	if(c[1]!=-1){
		for(i=1;i<=n;i++){
			cout<<c[i];
			}	
		}
		//else cout<<0;
	
	return 0;
}
