设集合A={a,a+d,a+2d},B={a,aq,aq2},若a,d,q∈R,且A=B,求q的值