#include <bits/stdc++.h>
using namespace std;
#define rep(i, N)  for (int (i) = 0; (i) < (N); (i)++)

int main(){

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

    rep (i, N){
        cout << ans[i];
    }
    cout << endl;

    return 0;
}