#include <bits/stdc++.h>
#include <bits/extc++.h>

using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define pi acos(-1.0)
const ll maxn = 2e5 + 100;
const ll mod = 1e9;
int c[10];
int val[10];
map<int, int> mat;
signed main()
{
	int n, m;
	cin >> n >> m;
	bool okay = 1;
	_rep(i, 1, m)
	{
		int s, c;
		cin >> s >> c;
		if (!mat.count(s) || mat[s] == c)
		{
			mat[s] = c;
		}
		else
			okay = 0;
	}

	string s;
	_rep(i, 1, n)
	{
		if (mat[i])
		{
			s += mat[i] + '0';
		}
		else
			s += '0';
	}
	if (s[0] == '0')
	{
		if (!mat.count(1))
			s[0] = '1';
		else
		{
			okay = 0;
		}
	}
	if (okay)
		cout << s << endl;

	else
		cout << -1 << endl;
}