##
use strict;
use warnings;
my %hash;
while(){
chomp;
$hash{$_}++ for split;
}
print join $/ => sort keys %hash;
print $/,$/, join $/ => grep {$_ if $hash{$_} > 1} sort keys %hash;
__DATA__
teacher students professor students
school class teacher desk table
chalk borad class school teacher
##
##
borad
chalk
class
desk
professor
school
students
table
teacher
##
##
class
school
students
teacher