n, m = map(int, input().split())
ans = ['0'] * n
for i in range(m):
    s, c = input().split()
    s = int(s)
    if s == 1 and c == '0':
        print(-1)
        break
    if ans[s-1] not in ['0', c]:
        print(-1)
        break
    ans[s-1] = c
else:
    if ans[0] == '0':
        ans[0] = '1'
    print(''.join(ans))