We consider Lie(G)-valued G-invariant connections on bundles over spaces G/H, R x G/H and R-2 x G/H, where G/H is a compact nearly K hler sixdimensional homogeneous space, and the manifolds R x G/H and R-2 x G/H carry G2-and Spin(7)-structures, respectively. By making a G-invariant ansatz, Yang-Mills theorywith torsion onR xG/H is reduced to Newtonian mechanics of a particle moving in a plane with a quartic potential. For particular values of the torsion, we find explicit particle trajectories, which obey first-order gradient or hamiltonian flow equations. In two cases, these solutions correspond to anti-self-dual instantons associated with one of two G2-structures on R x G/H. It is shown that both G2-instanton equations can be obtained from a single Spin(7)-instanton equation on R-2 x G/H.