#include <iostream>
#include <vector>

using namespace std;

int main(){
	int n,m;
	cin >> n >> m;
	bool res = true;
	vector<int> tmp(n,11);
	for(int i=0;i<m;++i){
		int a,b;
		cin >> a >> b;
		if(n > 1 && a == 1 && b == 0){
			res = false;
		}else if(tmp[a-1] == 11){
			tmp[a-1] = b;
		}else if(tmp[a-1] != b){
			res = false;
		}
	}
	if(res){
		for(int i=0;i<n;++i){
			if(tmp[i]==11){
				if(i==0 && n != 1)cout << 1;
				else cout << 0;
			}
			else cout << tmp[i];
		}
	}else{
		cout << -1;
	}
	cout << endl;
}