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

namespace abc157_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = CIn.ReadInt();
            var M = CIn.ReadInt();
            var s = new int[M];
            var c = new int[M];
            
            for(var i = 0; i < M; i++)
            {
                s[i] = CIn.ReadInt();
                c[i] = CIn.ReadInt();
            }
            for(var ans = Math.Pow(10,N - 1); ans < Math.Pow(10,N); ans++)
            {
                var S = ans.ToString();
                var flag = true;
                for(var i = 0; i < M; i++)
                {
                    if (S[s[i] - 1] != c[i] + '0')
                    {
                        flag = false;
                        break;
                        
                    }
                }
                if (flag == true)
                {
                    Console.WriteLine(ans);
                    return;
                }
            }
            Console.WriteLine("-1");
        }
    }
    class CIn
    {
        private static readonly Queue<string> fieldBuffer = new Queue<string>();

        public static string Read()
        {
            if (fieldBuffer.Count == 0)
            {
                foreach (var field in Console.ReadLine().Split())
                {
                    fieldBuffer.Enqueue(field);
                }
            }

            return fieldBuffer.Dequeue();
        }

        public static int ReadInt() => int.Parse(Read());
        public static long ReadLong() => long.Parse(Read());
        public static double ReadDouble() => double.Parse(Read());

        public static string[] ReadStringArray(long n)
        {
            var array = new string[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = Read();
            }

            return array;
        }

        public static int[] ReadIntArray(long n)
        {
            var array = new int[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadInt();
            }

            return array;
        }

        public static long[] ReadLongArray(long n)
        {
            var array = new long[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadLong();
            }

            return array;
        }
        public static double[] ReadDoubleArray(long n)
        {
            var array = new double[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadDouble();
            }

            return array;
        }
    }

}
