n, m = list(map(int, input().split()))
result= [-1 for _ in range(n)]
for _ in range(m):
    s, c = list(map(int, input().split()))
    if result[s-1] == -1 or result[s -1] == c:
        result[s-1] = c
    else:
        print(-1)
        quit()
if result[0] == 0:
    if len(result) != 1:
        print(-1)
        quit()
result_str=""
for i in range(len(result)):
    if result[i] == -1:
        if i == 0:
            result[i] = 1
        else:
            result[i] = 0
    result_str += str(result[i])
print(result_str)