#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (a*b)/ebob(a, b);
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	int q; cin>>q;
	int ar[n+1] = {};
	bool taken[n+1] = {};
	while(q--){
		int left, i; cin>>left>>i;
		if(taken[left] && ar[left] != i){
			cout<<-1;
			return 0;
		}
		ar[left] = i;
		taken[left] = true;
	}
	if(taken[1] && ar[1] == 0){
		cout<<-1;
		return 0;
	}
	if(!taken[1]) ar[1] = 1;
	for(int i = 1; i <= n; i++){
		cout<<ar[i];
	}
}