import sys
N, M = map(int, input().split())
ls = ['' for i in range(N)]

for i in range(M):
    s, c = map(int, input().split())
    if ls[s-1] == '':
        ls[s-1] = str(c)
    elif ls[s-1] != str(c):
        print(-1)
        sys.exit()

if ls[0] == '0' and len(ls) == 1:
    print(0)
    sys.exit()
elif ls[0] == '0' and len(ls) != 1:
    print(-1)
    sys.exit()

for i, x in enumerate(ls):
    if i == 0 and ls[i] == '':
        ls[i] = '1'
    elif i != 0 and ls[i] == '':
        ls[i] = '0'
print(''.join(ls))