N, M = map(int, input().split())
num = ['*' for _ in range(N)]


for _ in range(M):
    s, c = input().split()
    s = int(s)

    if num[s-1] != '*' and num[s-1] != c:
        print('-1')
        exit()
    else:
        num[s-1] = c

if len(num) == 1 and num[0] == '0':
    print('0')
    exit()

if num[0] == '0':
    print('-1')
    exit()

for i in range(N):
    if num[i] == '*':
        if i == 0:
            print('1', end='')
        else:
            print('0', end='')
    else:
        print(num[i], end='')

print('')
