#!/usr/bin/env perl use strict; use warnings; my $s = <>; chomp$s; my @array; for my $ch (split//, $s) { push @array, $ch; } @array = sort {$a cmp $b} @array; my $one; for (my $i = 0; $i < @array - 1; $i+=2) { if ($array[$i] ne $array[$i + 1]) { if ($one) { print "Impossible\n"; exit; } $one = $array[$i]; $i--; } if ($i < @array - 2 && $array[$i] eq $array[$i + 2]) { print "Impossible\n"; exit; } } if ($one) { print $one . "\n"; } else { print $array[@array - 1] . "\n"; }