How to combine pairs of images to single images?

The code is what you make it.

http://www.imagemagick.org/Usage/montage/