#include <bits/stdc++.h>
#define endl '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(var) var.begin(), var.end()
#define vi vector<int>
int const MOD = 1e9+7;
typedef long long ll;
using namespace std;
 
int main(){
    int n, m;
    cin >> n >> m;
    int num[n] = {0};
    while(m--){
        int p,q;
        cin >> p >> q;
        if(p == 1) num[0] = q;
        else if(p == 2) num[1] = q;
        else num[2] = q;
    }
    if(n > 1 && num[0] == 0) cout << "-1";
    else
        for(int i: num) cout << i;
    cout << endl;

}
