N,M= map(int,input().split())
R = [0]*N
L = [str(x) for x in range(1,1000)]
for _ in range(M):
    inp_lis = input().split()
    R[int(inp_lis[0])-1] = inp_lis[1]
R = ''.join(map(str,R))
if R not in L:
    print(-1)
    exit()
print(R)