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

int S[100];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) S[i] = -1;
	while(m--) {
		int s, c;
		cin >> s >> c;
		s--;
		if(s == 0 && c == 0 && n != 1) return cout << -1, 0;
		if(S[s] != -1 && S[s] != c) return cout << -1, 0;
		S[s] = c;
	}
	if(n == 1 && S[0] == -1) S[0] = 0;
	for (int i = 0; i < n; i++) {
		if(S[i] == -1) {
			if(i) S[i] = 0;
			else S[i] = 1;
		}
		cout << S[i];
	}
	return 0;
}