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

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var M = vals[1];

        var num = new char[N];
        var ok = true;
        for (int i = 0; i < M; i++)
        {
            vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var s = vals[0] - 1;
            var c = vals[1].ToString()[0];
            if (num[s] != 0 && num[s] != c)
            {
                ok = false;
            }
            num[s] = c;
        }

        if (!ok || (num[0] == '0' && N > 1))
        {
            Console.WriteLine(-1);
            return;
        }

        for (int i = 0; i < N; i++)
        {
            if (num[i] == 0)
            {
                if (i == 0)
                {
                    num[i] = '1';
                }
                else
                {
                    num[i] = '0';
                }
            }
        }

        Console.WriteLine(num);
    }
}