#include <bits/stdc++.h>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    string A(n, '0');
    vector<bool> B(n);
    for (int i = 0; i < m; i++){
        int s, c;
        cin >> s >> c;
        s--;
        if ((B[s] and A[s] - '0' != c) or (n != 1 and s == 0 and c == 0)){
            puts("-1");
            return 0;
        }
        A[s] = c + '0';
        B[s] = true;
    }
    if (A[0] == '0' and n != 1)
        A[0] = '1';
    cout << A << endl;
}