# 
# Here is my solution......
# 
#!/usr/bin/perl -w
use strict;

my %keyword = ();
my $n = 1; # tracks the nth word

while( <> )
{
        chomp;
        my $i = 0;
        $_ = lc;
        while( /(....)/g ) # generate all four words sequence
        {
                pos = ++$i;
                if( exists $keyword{$1} and $keyword{$1}->[0] != $n )
                {
                        $keyword{$1}->[0] = -1; # seen more than once
                        $keyword{$1}->[1] = undef;
                }
                else
                {
                        @{$keyword{$1}} = ($n, $_);
                }
        }
        ++$n if $i > 0; # only if any sequence was found
}

open( Q, ">questions" ) or die "cannot open 'questions' file";
open( A, ">answers" ) or die "cannot open 'answers' file";

foreach ( keys %keyword )
{
        if( $keyword{$_}->[0] > 0 ) # test for < 0 below to get rejected words
        {
                print Q  "$_\n";
                print A "$keyword{$_}->[1]\n" 
        }
}

