n,m = map(int,input().split())
sc = []
for i in range(m):
    sc.append(list(map(int,input().split())))
sc.sort()
for i in range(m):
    if n != 1 and sc[i][0] == 1 and sc[i][1] == 0:
        print('-1')
        exit()
for i in range(m-1):
    if sc[i][0] == sc[i+1][0]:
        if sc[i][1] != sc[i+1][1]:
            print('-1')
            exit()
   
ans = [1]
for i in range(n-1):
    ans.append(0)
 
for i in range(m):
    ans[sc[i][0]-1] = sc[i][1]
 
ans = map(str,ans)
print(''.join(ans))