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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int degitCnt = int.Parse(input[0]);
            int queryCnt = int.Parse(input[1]);

            List<List<string>> dataList = new List<List<string>>();
            for (int loop = 0; loop < queryCnt; loop++)
            {
                dataList.Add(Console.ReadLine().Split(' ').ToList());
            }

            List<string> pro = new List<string>();
            List<string> pro2 = new List<string>();
            string[] ans = new string[degitCnt];
            foreach (List<string> data in dataList) {
                ans[int.Parse(data[0]) - 1] = data[1];
                if (pro.Contains(data[0]) && !pro2.Contains(data[0] + " " + data[1])) { 
                    Console.WriteLine("-1");
                    Console.ReadLine();
                    return;
                }
                pro.Add(data[0]);
                pro2.Add(data[0] + " " + data[1]);
            }

            for (int loop = 0; loop < ans.Count(); loop++) {
                if (ans[loop] == null || ans[loop] == "") {
                    if (loop == 0)
                    {
                        ans[loop] = "1";
                    }
                    else { 
                        ans[loop] = "0";
                    }
                }
            }
            if (ans[0] == "0" && ans.Count() != 1) {
                Console.WriteLine("-1");
            Console.ReadLine();
                return;
            }

            Console.WriteLine(string.Join("", ans));
            Console.ReadLine();
        }
    }
}
