N, M = [int(item) for item in input().split()]

reg_list = [[int(item) for item in input().split()] for _ in range(M)]

cand = [11 for _ in range(N)]

is_flag = False

for i, v in reg_list:
    temp = cand[i-1]
    cand[i-1] = min(v, temp)
    if temp < 11 and v != temp:
        is_flag = True
    if i == 1 and v == 0:
        is_flag = True

# print(cand)

res = ''
for j, v in enumerate(cand):
    if v == 11 and j > 0:
        res += '0'
    elif v ==11 and j == 0:
        res += '1'
    else:
        res += str(v)

if is_flag and N >1:
    print(-1)
else:
    print(res)