# -*- coding: utf-8 -*-
N, M = map(int, input().split())
ans_list = ["X"] * N
if M == 0:
    print(int("1" + ("0" * (N - 1))))
elif N == 1:
    for i in range(M):
        s, c = map(int, input().split())
        if ans_list[s - 1] == "X" or ans_list[s - 1] == c:
            ans_list[s - 1] = c
        else:
            print(-1)
            break
    else:
        ans_list = ["0" if i == "X" else str(i) for i in ans_list]
        print(int("".join(ans_list)))
else:
    for i in range(M):
        s, c = map(int, input().split())
        if s == 1 and c == 0:
            print(-1)
            break
        elif ans_list[s - 1] == "X" or ans_list[s - 1] == c:
            ans_list[s - 1] = c
        else:
            print(-1)
            break
    else:
        ans_list = ["0" if i == "X" else str(i) for i in ans_list]
        if ans_list[0] == "0":
            ans_list[0] = "1"
        print(int("".join(ans_list)))
