N, M = map(int, input().split())
test_num_min = 1*(10**N)//10
test_num_max = 1*(10**N)

test_arr = []
for i in range(test_num_min, test_num_max):
    test_arr.append(i)

suffix = 0
for i in range(M):
    s, c = map(int, input().split())
    
    for j in range(len(test_arr)):
        if str(test_arr[suffix])[s-1] != str(c):
            del test_arr[suffix]
        elif str(test_arr[suffix])[s-1] == '0':
            del test_arr[suffix]
        else:
            suffix += 1
    suffix = 0
    

if len(test_arr) > 0: print(test_arr[0])
else: print(-1)