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


namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);

            int[] ans = new int[n];
            for(int i = 0; i < n; i++)
            {
                ans[i] = -1;
            }

            for(int i = 0; i < m; i++)
            {
                str = Console.ReadLine().Split(' ');
                int s = int.Parse(str[0]);
                int c = int.Parse(str[1]);

                if (ans[s - 1] == -1 || ans[s - 1] == c)
                {
                    ans[s - 1] = c;
                }
                else
                {
                    Console.WriteLine(-1);
                    return;
                }
            }

            if (ans[0] == 0||n==1)
            {
                Console.WriteLine(-1);
                return;
            }

            if (ans[0] == -1) { ans[0] = 1; }
            for(int i = 0; i < n; i++)
            {
                if (ans[i] == -1) { ans[i] = 0; }
                Console.Write(ans[i]);
            }
            Console.WriteLine();


            //ここまで
        }
    }
}
