
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

int main(){
    
    ll n,m;
    cin >> n >> m;
    char c[n];
    bool flag[n] = {false};
    rep(i,0,n) c[i] = (char)(max(0LL, 1-i) + '0');

    rep(i,0,m){
        ll a,b;
        cin >> a >> b;

        if(flag[a-1] && ('0' + b) != c[a-1]){
            cout << -1 << endl;
            return 0;
        }
        else if(a == 1 && b == 0){
            cout << -1 << endl;
            return 0;
        }

        flag[a-1] = true;
        c[a-1] = '0' + b;
    }

    rep(i,0,n) cout << c[i];
    cout << endl;
    return 0;
}