# coding: utf-8
# Your code here!
N,M=map(int,input().split())

l=[]
for _ in range(M):
   s,t=map(int,input().split())
   l.append([s,t])

for i in range(10**(N-1),10**N):
    #print(i)
    temp=list(str(i))
    judge=True
    for s,t in l:
        if temp[N-s]!=str(t):
            judge=False
    if judge:
        print(i)
        exit()

print(-1)
