using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nm[0];
        var m = nm[1];
        var digits = new int[n];
        for (int i = 0; i < m; ++i)
        {
            var sc = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            digits[sc[0] - 1] = sc[1];
        }

        if (digits[0] == 0)
        {
            Console.WriteLine("-1");
            return;
        }

        var s = new string(digits.SkipWhile(x => x == 0).Select(x => (char)(x + '0')).ToArray());
        Console.WriteLine(s == "" ? "0" : s);
    }
}
