#!/usr/bin/perl

while (<>) { 
	if (rand() < 0.5) { 
		push @l,$_; 
	} else { 
		unshift @l,$_; 
	} 
} 

while (scalar(@l)) { 
	print (rand() > 0.5 ? pop @l : shift @l);
}

