#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



int main(){
    int n, m;
    cin >> n >> m;

    vector<P> p;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        p.emplace_back(a, b);
    }

    if(n == 1){
        bool f = true;
        rep(i, m){
            int fst = p[j].first, snd = p[j].second;
            if(now[fst - 1] - '0' != snd)f = false;
        }
        if(f){
            cout << 0;
            return 0;
        }
    }
    for(int i = pow(10, n - 1); i < pow(10, n); i++){
        string now = to_string(i);
        bool f = true;
        rep(j, m){
            int fst = p[j].first, snd = p[j].second;
            if(now[fst - 1] - '0' != snd)f = false;
        }
        if(f){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1;
}

