N, M = map(int, input().split())
num = ['0'] * N
s1 = False
error = False

for i in range(M):
    s, c = input().split()
    if num[int(s)-1] in ['0', c]:
        num[int(s)-1] = c
        if s == '1':
            s1 = True
    else:
        error = True
        break

if (N != 1 and num[0] == '0') or error:
    print(-1)
else:
    if not s1:
        num[0] = '1'
    print(''.join(num))
