using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC157
{
    class C
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];

            int[] s = new int[M];
            int[] c = new int[M];

            Dictionary<int, int> dict = new Dictionary<int, int>();

            for (int i = 0; i < M; i++)
            {
                input = Console.ReadLine().Split().Select(int.Parse).ToArray();

                if (N != 1 && input[0] == 1 && input[1] == 0) { Console.WriteLine(-1); return; }
                if (!dict.ContainsKey(input[0])) dict.Add(input[0], input[1]);
                else
                {
                    if (dict[input[0]] != input[1]) { Console.WriteLine(-1); return; }
                }
            }

            /*
            for (int i = 0; i < M; i++)
            {
                for (int j = 0; j < M; j++)
                {
                    if (i != j && s[i] == s[j] && c[i] != c[j]) { Console.WriteLine(-1); }
                }
            }
            */
            var dict2 = dict.OrderBy(x => x.Key);
            int index = 1;
            foreach (var item in dict2)
            {
                while (item.Key != index)
                {
                    if (1 < index) Console.Write(0);
                    else Console.Write(1);
                    index++;
                }

                if (item.Key == index) Console.Write(item.Value);
                index++;
            }

            Console.WriteLine();
        }
    }
}
