n, m = map(int, input().split())
ans = [-1 for _ in range(n)]
flag = 0
for k in range(m):
    s, c = map(int, input().split())
    if (ans[s - 1] == -1) or (ans[s - 1] == c):
        ans[s - 1] = c
    else:
        print(-1)
        flag = 1
        break

if flag == 0:
    anss = []
    flag = 1
    for a in ans:
        if a != -1:
            anss.append(a)
            flag = 0
        else:
            if flag == 0:
                anss.append(0)
            else:
                anss.append(1)
                flag = 0
    if anss[0] == 0:
        if len(anss) == 1:
            print(0)
        else:
            print(-1)
    else:
        print("".join(map(str, anss)))