#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rev(a) reverse(all(a))
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main() {
    int n, m;
    cin >> n >> m;
    bool f=0;
    int a[n]={0};
    while(m--){
        int x,y;
        cin >> x >> y;
        if(x>n){
            f=1;
        }else{
            if(a[x-1]!=0&&a[x-1]!=y)f=1;
            else a[x-1]=y;
        }
    }
    if(f==1) cout << -1 << endl;
    else{
        for(int i=0; i<n; i++) cout << a[i];
        cout << endl;
    }
    
	return 0;
}