
n,m = map(int,input().split())
if m == 0:
    if n == 1:
        print(0)
        exit()
    else:
        print(-1)
        exit()
 
lists = [list(map(int,input().split())) for i in range(m)]
for i in range((10**3) + 1):
    num = str(i)
    flag = False
    if len(num) == n:
        for s,c in lists:
            if num[s-1] == str(c):
                flag = True
            else:
                flag = False
                break
        if flag:
            print(num)
            exit()
print(-1)