//dhruv
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second


signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int n,m;
    cin >> n >> m;
    string ans;
    ans.resize(n);
    ffor(i,n){
    	ans[i] = '.';
    }
    ffor(i,m){
    	int s,c;
    	cin >> s >> c;
    	--s;
    	if(ans[s] != '.' && (ans[s] != ('0' + c))) {
    		cout << -1;
    		return 0;
    	}
    	ans[s] = ('0' + c);
    }
    if(ans[0] == '0' && (n > 1)){
    	cout << -1;
    	return 0;
    }
    if(n == 1 && (ans[0] == '.'))ans[0] = '0';
    else(ans[0] == '.') ans[0] = '1';
    for(int i = 1;i < n; ++i){
    	if(ans[i] == '.') ans[i] = '0';
    }
    cout << ans;
}		