n,m= map(int, input().split())
s= [list(map(int, input().split())) for i in range(m)]



flag=True
if n==1:
    for i in range(10):
        x = str(i)
        flag=True
        for j in range(m):
            if x[s[j][0] - 1] != str(s[j][1]):
                flag = False

        if flag:
            print(x)
            exit()
    print(-1)



for i in range(10**(n-1),10**n):
    x=str(i)
    flag=True
    for j in range(m):
        if x[s[j][0]-1]!=str(s[j][1]):
            flag=False

    if flag:
        print(x)
        exit()

print(-1)