## 4 December 2014

### Problem:

N people are standing in a line to take autograph from famous actress "Priyanka". People can be classified to boy, girl, man and woman. Priyanka decided that 1st she will give autograph to 1st girl in the line, then next girl and so on. Then she will follow this rule for woman, then boy and then man.Given input in form of "name classification", print the names in order of getting autograph.

### Input Format:

N
N lines in format "name classification"

### Output Format:

N lines having names

None

10
saurabh boy
shikha girl
satyam boy
kanchan girl
sameer man
sonali woman
shree man
neelabh boy
sony girl
karishma woman

shikha
kanchan
sony
sonali
karishma
saurabh
satyam
neelabh
sameer
shree

### Explanations:

girls followed by women and so on

Solution:

chomp(\$n=<STDIN>);
for(\$i=0;\$i<\$n;\$i++)
{
chomp(\$line=<STDIN>);
(\$a,\$b)=split(" ",\$line);
if(\$b eq 'girl')
{
push(@g,\$a);
}
elsif(\$b eq 'boy')
{
push(@b,\$a);
}
elsif(\$b eq 'man')
{
push(@m,\$a);
}
else
{
push(@w,\$a);
}
}
foreach(@g){print "\$_\n";}
foreach(@w){print "\$_\n";}
foreach(@b){print "\$_\n";}
foreach(@m){print "\$_\n";}

### Tips:

push names to different classifications