n, m = map(int, input().split())
res = ['0' for _ in range(n)]
for _ in range(m):
    s, c = map(int, input().split())
    if (s == 1 and c == 0) or (res[s-1] != '0' and res[s-1] != str(c)):
        print(-1)
        exit()
    else:
        res[s-1] = str(c)
if res[0] == '0':
    res[0] = '1'
print(''.join(res))