ans = [-1] * n
for i in range(m):
    if ans[sc[i][0]-1] == -1 or ans[sc[i][0]-1] == sc[i][1]:
        ans[sc[i][0]-1] = sc[i][1]
    else:
        print(-1)
        exit()
if n == 1 and ans[0] != -1:
    print(ans[0])
    exit()
if ans[0] == 0:
    print(-1)
    exit()
if n == 2 and ans[0] != -1 and ans[1] != -1:
    map_ans = map(str, ans)
    print("".join(map_ans))
elif n == 2 and ans == [-1, -1]:
    print(-1)
elif n == 2:
    ans[0] = 1
    map_ans = map(str, ans)
    print("".join(map_ans))
elif n == 3 and ans == [-1, -1, -1]:
    print(-1)
elif n == 3:
    for i in range(3):
        if i == 0 and ans[i] == -1:
            ans[i] = 1
        if ans[i] == -1:
            ans[i] = 0
    map_ans = map(str, ans)
    print("".join(map_ans))

