n, m = map(int, input().split())
answer = [-1] * n
out = False
for i in range(m):
    s, c = map(int, input().split())
    if(s == 1 and c == 0):
        out = True
        break
    elif(answer[s-1] != -1 and answer[s-1] != c):
        out = True
        break
    answer[s-1] = c

if out:
    print(-1)
else:
    if(answer[0] == -1):
        answer[0] = 1
    for i in range(1, len(answer)):
        if(answer[i] == -1):
            answer[i] = 0
    print("".join(str(e) for e in answer))
