def resolve():
    s_list = []
    c_list = []

    N, M = map(int, input().split())

    if M == 0:
        print('-1')
        return

    for i in range(M):
        tmp_s, tmp_c = map(int, input().split())
        s_list.append(tmp_s)
        c_list.append(tmp_c)

    for i in range(10**(N-1), 10**(N)):
        str_i = str(i)
        tmp_flag = True
        for j in range(M):
            if str_i[(s_list[j])-1] != str(c_list[j]):
                tmp_flag = False
                break
        if tmp_flag:
            print(i)
            return

    print('-1')
    return

if __name__ == "__main__":
    resolve()