n,m = map(int, input().split())
lis = []
for i in range(m):
    lis.append(list(map(int, input().split())))
    
s =[0]*n
for j in lis:
    s[j[0]-1] = j[1]
    
stli = ""
for i in s:
    stli += str(i)

flag = 0
for k in range(10**n):
    if str(k) == stli:
        flag = 1
        break

if flag:
    print(stli)
else:
    print(-1)