n, k =map(int, input().split())
data = []
for i in range(k):
    data.append(list(map(int, input().split())))
for i in range(10**(n-1), 10**n):
    a = str(i)
    tmp = True
    for i in data:
        data1 = i[0]
        data2 = i[1]
        #print(data1, data2)
        if(a[data1-1] != str(data2)):
            tmp=False
    if(tmp):print(a);exit()
print(-1)