N, M = map(int, input().split(' '))
rst_ls = [0] * N
rst = ''
if M == 0:
    if N == 1:
        print(0)
    else:
        rst = '1' + '0' * (N - 1)
        print(rst)
else:
    for i in range(M):
        ls = list(map(int, input().split(' ')))
        rst_ls[ls[0] - 1] = ls[1]
    for i in rst_ls:
        rst += str(i)
    rst = int(rst)
    if N == len(str(rst)):
        print(rst)
    else:
        print(-1)