function Main(input) {
    const lines = input.split("\n");
    const [n, m] = lines.shift().split(' ').map(v => +v);

    let result = Array(n).fill(false);

    try {
        lines.forEach(l => {
            let [s, c] = l.split(' ');
            s -= 1;
            if (result[s] !== false && result[s] != c) {
                throw 0;
            }
            result[s] = c;
        });
        if (result[0] === '0') throw 0;
        if (result[0] === false) result[0] = 1;
        result = result.map(v => v === false ? 0 : v);
        console.log(result.join(''));
    } catch (_) {
        console.log(-1);
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));