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

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var nm = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var dict = new Dictionary<long, long>();
            var isEnable = true;

            for(int i = 0; i < nm[1]; i++) {
                var sc = Console.ReadLine().Split(' ').Select(q => long.Parse(q)).ToArray();
                if (dict.ContainsKey(sc[0])) {
                    isEnable = isEnable && dict[sc[0]] == sc[1];
                } else {
                    dict.Add(sc[0], sc[1]);
                }
            }

            if(dict.ContainsKey(1) && dict[1] == 0) {
                isEnable = false;
            }

            if(isEnable == false) {
                Console.WriteLine(-1);

                Console.Out.Flush();
                return;
            }

            var chars = new char[nm[0]];

            foreach(var dic in dict) {
                chars[dic.Key - 1] = dic.Value.ToString()[0];
            }

            var st = "";

            for(int i = 0; i < nm[0]; i++) {
                if(chars[i] == default(char)) {
                    if(i == 0) {
                        chars[i] = '1';
                    } else {
                        chars[i] = '0';
                    }
                }

                st += chars[i];
            }

            Console.WriteLine(st);
            Console.Out.Flush();
        }
    }
}
