A rectangle has side lengths (x+1)(x+1)(x+1) cm and (x+4)(x+4)(x+4) cm and area 40 cm2. Find its dimensions.