#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	int a[n+1];
	for (int i=1; i<=n; i++) a[i]=-1;
	for (int i=1; i<=m; i++)
	{
		int x, y;
		cin >> x >> y;
		if (a[x]==-1) a[x]=y;
		else if (a[x]!=y)
		{
			cout << -1 << endl;
			return 0; 
		}
	}
	if (a[1]==0&&n!=1)
	{
		cout << -1 << endl;
		return 0;
	}
	if (a[1]==-1&&n!=1) a[1]=1;
	if (a[1]==-1&&n==1) a[1]=0;
	for (int i=1; i<=n; i++)
	{
		if (a[i]==-1) a[i]=0;
		cout << a[i];
	}
	cout << endl;
	return 0;
}