import sys

N, M = map(int, input().split())

ans = ['*'] * N

if M == 0:
    if N == 1:
        print(0)
    else:
        print(10**(N-1))
else:
    for i in range(M):
        a, b = map(int, input().split())

        if ans[a-1] == '*':
            ans[a-1] = str(b)
        else:
            print(-1)
            sys.exit()

    for i in range(M):
        if ans[i] == '*' or ans[i] == '0':
            print(-1)
            sys.exit()
        else:
            print(''.join(ans).replace('*', '0'))
            sys.exit()
