#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    vector <ll> num;
    vector <bool> used;
    REP(i, n){
        used.push_back(false);
        if (i==n-1){
            num.push_back(1);
        } else {
            num.push_back(0);
        }
    }
    ll m; cin >> m;
    REP(i, m){
        ll s; cin >> s; s--;
        ll c; cin >> c;
        if (used[s] && (num[s] != c)){
            cout << -1 << endl;
            return 0;
        }
        used[s] = true;
        num[s] = c;
    }
    ll ans = 0;
    REP(i, n){
        ans += pow(10, n-i-1) * num[i];
    }
    if (ans < pow(10, n-1)){
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    dumparr(num)
    return 0;
}