n,m = map(int,input().split())
L = [-1]*n
lia,lib = [],[]
flag = True

for i in range(m):
    a,b = map(int,input().split())
    lia.append(a-1)
    lib.append(b)

for i in range(len(lia)):
    if L[i] == -1:
        L[lia[i]] = lib[i]

if n == 1:
    if L[0] != -1:
        print(L[0])
        exit()
else:
    if L[0] == 0:
        print(-1)
        exit()
    elif L[0] == -1:
        L[0] = 1
    
for i in range(n):
    if L[i] == -1:
        L[i] = 0
L = [str(x) for x in L]
print("".join(L))