#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	pair<int, char> p[m];
	for (int i = 0; i < m; i++){
		cin >> p[i].first >> p[i].second;
	}
	for (int i = 0; i < pow(10, n); i++){
		string s = to_string(i);
		bool flag = 1;
		for (int j = 0; j < m; j++){
			if (s[p[j].first-1] != p[j].second) flag = 0;
		}
		if (s.size() == n and flag){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;

}
