N, M = map(int, input().split())
arr=[10]*N

for i in range(M):
    X, Y = map(int, input().split())
    if arr[X-1] != 10 and arr[X-1] != Y:
        print('-1')
        exit()
    else:
         arr[X-1] = Y

for i in range(N):
    if arr[i] == 10:
        arr[i] = 0

if arr[0] ==0:
    arr[0] = 1
    
print(''.join(map(str, arr)))