
def main():
    N,M = map(int,input().split())
    s = []
    c = []
    for _ in range(M):
        S, C = map(int,input().split())
        s.append(S)
        c.append(C)

    for i  in range(10**(N-1),10**(N)):
        str_i = str(i)
        hantei = 1
        for m in range(M):
            if str_i[s[m]-1] != str(c[m]):
                hantei =0

        if hantei == 1:
            print(i)
            exit()
    print(-1)


if __name__ =="__main__":
    main()