using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }


        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var cnd = new Dictionary<long, long>();
            for (var i = 0; i < M; ++i)
            {
                var sc = Sarray();
                var s = sc[0] - 1;
                var c = sc[1];
                if (s == 0 && c == 0)
                {
                    WriteLine(-1);
                    return;
                }
                if (cnd.ContainsKey(s) && cnd[s] != c)
                {
                    WriteLine(-1);
                    return;
                }
                cnd[s] = c;
            }
            var ans = new string('0', (int)N).ToCharArray();
            ans[0] = '1';
            foreach (var c in cnd)
                ans[(int)c.Key] = (char)(c.Value + '0');
            WriteLine(ans);
            //Out.Flush();
        }
    }
}