#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int n, m, i, c, s;
    cin >> n >> m;
    int a[n] = {};
    for(i=0; i<n; i++){
        a[i] = -1;
    }
    for(i=0; i<m; i++){
        cin >> s >> c;
        if(a[s-1] != -1){
            cout << -1;
            return 0;
        }else if(n > 1 && s == 1 && c == 0){
            cout << -1;
            return 0;
        }else{
            a[s-1] = c;
        }
    }
    for(i=0; i<n; i++){
        if(a[i] == -1 && i == 0){
            cout << 1;
        }else if(a[i] == -1){
            cout << 0;
        }else{
            cout << a[i];
        }
    }
    return 0;
}