#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
//#define x first
//#define y second

using namespace std;
int m,n,s,c;
map<int,int>a;
int main()
{
	cin>>n>>m;
	rep(i,m)
	{
		cin>>s>>c;
		if(s>n||(a.count(s)&&a[s]!=c))
		{
			cout<<-1<<endl;
			return 0;
		}
		a[s]=c;
	}
	if(n==1&&!a.count(1)) cout<<0<<endl;
	if(n!=1&&a.count(1)&&a[1]==0)
	{
		cout<<-1<<endl;
		return 0;
	}
	else
	{
		if(a.count(i)) cout<<a[i];else cout<<1;
		rep2(i,2,n+1) if(a.count(i)) cout<<a[i];else cout<<0;
		cout<<endl;
	}
	return 0;}