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

ans = ""
for i in range(n):
    if box[i] == -1 and i == 0:
        ans += '1'
    elif box[i] == -1:
        ans += '0'
    else:
        if i == 0 and box[i] == 0:
            print(-1)
            exit()
        ans += str(box[i])

print(ans)
