#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << '\n';}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}

const ll inf = 1e18 + 1;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

	
		int n, m;
		cin>>n>>m;
		ll s[m], c[m];
		ll v[n] = {0};
		ll flag=0;
		for(int i=0;i<m;i++){
			cin>>s[i]>>c[i];
			if(v[s[i]-1]) flag=1;
			v[s[i]-1] = c[i];
		}	
		if(v[0]==0) flag=1;
		ll ans=0;
		if(flag==1) cout<<-1<<"\n";
		else {
		for(int j=0;j<n;j++){
			ans = ans*10+v[j];
		}
		cout<<ans<<"\n";
	}
	return 0;
}
