#!/usr/bin/env perl use strict; use warnings; my $target = "abcdefghijklm"; my %h; my $count2 = 0; my $twoer; my $s = <>; chomp$s; for my $c (split//, $s) { $h{$c}++; if ($h{$c} >= 2) { if ($count2 == 1) { print "Impossible\n"; exit; } $count2 = 1; $twoer = $c; } if ($target !~ /$c/) { print "Impossible\n"; exit; } } if ($twoer) { for my $tch (split//, $target) { if (!exists$h{$tch}) { print "$tch\n"; exit; } } } print join("\n", split//,$target)