#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001
#define MOD 1000000007

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    int N, M;
    cin >> N >> M;
    int flag = 1;
    vector<int> ans(N,-1);
    rep(i,M){
        int s,c;
        cin >> s >> c;
        if(s == 1 && c == 0) flag = 0;
        if(N < s) flag = 0;
        if(ans[s-1] == -1) ans[s-1] = c;
        else{
            if(ans[s-1] != c) flag = 0;
        }
    }
    if(flag)rep(i,N){
        if(ans[i] == -1 && i == 0) cout << 1;
        else if(ans[i] == -1) cout << 0;
        else cout << ans[i];
    }
    else cout << -1;
    cout << endl;
}
