#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int n,m;
    cin >> n >> m;

    int ans[n] = {0};
    for (int i = 0; i < m; i++) {
        int s,c;
        cin >> s >> c;
        ans[s - 1] = c;
    }

    int ans1 = 0;
    for (int i = 0; i < n; i++) {
        if (i < n - 1 && ans[i] == 0) {
            cout << -1 << endl;
            return 0;
        }
        ans1 += ans[i] * pow(10, n - 1 - i);
    }

    cout << ans1 << endl;
}
