N, M = map(int, input().split())
X = [None] * N

order_list = []

for _ in range(M):
    s, c = map(int, input().split())
    if N != 1 and s == 1 and c == 0:
        print(-1)
        exit()
    for o in order_list:
        if o[0] == s and o[1] != c:
            print(-1)
            exit()
    else:
        order_list.append([s,c])
        X[s-1] = str(c)

f = False
for i in range(N):
    if X[i] == None and f == False:
        X[i] = "1"
        f = True
    elif X[i] == None and f == True:
        X[i] = "0"
    elif X[i] != None and f == False:
        f = True

print("".join(X))