n,m,p,*a=map(int,open(0).read().split()) a.sort(reverse=True) for i in a: if i%p and i!=1: break if i%p==0 or i==1 and m!=1: print(-1) exit() print(i) x=1 j=0 while x<=m: x*=i j+=1 print(j)