N,M = map(int, input().split())
sc = []
for i in range(M):
    sc.append(tuple(map(int, input().split())))

dp = [0] * N
for s,c in sc:
    dp[s-1] = c

if dp[0] == 0:
    print('-1')
    exit()

print(''.join(map(str, dp)))