import os

def main():
    AnsKeta,count = (int(x) for x in input().split())
    input_list = [0] * AnsKeta
    
    for i in range(count):
        keta,num = (int(x) for x in input().split())
        input_list[keta - 1] = num

    if input_list[0] == 0:
        print(-1)
    else:
        print(IntChange(input_list))

def IntChange(int_list):
    num = ""
    str_list = [str(n) for n in int_list]
    for i in str_list:
        num = num + i
    return int(num)


if __name__ == "__main__":
    main()