N,M= map(int,input().split())
R = ["0"]*N
for _ in range(M):
    inp_lis = list(map(int,input().split()))
    R[inp_lis[0]-1] = str(inp_lis[1])
if R[0] == "0" and len(R) != 1:
    print(-1)
    exit()
print(''.join(map(str,R)))