#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b)
{
	int res = 1;

	while (b)
	{
		if (b & 1) res = (res * a);

		a = (a * a); 
		b >>= 1;
	}
	return res;
}

int gcd(int a, int b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

#define N 200010
#define MOD 1000000007

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	int n, m;
	cin >> n >> m;

	int di[n + 1] = {}, s, c;
	for (int i = 0; i < m; ++i)
	{	
		cin >> s >> c;

		if (s == 1 && c == 0)
		{
			cout << -1;
			return 0;
		}

		if (di[s] == 0 || di[s] == c)
			di[s] = c;
		else
		{
			cout << -1;
			return 0;
		}
	}	
		
	if (di[1] == 0)
		di[1] = 1;
	for (int i = 1; i <= n; ++i)
		cout << di[i];

	return 0;
}