n, num = map(int, input().split())

ans = [-1 for i in range(n)]

flag = True

for i in range(num):
    s, c = map(int, input().split())
    s -= 1
    if ans[s] == -1 or ans[s] == c:
        ans[s] = c
    else:
        flag = False

if flag and ans[0] != 0:
    if ans[0] == -1:
        ans[0] = 1
    for i, x in enumerate(ans):
        if x == -1:
            ans[i] = 0
    print("".join(map(str, ans)))
else:
    print(-1)