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