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

class Program
{
    static void Main()
    {
        var nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        var sc = new int[m][];

        for (int i = 0; i < m; i++)
        {
            sc[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        //if (sc.Any(x => sc.Any(y => y[0] == x[0] && y[1] != x[1])))
        //{
        //    Console.WriteLine("-1");
        //    return;
        //}

        var ansString = new string[n];

        for (int i = 0; i < n; i++)
        {
            var digit = sc.FirstOrDefault(x => x[0] == i + 1);
            if (digit != null)
            {
                ansString[i] = digit[1].ToString();
            }
            else
            {
                ansString[i] = "0";
            }
        }

        var ans = int.Parse(string.Join("", ansString));

        if (ans >= Math.Pow(10, n - 1))
        {
            Console.WriteLine(ans);
        }
        else
        {
            Console.WriteLine("-1");
        }
    }
}