n, m = map(int, input().split())
# S = [None] * m
# C = [None] * m
dic = {}
for i in range(m):
    s, c = map(int, input().split())
    try:
        _ = dic[s]
    except KeyError:
        dic[s] = c
    else:
        if (dic[s] != c):
            print(-1)
            exit()

ans = '0' * n
for k, v in dic.items():
    ans = ans[:k - 1] + str(v) + ans[k:]

if (dic[1] == 0 and ans[0] == '0'):
    print(-1)
    exit()
elif (dic[1] == 0):
    ans = '1' + ans[1:]

print(ans)
