use strict; use warnings; my @cups = (0, 0, 0); my $n = + 0; $cups[$n-1] = 1; my $m = + 0; for(my $i = 0; $i < $m; ++$i) { my ($p, $q) = split(" ", ); #print $p, " ", $q, "\n"; $p--; $q--; ($cups[$p], $cups[$q]) = ($cups[$q], $cups[$q]); } for(my $i = 0; $i < 3; ++$i) { #print $cups[$i], "\n"; if($cups[$i] == 1) { print $i+1, "\n"; } }