#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m;
    cin >> n >> m;
    int d[n+5] = {};
    memset(d,-1,sizeof(d));
    for(int i = 0 ; i < m ; i++) {
        int x, y;
        cin >> x >> y;
        if(d[x] == -1) {
            d[x] = y;
        }
        else if(d[x] != y) {
            cout << -1 << endl;
            exit(0);
        }
    }
    if (d[1] == 0 && n != 1) {
        cout << -1 << endl;
        exit(0);
    }
    for (int i = 1 ; i <= n ; i++) {
        if(d[i] == -1) {
            if(i == 1) {
                cout << 1;
            }
            else {
                cout << 0;
            }
        }
        else {
            cout << d[i];
        }
    }
    cout << endl;
}