n,m = map(int,input().split())
lst = [-1 for _ in range(n)]
for i in range(m):
    s,c = map(int,input().split())
    if lst[s-1] != -1:
        if lst[s-1] != c:
            print(-1)
            exit()
    else:
        lst[s-1] = c
if lst[0] == 0 and n != 1:
    print(-1)
    exit()
if lst[0] == -1:
    lst[0] = 1
for i in range(n):
    if lst[i] == -1:
        lst[i] = 0
    lst[i] = str(lst[i])
print("".join(lst))