N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
ans = [0] * N
sc.sort(key=lambda x: x[1], reverse=True)
flg = True

for i in range(M):
    ans[sc[i][0] - 1] = sc[i][1]
    if sc[i][0] == 1:
        flg = False

if N != 1 and ans[0] == 0 and not flg:
    print(-1)
elif flg:
    ans[0] = 1
    print("".join(map(str, ans)))
else:
    print("".join(map(str, ans)))