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

namespace atcoder
{
    class Program
    {
        static bool[] cardState = new bool[9];
        static int[] card = new int[9];
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            var n = nm[0];
            var m = nm[1];

            var result = new int[n];
            for (var i = 0; i < n; i++)
            {
                result[i] = -1;
            }

            for (var i = 0; i < m; i++)
            {
                var sc = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
                var s = sc[0] - 1;
                var c = sc[1];
                if (result[s] != -1 && result[s] != c)
                {
                    Console.WriteLine(-1);
                    return;
                }
                result[s] = c;
            }

            for (var i = 0; i < n; i++)
            {
                if (i == 0)
                {
                    if (result[i] == 0)
                    {
                        Console.WriteLine(-1);
                        return;
                    }
                    else if (result[i] == -1)
                    {
                        result[i] = 1;
                    }
                }
                else
                {
                    if (result[i] == -1)
                    {
                        result[i] = 0;
                    }
                }
            }

            for (var i = 0; i < n; i++)
            {
                Console.Write(result[i]);
            }
        }
    }
}