#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    string r(n, 'a');
    for(int i = 0; i < m; i++) {
        int s, c;
        cin >> s >> c;
        if(n != 1 && s == 1 && !c || r[s - 1] != 'a' && r[s - 1] != c + '0') {
            cout << -1 << endl;
            return 0;
        }
        r[s - 1] = c + '0';
    }
    for(int i = 0; i < n; i++)
        if(r[i] == 'a')
            r[i] = n > 1 ? !i + '0' : '0';
    cout << r << endl;
    return 0;
}
