import sys


N, M = map(int, input().split())
ans = [1]+[0 for _ in range(N-1)]
status = [0 for _ in range(N)]
for _ in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
        print('-1')
        sys.exit()
    if s > N:
        print('-1')
        sys.exit()

    if status[s-1] == 0:
        ans[s-1] = c 
        status[s-1] = 1
    elif status[s-1] == 1 and ans[s-1] != c:
        print('-1')
        sys.exit()

all0_flg = True
for i, a in enumerate(ans):
    if a == 0 and i == 0 and N != 1:
        for a in ans:
            if a != 0:
                print('-1')
                sys.exit()
        break
    if a != 0:
        all0_flg = False
if all0_flg == True and N != 1:
    ans[0] = 1
    

checked_ans = ''.join([str(a) for a in ans])
print(checked_ans)

