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

tmp = 0
string_list.sort()

if(len(string_list) >= 1):
    for i in range(len(string_list)-1):
        if(string_list[i][0] == string_list[i+1][0]):
            if(string_list[i][1] != string_list[i+1][1]):
                tmp = 1
        elif(string_list[i][0] > n[0]):
            tmp = 1
    if(string_list[0][0] == 1 and string_list[0][1] == 0):
        tmp = 1



def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

string_list2 = get_unique_list(string_list)

t = 0

#条件がないときの0,10,100,1000...のprint
if(len(string_list) == 0):
    if(n[0] == 1):
        print(0)
    else:
        print(1, end="")
        for i in range(n[0]-1):
            print(0, end="")

if(tmp == 0):
    for i in range(n[0]):
        if(t < len(string_list2)):
            if(string_list2[t][0] == i+1):
                print(string_list2[t][1], end="")
                t += 1
            elif(t == 0 and  i == 0):
                print(1, end="")
            else:
                print(0, end="")
else:
    print(-1)