#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
	int n, m; cin >> n >> m;
	vector<int> s(m), c(m);
	rep(i, m) cin >> s[i] >> c[i];
	for (int i = 0; i < 1000; ++i) {
		string t = to_string(i);
		if (t.size() != n) continue;
		bool elf = true;
		rep(i, m) {
			if (t[s[i] - 1] != char(c[i] + '0')) elf = false;
		}
		if (elf) {
			cout << t << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}
