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

class Program
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine();
        var digit = int.Parse(l.Split(' ')[0]);
        var num = int.Parse(l.Split(' ')[1]);
        //line.Split(' ');
        var flag = true;

        if(num == 0)
        {
            if(digit == 1)
            {
                Console.WriteLine(0);
            }
            else
            {
                var s = "1";
                for(var i = 2; i < digit + 1; i++)
                {
                    s += "0";
                }
                Console.WriteLine(s);
            }
            return;
        }


        var dict = new Dictionary<int, int>();
        for(var i = 0; i < num; i++)
        {
            var line = Console.ReadLine();
            var digitPlace = int.Parse(line.Split(' ')[0]);
            var digitNum = int.Parse(line.Split(' ')[1]);

            if (!dict.ContainsKey(digitPlace))
            {
                dict.Add(digitPlace, digitNum);
            }
            else
            {
                if(dict[digitPlace] != digitNum)
                {
                    flag = false;
                    break;
                }
            }
        }
        var str = "";

        if (flag)
        {
            for(var i = 1; i < digit + 1; i++)
            {
                if(i == 1 && dict[1] == 0 && digit != 1)
                {
                    Console.WriteLine(-1);
                    break;
                }

                if (dict.ContainsKey(i))
                {
                    str += dict[i];
                }
                else
                {
                    if(i == 1)
                    {
                        str += "1";
                    }
                    else
                    {
                        str += "0";
                    }
                }
            }

            Console.WriteLine(str);
        }
        else
        {
            Console.WriteLine(-1);
        }

        //Console.ReadKey();
    }
}

