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

namespace ConsoleApp15
{
    class Class73
    {
        static void Main()
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NM[0], M = NM[1];
            char[] S = new char[NM[0]];
            for (int i = 0; i < S.Length; i++) S[i] = 'x';
            bool imp = false;
            for(int i = 0; i < M; i++)
            {
                var sc = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int s = sc[0] - 1, c = sc[1];
                

                    if (S[s] == 'x' || S[s] == c.ToString()[0])
                    {
                        S[s] = c.ToString()[0];
                    }
                    else imp = true;
                
            }
            if (S[0] == '0'&&!(N==1)) imp = true;
            if (N == 1 | S[0] == 'x') S[0] = '0';
            if (S[0] == 'x') S[0] = '1';
            
            for(int i = 1; i < N; i++)
            {
                if (S[i] == 'x') S[i] = '0';
            }
            Console.WriteLine(imp ? "-1" : $"{string.Join("",S)}");
        }
    }
}
