  We consider Lie(G)-valued G-invariant connections on bundles over spaces G/H,
RxG/H and R^2xG/H, where G/H is a compact nearly Kaehler six-dimensional
homogeneous space, and the manifolds RxG/H and R^2xG/H carry G_2- and
Spin(7)-structures, respectively. By making a G-invariant ansatz, Yang-Mills
theory with torsion on RxG/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
G_2-structures on RxG/H. It is shown that both G_2-instanton equations can be
obtained from a single Spin(7)-instanton equation on R^2xG/H.
