#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m; scanf("%d%d", &n, &m);

	std::string ans(n, '.');
	for(int i = 0; i < m; i++) {
		int a, b; scanf("%d%d", &a, &b);
		a--;
		
		if(ans[a] != '.' and ans[a] != (char)(b + '0')) {
			printf("-1\n");
			return 0;
		}
		ans[a] = (char)(b + '0');
	}
	if(ans[0] == '0') {
		printf("-1\n");
		return 0;
	}
	
	if(n >= 1 and ans[0] == '.') ans[0] = '1';
	if(n >= 2 and ans[1] == '.') ans[1] = '0';
	if(n >= 3 and ans[2] == '.') ans[2] = '0';
	printf("%s\n", ans.c_str());
	return 0;
}
