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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> a(n);
	rep(i,m){
		int s,c;
		cin >> s >> c;
		a[s-1] = c;
	}
	if(s == 1 && c == 0) cout << -1 << endl;
	if(n >1 && a[0] == 0) cout << -1 << endl;
	else{
	rep(i,m){
		cout << a[i];
	}
	cout << endl;
}
}