n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]
ans = -1
for i in range(10**(n-1),10**n):
    si = str(i)
    is_ans = True
    for j in range(m):
        if not si[sc[j][0]-1]==str(sc[j][1]):
            is_ans = False
    if is_ans:
        ans = i
        break
print(ans)
