n, m = map(int, input().split())
s = "0" * n
flag = 0

for _ in range(m):
    a, b = map(int, input().split())

    if s[a - 1] != '0':
        if s[a - 1] != str(b):
            flag = 1
    
    s = s[:a-1] + str(b) + s[a:]

if flag == 0:
    if n == 1:
        print(s)
    elif int(s) >= 10 ** (n - 1):
        print(s)
    else:
        print(-1)
else:
    print(-1)