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

