from operator import itemgetter
N,M = map(int,input().split())
s = [0 for x in range(M)]
c = [0 for x in range(M)]
for i in range(M) :
    s[i],c[i] = map(int,input().split())

buf_list = ['' for x in range(N)]
buf = ''
list = [0 for x in range(N)]
#print(list)

for i in range(M) :
    list[s[i]-1] = c[i]

if list[0] == 0 :
    print(-1)
else :
    for i in range(N) :
        buf_list[i] = str(list[i])
    for i in buf_list :
        buf += i
    buf = int(buf)
    print(buf)