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

namespace ABC157C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NM = Console.ReadLine().Split(' ');
            int N = int.Parse(NM[0]);
            int M = int.Parse(NM[1]);
            int[] s = new int[M];
            int[] c = new int[M];
            for(int i = 0; i < M; i++)
            {
                string[] sc = Console.ReadLine().Split(' ');
                s[i] = int.Parse(sc[0]);
                c[i] = int.Parse(sc[1]);
            }
            int[] num = new int[N];
            for (int i = 0; i < N; i++)
            {
                num[i] = -1;
            }
            bool hantei = true;
            for(int i = 0; i < M; i++)
            {
                if (num[s[i] - 1] == -1)
                {
                    num[s[i] - 1] = c[i];
                }
                else if (num[s[i] - 1] == c[i])
                {
                }
                else
                {
                    hantei = false;
                }
            }
            if (hantei == false|num[0]==0)
            {
                Console.WriteLine("-1");
            }
            else
            {
                for(int i = 0; i < N; i++)
                {
                    if (num[i] == -1)
                    {
                        if (i == 0)
                        {
                            num[i] = 1;
                        }
                        else
                        {
                            num[i] = 0;
                        }
                    }
                }
                Console.WriteLine(string.Join("", num));
            }
        }
    }
}
