#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    int n, m, f = 1;
    cin>>n>>m;
    int a[n], b[n] = {0};
    f(i,n)a[i] = 0;
    a[0] = 1;
    while(m--){
        int s, c;
        cin>>s>>c;
        s--;
        if(b[s] == 1 && c != a[s]){f = 0;continue;}
        if(b[s] == 0){
            b[s] = 1;
            a[s] = c;
        }
    }
    if(f)f(i,n)cout<<max(0ll,a[i]);
    else cout<<"-1";
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}
