You see the input. You see the output. Go.
a b c d e f g
a g a g a g a b f b f b f b c e c e c e c d d d d d d d e c e c e c e f b f b f b f g a g a g a g