>>700
あぁ、しまった。expand.grid()は3次元次元でも使えたのか。

>>700さんの別解。rev()を2重に使う。
as.matrix(rev(expand.grid(rev(a))))