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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);                      \
	cin.exceptions(cin.failbit);
#define int long long int //Comment when Unnecessary
#define ll long long
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define pii pair<int, int>
#define vi vector<int>
#define F first
#define S second
#define endl "\n" // Remove on Interactive

const int N = 300009;
const int mod = 1000000007;

void pre()
{
}

int32_t main()
{
	IOS;
	pre();
	int n, m;
	int s, c;
	cin >> n >> m;
	if (n == 1)
	{
		if (m == 0)
		{
			cout << 0 << endl;
			return 0;
		}
		rep(i, 0, m)
		{
			cin >> s >> c;
			if (st[s - 1] != '#' && (st[s - 1] != (c + '0')))
			{
				cout << -1 << endl;
				return 0;
			}
			st[s - 1] = (c + '0');
		}
		cout << st << endl;
	}

	string st = "";
	rep(i, 0, n)
	    st += '#';

	rep(i, 0, m)
	{
		cin >> s >> c;
		if (st[s - 1] != '#' && (st[s - 1] != (c + '0')))
		{
			cout << -1 << endl;
			return 0;
		}
		st[s - 1] = (c + '0');
	}
	if (st[0] == '0')
	{
		cout << -1 << endl;
		return 0;
	}
	if (st[0] == '#')
	{
		st[0] = '1';
	}
	rep(i, 1, n) if (st[i] == '#')
	    st[i] = '0';
	cout << st << endl;
	return 0;
}
