#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int     idx = 0, dig = 0, in = 0, num = 0;
    int     ans[3] = {0, 0 ,0};
    cin >> dig >> in;
    if (in == 0)
    {
        cout << -1 << endl;
        return (0):
    }
    while (in-- > 0)
    {
        cin >> idx >> num;
        ans[idx - 1] = num;
    }
    for (int i = 0; i < dig; i++)
    {
        if (dig > 1 && ans[3 - dig] == 0)
        {
            cout << -1 << endl;
            return (0);
        }
        cout << ans[i];
    }
    cout << endl;
    return (0);
}
