#!/usr/bin/perl -w

open F, "cat $ARGV[0] |";
my (%soure, $root, @tmp);
while (<F>) {
  @tmp = split (' ', lc $_);
  if (length($tmp[0]) eq 4) {
    $root = substr $tmp[0], 0, 2;
    $root .= substr $tmp[0], 3, 1;
  }
  else {
    $root = $tmp[0];
  }
  if (exists($source{$root})) {
    if ($source{$root} =~ m/$tmp[1]/) { 
    }
    else {
      $source{$root} .= " $tmp[1]";
    }
  }
  else {
    $source{$root} = $tmp[1];
  }
}
close F;


foreach $first ( sort keys %source) {
  @tmp = split (' ', $source{$first});
  foreach $word (@tmp) {
    print "$first $word\n";
  }
}
