n,m = map(int,input().split())
L = [0]*n
li = []
flag = True
for i in range(m):
    a,b = map(int,input().split())
    if a in li:
        if L[a-1] != b:
            flag = False
            break
    elif n > 1 and a == 1 and b == 0:
        flag = False
        break
    else:
        L[a-1] = b
        li.append(a)

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