n = []

N, M = list(map(int, input().split()))
for i in range(N):
    n.append('W')

for i in range(M):
    s, c = list(map(int, input().split()))
    s -= 1
    if n[s] == "W":
        n[s] = c
    elif n[s] == c:
        pass
    else:
        print(-1)
        exit()
        
if N != 0:
    if n[0] == 0:
        print(-1)
    
    if n[0] == "W":
        n[0] == 1
        
    for i in range(N):
        if n[i] =="W":
            n[i] = 0

else:
    if n[0] == -1:
        n[0] = 0
        
print(''.join(map(str,n)))