N, M = map(int, input().split())
num = ['a'] * N
for i in range(M):
    s, c = map(int, input().split())
    if num[s-1] == 'a':
        num[s-1] = str(c)
    elif num[s-1] == str(c):
        continue
    else:
        num.append('B')

if num[0] == 'a':
    num[0] = '1'

for i in range(1,N):
    if num[i] == 'a':
        num[i] = '0'

if num[-1] == 'B':
    print(-1)
elif num[0] == '0':
    print(-1)
else:
    print(''.join(num) if num[-1] != 'B' else -1)