// Created by sz
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
#ifdef LOCAL
	freopen("./input.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, m;
	cin >> n >> m;
	vector<int> num(n, -1);
	int ok = 1;
	for (int i = 0; i < m; i++)
	{
		int s, c;
		cin >> s >> c;
		s--;
		if (num[s] == -1) num[s] = c;
		else if (num[s] != c) ok = 0;
	}

	if (num[0] == 0) ok = 0;

	if (!ok) {
		cout << -1 << endl;
	}
	else
	{
		for (int i = 0; i < n; i++)
		{
			if (num[i] == -1){
				if(i==0)num[i] = 1;
				else num[i] = 0;
			cout << num[i];
		}
		cout << endl;
	}



	return 0;
}
