#!/bin/sh

# m -- switch first and last line (move)

read first
mid=
last=
while read line; do
	mid="$mid$last"
	last="
$line"
done
echo "$last" | tr -d '
'
echo "$mid"
echo "$first"