using System;

namespace Atcoder
{ 
    class Program
    {
        static void Main(string[] args)
        {
            int N, M;
            string[] input = Console.ReadLine().Split();
            N = Convert.ToInt32(input[0]);
            M = Convert.ToInt32(input[1]);
            int[] number = new int[N];
            for (int i = 0; i < M; i++)
            {
                input = Console.ReadLine().Split();
                int si = Convert.ToInt32(input[0]);
                int ci = Convert.ToInt32(input[1]);
                if (ci < 0)
                {
                    number[0] = 0;
                    break;
                }
                number[si - 1] = ci;
            }
            if (number[0] == 0 && N > 1)
            {
                Console.WriteLine("-1");
            }
            else
            {
                foreach (var digit in number)
                {
                    Console.Write(digit);
                }
            }
        }
    }
}
