n,m=map(int,input().split())

r=""
for i in range(n):
    if i == 0:r += '1'
    else : r+='0'
r = list(r)

k ={}
for _ in range(m):
    x,y = map(int,input().split())

    if x == 1 and y == 0: print('-1');exit()

    if k.get(x) and k[x] != y: print('-1');exit()
    else: k[x] = y

for i,j in k.items():
    r[i-1] = j

for i in r:print(i,end='')