main=interact$unwords.($[0..]).zipWith((!!).cycle.words).filter(>"").lines