N, M = map(int, input().split())
digit = ['']*N
flag = True
for _ in range(M):
    s, c = map(int, input().split())
    s-=1
    if digit[s] == '':
        digit[s] = str(c)
        continue
    elif digit[s] != str(c):
        flag = False
        break
if digit[0] == '0':
    flag = False
if not flag:
    print(-1)
else:
    if digit[0] == '':
        digit[0] = '1'
    for i in range(1, N):
        if digit[i]== '':
            digit[i] = '0'
    print(int(''.join(digit)))
