N, M = map(int,input().split())

ans = [None] * N
flag = 1
for i in range(M):
    s,c = map(int,input().split())

    if (ans[s-1] != None and ans[s-1] != c):
        flag = 0
    ans[s-1] = c

tr_num = False
for i in range(N):
    if (ans[i] == 0):
        if tr_num:
           ans[i] = 0
        else:
            flag = 0
            break
    elif (ans[i]== None) and not tr_num:
        ans[i] = 1
        tr_num = True
    elif (ans[i]== None) and tr_num:
        ans[i] = 0
    else:
        tr_num = True

if flag:
    print("".join([str(x) for x in ans]))
else:
    print(-1)
