using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;
using System.Numerics;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x, long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }
        public static long keta(long x)
        {
            var z = 1;
            while (x > 0)
            {
                x /= 10;
                z++;
            }
            return z;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var nm = Reads();
            var n = nm[0];
            var m = nm[1];
            var ans = new long[n];
            for (int i = 0; i < n; i++)
            {
                ans[i] = 10;
            }
            bool f = false;
            for (int i = 0; i < m; i++)
            {
                var sc = Reads();
                if (ans[sc[0] - 1] != 10 && (ans[sc[0] - 1] != sc[1])) f = true;
                else if (n!=1&&sc[0] == 1 && sc[1] == 0) f = true;
                else ans[sc[0] - 1] = sc[1];
            }


            if (f) WriteLine("-1");
            else
            {
                for (int i = 0; i < n; i++)
                {
                    if (i == 0)
                    {
                        if (ans[i] == 10)
                            Write(1);
                        else
                            Write(ans[i]);
                    }
                    else
                    {
                        if (ans[i] != 10)
                            Write(ans[i]);
                        else
                            Write(0);
                    }
                }
                WriteLine();
            }












          
            Console.Out.Flush();
        }
    }
}

