#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

int main() {
	int n, m, s;
	char c;
	cin >> n >> m;
	string t = string(n, ' ');
	while (m--) {
		cin >> s >> c;
		s--;
		if (t[s] != ' ' && t[s] != c) {
			cout << -1 << endl;
			return 0;
		}
		t[s] = c;
	}
	if (n > 1 && t[0] == '0') {
		cout << -1 << endl;
		return 0;
	}
	if (t[0] == ' ') {
		t[0] = '0' + (n > 1);
	}
	for (int i = 1; i < n; i++) {
		if (t[i] == ' ') t[i] = '0';
	}
	cout << t << endl;
	return 0;
}
