using System;
using System.IO;
using System.Text;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        int N = ScanInt(), M = ScanInt();
        Span<int> span = stackalloc int[N];
        span.Fill(-1);
        for (int i = 0; i < M; i++) {
            int s = ScanInt(), c = ScanInt();
            if (span[s - 1] == c) continue;
            if (span[s - 1] != -1 || N != 1 && s == 1 && c == 0) {
                Console.WriteLine(-1);
                return;
            }
            span[s - 1] = c;
        }
        var sb = new StringBuilder();
        for (var i = 0; i < span.Length; i++) {
            if (span[i] == -1) sb.Append(i == 0 ? 1 : 0);
            else sb.Append(span[i]);
        }
        Console.WriteLine(sb.ToString());
    }
}

public static class Scanner
{
    static readonly Stream stdin = Console.OpenStandardInput();
    static readonly byte[] buffer = new byte[1024];
    static int length, p;
    static bool isEof;
    private static byte StdIn() {
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stdin.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    public static char GetChar() {
        var by = StdIn();
        while ((by < '!' || '~' < by) && !isEof) by = StdIn();
        return (char) by;
    }
    public static int ScanInt() {
        var temp = 0;
        for (var ch = GetChar(); '0' <= ch && ch <= '9'; ch = (char) StdIn()) {
            temp = temp * 10 + ch - '0';
        }
        return temp;
    }
}