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]
    


s1 = ""
for k in s:
    s1 += str(k)

s1 = int(s1)
s1 = str(s1)

spe = 0
if len(s1) != n:
    spe = 1
    


flag = 0
for i in range(1,10**n):
    if i == s1:
        flag = 1
        break

if flag == 0 or spe == 1:
    print("-1")
else:
    print(s1)
    

