N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
ans = [0] * N

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

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