int main()
{
	int n , k , i , j ;
	char sex[10] ;
	double h ;
	double maleH[40] , femaleH[40] ;
	cin >> n ;
	int numM = 0 ;
	int numF = 0 ;
	for ( k = 0 ; k < n ; k++ )
	{
		cin >> sex ;
		cin >> h ;
		if ( sex[0] == 'm' )
		{
			maleH[numM] = h ;
			numM++ ;
		}
		else if ( sex[0] == 'f' )
		{
			femaleH[numF] = h ;
			numF++ ;
		}
	}
	double t = 0 ;
	for ( i = 0 ; i < numF - 1 ; i++ )
	{
		for ( j = 0 ; j < numF - i - 1 ; j++ )
		{
			if ( femaleH[j] < femaleH[j+1] )
			{
				t = femaleH[j] ;
				femaleH[j] = femaleH[j+1] ;
				femaleH[j+1] = t ;
			}
		}
	}
	for ( i = 0 ; i < numM - 1 ; i++ )
	{
		for ( j = 0 ; j < numM - i - 1 ; j++ )
		{
			if ( maleH[j] > maleH[j+1] )
			{
				t = maleH[j] ;
				maleH[j] = maleH[j+1] ;
				maleH[j+1] = t ;
			}
		}
	}

	for ( i = 0 ; i < numM ; i++ )
	{
		cout << fixed << setprecision(2) << maleH[i] << " " ;
	}
	for ( i = 0 ; i < numF ; i++ )
	{
		if ( i == numF - 1 )
		{
			cout << fixed << setprecision(2) << femaleH[i] ;
		}
		else
		{
			cout << fixed << setprecision(2) << femaleH[i] << " " ;
		}
	}
	return 0 ;
}


void mysort1(float array[],int length)
{
	int i=0,j=0;
	int tmpindex=0;
	double tmpvalue;
	for(i=0;i<length;i++)
	{
		tmpindex=i;
		for(j=i;j<length;j++)
		{
			if(array[j]<array[tmpindex])
			tmpindex=j;
		}

		tmpvalue=array[tmpindex];
		array[tmpindex]=array[i];
		array[i]=tmpvalue;
	}
}

void mysort2(float array[],int length)
{
	int i=0,j=0;
	int tmpindex=0;
	double tmpvalue;
	for(i=0;i<length;i++)
	{
		tmpindex=i;
		for(j=i;j<length;j++)
		{
			if(array[j]>array[tmpindex])
			tmpindex=j;
		}

		tmpvalue=array[tmpindex];
		array[tmpindex]=array[i];
		array[i]=tmpvalue;
	}
}

int main()
{
	int n,i=0,j=0,k,m;
	float marr[40];
	float farr[40];
	char str[8];
	float height;
	scanf("%d",&n);

	for(k=0;k<n;k++)
	{
		scanf("%s%f",str,&height);
		if(strcmp(str,"male")==0)
	   {
		  marr[i]=height;

		  i++;

	   }
		else
		{
		farr[j]=height;

		j++;
		}

	}

	mysort1(marr,i);
	mysort2(farr,j);

	for(m=0;m<i;m++)
	printf("%.2f ",marr[m]);

	for(m=0;m<j-1;m++)
	printf("%.2f ",farr[m]);

	printf("%.2f",farr[j-1]);

		return 0;
}


int cmpf(void const *a,void const *b)
{
	double m;
	m=*(double *)b-*(double *)a;
	if (m>0) return 1;
	else return -1;
}
int cmpm(void const *a,void const *b)
{
	double m;
	m=*(double *)a-*(double *)b;
	if (m>0) return 1;
	else return -1;
}
int main()
{
	int n,i;
	double	f[40],m[40];
	int fp=0,mp=0;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		char s[7];
		scanf("%s",s);
		if (s[0]=='f')
			scanf("%lf",&f[fp++]);
		else
			scanf("%lf",&m[mp++]);
	}
	qsort(f,fp,sizeof(double),cmpf);
	qsort(m,mp,sizeof(double),cmpm);

	for (i=0;i<mp;i++)
		printf("%.2lf ",m[i]);

	for (i=0;i<fp;i++)
	{
		printf("%.2lf",f[i]);
		if (i!=fp-1)
            printf(" ");
	}
}


void main()
{
	int num,i,j=0,k=0,m,n;
	float hight[N],hi,woman[N],man[N];
	char string1[5]="male";
	char string[N][7];
	scanf("%d",&num);
	for(i=0;i<num;i++)
	{
		scanf("%s %f",string[i],&hight[i]);
		if(strcmp(string[i],string1)==0)
		{
			man[j]=hight[i];
		    j=j+1;
		}
		else
		{
			woman[k]=hight[i];
			k=k+1;
		}
	}
	for(i=0;i<j;i++)
		for(m=i;m<j;m++)
		{
			if(man[i]>man[m])
			{
				hi=man[i];
				man[i]=man[m];
				man[m]=hi;
			}
		}
	for(i=0;i<k;i++)
		for(n=i;n<k;n++)
		{
			if(woman[i]<woman[n])
			{
				hi=woman[n];
				woman[n]=woman[i];
				woman[i]=hi;
			}
		}
		for(i=0;i<j;i++)
			printf("%4.2f ",man[i]);
		for(i=0;i<k-1;i++)
			printf("%4.2f ",woman[i]);
		printf("%4.2f",woman[k-1]);
		printf("\n");
}


int main()
{
	int n,i,j,k,nmale=0,nfemale=0;
	char s[40][7];
	double a[40],e;
	double male[40],female[40];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s%lf",s[i],&a[i]);
	}
	for(i=0;i<n;i++)
	{
		if(strcmp(s[i],"male")==0)
		{
			male[nmale]=a[i];
			nmale++;
		}
		else
		{
			female[nfemale]=a[i];
			nfemale++;
		}
	}
	for(j=0;j<nmale;j++)
	{
		for(k=0;k<nmale-j-1;k++)
		{
			if(male[k]>male[k+1])
			{
				e=male[k];
				male[k]=male[k+1];
				male[k+1]=e;
			}
		}
	}
	for(j=0;j<nfemale;j++)
	{
		for(k=0;k<nfemale-j-1;k++)
		{
			if(female[k]<female[k+1])
			{
				e=female[k];
				female[k]=female[k+1];
				female[k+1]=e;
			}
		}
	}
	for(j=0;j<nmale;j++)
	{
		if(j==0)
		{
			printf("%.2lf",male[j]);
		}
		else
		{
			printf(" %.2lf",male[j]);
		}
	}
	for(j=0;j<nfemale;j++)
	{
		printf(" %.2lf",female[j]);
	}
	return 0;
}


double male[41];
double female[41];
int cmp_male(const void *a,const void *b)
{

	return *(double *)a - *(int *)b;
}
int cmp_female(const void *a,const void *b)
{
	return *(double *)b - *(double *)a;
}

int main()
{
	int n,i,mi=0,fi=0;
	double h;
	char tmp[10];

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %lf",&tmp,&h);
		if(tmp[0] == 'm')
		{
			male[mi] = h ;
			mi++;
		}
		else
		{
			female[fi] = h;
			fi++;
		}
	}
	sort(male,male + mi);
	sort(female,female + fi);
	for(i=0;i<mi;i++)
		printf("%.2lf ",male[i]);
	for(i=fi-1;i>=0;i--)
	{
		if(i==0)
			printf("%.2lf",female[i]);
		else
			printf("%.2lf ",female[i]);
	}

	printf("\n");
	return 0;
}


int compare(const void *a,const void *b)
{
	if(*(float*)a>*(float*)b)return 1;
	if(*(float*)a<*(float*)b)return -1;
	if(*(float*)a==*(float*)b)return 0;
}
int main()
{
	int N,i,v,t,j;
	float r;
	scanf("%d",&N);
	struct kids
	{
		char s[10];
		float h;
	}kid[40];
	char c;
	for(i=0;i<=N-1;i++)
	{
		scanf("%s ",kid[i].s);
		scanf("%f",&kid[i].h);
	}
	float hm[40],fm[40];
	for(i=0,t=0,v=0;i<=N-1;i++)
	{
		if(strcmp(kid[i].s,"male")==0)
		{
			hm[t]=kid[i].h;
			t=t+1;
		}
		if(strcmp(kid[i].s,"female")==0)
		{
			fm[v]=kid[i].h;
			v=v+1;
		}

	}
	//int *p=(float*)malloc(N*sizeof(float));

	//qsort(hm,t,sizeof(hm[0]),compare);
	for(i=1;i<=t-1;i++)
	{
		for(j=0;j<=t-i-1;j++)
		{
			if(hm[j]>=hm[j+1])
			{
				r=hm[j];
				hm[j]=hm[j+1];
				hm[j+1]=r;
			}
		}
	}
	for(i=1;i<=v-1;i++)
	{
		for(j=0;j<=v-i-1;j++)
		{
			if(fm[j]<=fm[j+1])
			{
				r=fm[j];
				fm[j]=fm[j+1];
				fm[j+1]=r;
			}
		}
	}
	printf("%.2f",hm[0]);
	for(i=1;i<=t-1;i++)
	{
		printf(" %.2f",hm[i]);
	}
	//qsort(fm,v,sizeof(fm[0]),compare);
	//printf("%.2f",fm[0]);
	for(i=0;i<=v-1;i++)
	{
		printf(" %.2f",fm[i]);
	}

}


int main() {
	int n;
	scanf("%d\n",&n);
	char ren[40][7];
	double sg[40];
	int i,j;
	for(i=0;i<n;i++){
		scanf("%s %lf",&ren[i],&sg[i]);
	}
	double nssg[40];
	double vssg[40];
	double e;
	int m,t;
	m=0;
	t=0;
	for(i=0;i<n;i++){
		if(ren[i][0]=='m'){
			nssg[m]=sg[i];
			m++;
		}else{
			vssg[t]=sg[i];
			t++;
		}
	}
	for(i=1;i<=m;i++){
		for(j=0;j<m-i;j++){
			if(nssg[j]>nssg[j+1]){
				e=nssg[j+1];
				nssg[j+1]=nssg[j];
				nssg[j]=e;
			}
		}
	}
	for(i=1;i<=t;i++){
		for(j=0;j<t-i;j++){
			if(vssg[j]>vssg[j+1]){
				e=vssg[j+1];
				vssg[j+1]=vssg[j];
				vssg[j]=e;
			}
		}
	}
	for(i=0;i<m;i++){
		printf("%.2lf ",nssg[i]);
	}
	for(i=t-1;i>0;i--){
		printf("%.2lf ",vssg[i]);
	}
	printf("%.2lf\n",vssg[0]);
	return 0;
}


double male[42]={0};
double female[42]={0};
int m=0;
int f=0;
int main()
{
	int n;
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++)
	{
		char temp[10];
		double templen;
		scanf("%s",temp);
		scanf("%lf",&templen);
		if(temp[0]=='m')
		{
			male[m]=templen;
			m++;
		}
		else
		{
			female[f]=templen;
			f++;
		}
	}
	sort(male,male+m);
	sort(female,female+f);
	reverse(female,female+f);
	for(i=0;i<m;i++)
	{
		printf("%.2lf ",male[i]);
	}
	for(i=0;i<f-1;i++)
	{
		printf("%.2lf ",female[i]);
	}
	printf("%.2lf\n",female[i]);
	return 0;
}


main()
{
      int n,i,j,x;
      float t;
      struct person
      {
             char sex[6];
            float h;
      };
      scanf("%d",&n);
      struct person per[40];
      for(i=0;i<n;i++)
      {
                      scanf("%s",per[i].sex);
                      scanf("%f",&per[i].h);
      }
      for(i=0;i<n;i++)
      {if(strcmp(per[i].sex,"female")==0)
      continue;
                      for (j=i+1;j<n;j++)
                      {
                         if(strcmp(per[j].sex,"female")==0)
                         continue;
                         if(per[i].h>per[j].h)
                         {
                                     t=per[i].h;
                                     per[i].h=per[j].h;
                                     per[j].h=t;
                         }
                      }
                      printf("%.2f ",per[i].h);
      }
      x=0;
      for(i=0;i<n;i++)
      {if(strcmp(per[i].sex,"male")==0)
      continue;
                      for (j=i+1;j<n;j++)
                      {
                         if(strcmp(per[j].sex,"male")==0)
                         continue;
                         if(per[i].h<per[j].h)
                         {
                                     t=per[i].h;
                                     per[i].h=per[j].h;
                                     per[j].h=t;
                         }
                      }
                      if(x==0)
                      {printf("%.2f",per[i].h);
                      x=1;}
                      else
                      {printf(" %.2f",per[i].h);}
      }
}


int main()
{
    char a[8];                               //?????,????
    double height;
    double female[40];
    double male[40];
    int n;
    int femalecount = 0;
    int malecount = 0;
    int i;
    cin >>n;
    for (i = 0; i < n; i++)
    {
        cin >> a;
        cin >> height;
        if (strlen(a) == 6)                          //???????6,??????
        {
            female[femalecount] = height;            //???????????
            femalecount++;
        }
        else
        {
            male[malecount] = height;               //??????,????????????
            malecount++;
        }
    }
    sort(male,male + malecount);                    //????
    sort(female,female + femalecount);              //????
    for (i = 0; i < malecount; i++)
    {
        cout << fixed << setprecision(2);
        cout << male[i] << " ";                       //???????????
    }
    for (i = femalecount - 1; i > 0; i--)
    {
        cout << female[i] << " ";                    //???????????
    }
    cout << female[0];
    return 0;
}


int pfCb(const void *x ,const void *y)
{
    return *((int*)x)-*((int*)y);
}

int pfCg(const void *x ,const void *y)
{
    return *((int*)y)-*((int*)x);
}

main()
{
      int n,j=0,k=0;
      char gender[7];
      float m[40],f[40],height;
      scanf("%d",&n);
      for(int i=0;i<n;i++)
      {
              scanf("%s %f",gender,&height);
              if(gender[0]=='m')
              {
                  m[j]=height;
                  j++;
              }
              else
              {
                  f[k]=height;
                  k++;
              }
      }
      qsort(m,j,sizeof(float),pfCb);
      qsort(f,k,sizeof(float),pfCg);
      printf("%.2f",m[0]);
      for(int t=1;t<j;t++)
      {
              printf(" %.2f",m[t]);
      }
      for(int t=0;t<k;t++)
      {
              printf(" %.2f",f[t]);
      }
}


int main()
{
	int n;
	double x;
	double a[40];
	double b[40];
	int counta = 0;
	int countb = 0;

	cin >> n;

	for(int i = 0; i < n; i ++)
	{
		char ch[10];

		cin >> ch >> x;

		if(ch[0] == 'm')
		{
			a[counta] = x;
			counta ++;
		}
		else
		{
			b[countb] = x;
			countb ++;
		}
	}

	for(int i = 0; i < counta - 1; i ++)
	for(int j = 0; j < counta - 1 - i; j ++)
	{
		if(a[j] > a[j + 1])
		{
			x = a[j];
			a[j] = a[j + 1];
			a[j + 1] = x;
		}
	}

	for(int i = 0; i < countb - 1; i ++)
	for(int j = 0; j < countb - 1 - i; j ++)
	{
		if(b[j] < b[j + 1])
		{
			x = b[j];
			b[j] = b[j + 1];
			b[j + 1] = x;
		}
	}

	cout << fixed << setprecision(2);

	cout << a[0];

	for(int i = 1; i < counta ; i ++)
	cout << " " << a[i];

	for(int i = 0; i < countb ; i ++)
	cout << " " << b[i];

	return 0;
}


int main()
{
	int n, i, j, count_male = 0, count_female = 39, emp;
	char sex[7];
	double hight[40];
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> sex;
		if (strcmp(sex, "female"))
			cin >> hight[count_male++];
		else
			cin >> hight[count_female--];
	}
	for (i = 0; i < count_male; i++)
	{
		emp = 0;
		for (j = 1; j < count_male; j++)
		{
			if (hight[j] <= hight[emp])
				emp = j;
		}
		cout << fixed << setprecision(2) <<hight[emp] << " ";
		hight[emp] = 3;
	}
	for (i = 39; i > count_female; i--)
	{
		emp = 39;
		for (j = 38; j > count_female; j--)
		{
			if (hight[j] >= hight[emp])
				emp = j;
		}
		cout << hight[emp];
		if (i != count_female+1)
			cout << " ";
		hight[emp] = 0;
	}
return 0;
}


int compmale(const void*a1,const void*a2)
{
 	float*p1,*p2;
 	p1=(float*)a1;
    p2=(float*)a2;
    if((*p1)-(*p2)>=0)
   return 1;
   else
   return -1;
}
int compfemale(const void*a1,const void*a2)
{
 	float*p1,*p2;
 	p1=(float*)a1;
    p2=(float*)a2;
   if((*p2)-(*p1)>=0)
   return 1;
   else
   return -1;
}
struct person
{
 	   char sex[10];
 	   float h;
}mate[40];
main()
{
 	  float m[40],f[40];
	   int n,i,j,a=0,b=0;
	   scanf("%d",&n);

	   for(i=0;i<n;i++)
	   {
	   		scanf("%s %f",mate[i].sex,&mate[i].h);
			if(strcmp(mate[i].sex,"male")==0)
			{
			 	m[a]=mate[i].h;
				 a++;
		    }
			else if(strcmp(mate[i].sex,"female")==0)
			{
	 	        f[b]=mate[i].h;
				 b++;
		    }
       }
	   qsort(m,a,sizeof(float),compmale);
	   for(i=0;i<a;i++)
	   printf("%1.2f ",m[i]);
	   qsort(f,b,sizeof(float),compfemale);
	   for(i=0;i<b;i++)
	   {
	   	if(i<b-1)
	      printf("%1.2f ",f[i]);
	    else
		  printf("%1.2f",f[i]);
	  }
		  getchar();getchar();
}


int main()
{
	int n , malecount = 0 , femalecount = 0;
	cin >> n;
	float t;
	char a[41][6];
	float b[41] , m[41] , f[41];
	int i , j;
	for (i = 1 ; i <= n ; i++)
	{
		cin >> a[i] >> b[i];
		if (a[i][0] == 'm')
		{
		   	malecount++;
			m[malecount] = b[i];
		}
		else
		{
			femalecount++;
			f[femalecount] = b[i];
		}
	}
	for (i = 1 ; i <= malecount - 1 ; i++)
	{
		for (j = 1 ; j <=  malecount - i ; j++)
		{
			if (m[j] > m[j + 1])
		    {
				t = m[j];
				m[j] = m[j + 1];
			    m[j + 1] = t;
		    }
		}
	}
	for (i = 1 ; i <= femalecount - 1 ; i++)
	{
		for (j = 1 ; j <= femalecount - i ; j++)
		{
			if (f[j] < f[j + 1])
			{
				t = f[j];
				f[j] = f[j + 1];
			    f[j + 1] = t;
			}
		}
	}
	cout << fixed;
	cout << setprecision(2) << m[1];
	for (i = 2 ; i <= malecount ; i++)
	{
		cout << " " << setprecision(2) << m[i];
	}
	for (i = 1 ; i <= femalecount ; i++)
	{
		cout <<  " " << setprecision(2) << f[i];
	}
	return 0;
}


int main()
{
	int n, male1 = 0, female1 = 0, i, j;
	float height[41], male[41], female[41], t;
	char a[41][7];
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> a[i] >> height[i];
		if (strcmp(a[i], "male") == 0)
		{
			male1 += 1;
			male[male1] = height[i];
		}
		else
		{
			female1 += 1;
			female[female1] = height[i];
		}
	}
	for (i = 1; i < male1; i++)
		for (j = 1; j <= male1 - i; j++)
			if (male[j] > male[j +1])
			{
				t = male[j];
				male[j] = male [j + 1];
				male[j + 1] = t;
			}
	for (i = 1; i < female1; i++)
		for (j = 1; j <= female1 - i; j++)
			if (female[j] < female[j + 1])
			{
				t = female[j];
				female[j] = female[j + 1];
				female[j + 1] = t;
			}
	for (i = 1; i <= male1; i++)
		cout << fixed << setprecision(2) << male[i] << " ";
	for (i = 1; i < female1; i++)
		cout << fixed << setprecision(2) << female[i] << " ";
	cout << female[female1] << endl;

	return 0;
}


struct human
{
       char ch[7];
       float tall;
       };
main()
{
      int n,m,s,i,j;
      int q=0;
      int x=0;
      scanf("%d",&n);
      struct human hu[n],Hn[n],Hu[n];
      for(i=0;i<n;i++)
      {
          scanf("%s %f\n",hu[i].ch,&hu[i].tall);
      }
       for(i=0;i<n;i++)
      {
         if(strcmp(hu[i].ch,"male")==0)
          {Hn[q]=hu[i];
           q++;}
         else
          {Hu[x]=hu[i];
           x++;}
       }
       for(i=0;i<q;i++)
       {m=i;
         for(j=i+1;j<q;j++)
          {if(Hn[j].tall<Hn[m].tall)
            m=j;
          }
           if(i==0)
              printf("%.2f",Hn[m].tall);
           if(i!=0)
              printf(" %.2f",Hn[m].tall);
         Hn[m].tall=Hn[i].tall;
       }

        for(i=0;i<x;i++)
         {s=i;
           for(j=i+1;j<x;j++)
            {if(Hu[j].tall>Hu[s].tall){
             s=j;}
            }
         printf(" %.2f",Hu[s].tall);
         Hu[s].tall=Hu[i].tall;
         }

}


int main(){
	int n,i=0,j=0;
	char sex[41][7];
	double height[41],male[41]={0},female[41]={0},ex;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",sex[i]);
		scanf("%lf",&height[i]);
	}
	for(i=0;i<n;i++){
		if(sex[i][0]=='m'){
			male[i]=height[i];
		}else{
			female[i]=height[i];
		}
	}
	for(i=0;i<41;i++){
		for(j=0;j<40;j++){
			if(male[j]>male[j+1]){
				ex=male[j];
				male[j]=male[j+1];
				male[j+1]=ex;
			}
		}
	}
	for(i=0;i<41;i++){
		for(j=0;j<40;j++){
			if(female[j]<female[j+1]){
				ex=female[j];
				female[j]=female[j+1];
				female[j+1]=ex;
			}
		}
	}
	for(i=0;i<41;i++){
		if(male[i]!=0){
			printf("%.2lf ",male[i]);
		}
	}
	printf("%.2lf",female[0]);
	for(i=1;female[i]!=0;i++){
		printf(" %.2lf",female[i]);
	}
	return 0;

}


int main()
{
    float male[40],female[40],all[41];
    int count1=0;
    int count2=0;
    int n,i,j,k;
    float s,t,y;
    char x[7],c;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
         scanf("%s",x);
         scanf("%f",&y);
         //printf("%s,%f\n",x,y);
         if(strlen(x)==4)
         {
              male[count1]=y;
              count1++;
         }
         else
         {
              female[count2]=y;
              count2++;
         }
    }
         for(i=0;i<=count1-2;i++)
           for(j=i+1;j<=count1-1;j++)
           {
                if(male[i]>male[j])
                {
                s=male[i];
                male[i]=male[j];
                male[j]=s;
                }
           }
         for(i=0;i<=count2-2;i++)
           for(j=i+1;j<=count2-1;j++)
           {
                if(female[i]<female[j])
                {
                t=female[i];
                female[i]=female[j];
                female[j]=t;
                }
           }
         for(k=0;k<=count1-1;k++)
            all[k]=male[k];
         for(k=count1;k<=count1+count2-1;k++)
            all[k]=female[k-count1];
for(k=0;k<=count1+count2-2;k++)
{
printf("%.2f ",all[k]);
}
printf("%.2f",all[count1+count2-1]);
}


struct people
{
    char a[10];
    float h;
};
int com1(const void *x,const void *y)
{
    return *(int *)x-*(int *)y;
}
int com2(const void *x,const void *y)
{
    return *(int *)y-*(int *)x;
}
int main()
{
    struct people p[40];
    int n,i,j,k;
    float m[40],f[40];
    scanf("%d",&n);
    j=0;
    k=0;
    for(i=0;i<n;i++)
    {
        scanf("%s %f",&p[i].a,&p[i].h);
        if(p[i].a[0]=='m')
        {
            m[j]=p[i].h;
            j=j+1;
        }
        else
        {
            f[k]=p[i].h;
            k=k+1;
        }
    }
    qsort(m,j,sizeof(m[0]),com1);
    qsort(f,k,sizeof(f[0]),com2);
    for(i=0;i<j;i++)
    {
        printf("%.2f ",m[i]);
    }
    for(i=0;i<k-1;i++)
    {
        printf("%.2f ",f[i]);
    }
    printf("%.2f",f[k-1]);
    return 0;
}


int nancom(const void *a,const void *b)
{
	return *(int *)a-*(int *)b;
}
int nvcom(const void *a,const void *b)
{
	return *(int *)b-*(int *)a;
}

int main()
{
	int nan[40]={0};
	int nv[40]={0};
	double hai = 0;
	int inthai=0;

	char tmp[8] = "";
	int i=0,j=0,num=0;
	int nanNum=0,nvNum=0;
	scanf("%d",&num);

	while(i<num)
	{
		scanf("%s %lf",tmp, &hai);
		inthai = hai*1000;

		if(tmp[0] == 'm')
			nan[nanNum++] =inthai;
		else
			nv[nvNum++] =inthai;
		i++;
	}

	qsort(&nan[0],nanNum,sizeof(int),nancom);
	qsort(&nv[0],nvNum,sizeof(int),nvcom);
	for(i=0;i<nanNum;i++)
	{
		hai = (double)nan[i]/1000;
		printf("%.2f ",hai);
	}

	for(i=0;i<nvNum;i++)
	{
		hai = (double)nv[i]/1000;
		if(i==0)
			printf("%.2f",hai);
		else
			printf(" %.2f",hai);
	}
	printf("\n");
	return 0;
}


int main()
{
	char sex[41][7];
	float height[41], b[41], t, s;
	int n, i, j, countM = 0, countF = 0;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> sex[i] >> height[i];
		if (sex[i][0] == 'm')
		{
			countM++;
			b[countM] = height[i];
		}
     	else
		{
			countF++;
			b[n+1-countF] = height[i];
		}
	}
	for (i = 1; i < countM; i++)
		for (j = i + 1; j <= countM; j++)
		{
			if (b[i] > b[j])
			{
				s = b[i];
				b[i] = b[j];
				b[j] = s;
			}
		}
	for (i = countM + 1; i < n; i++)
		for ( j = i + 1; j <= n; j++)
		{
			if (b[i] < b[j])
			{
				t = b[i];
				b[i] = b[j];
				b[j] = t;
			}
		}
	for (i = 1; i < n; i++)
		cout << fixed << setprecision(2) << b[i] << " ";
	cout << b[n] << endl;
return 0;
}


int main()
{
 int n;
 scanf("%d",&n);
 double shengao[40];
 char xingbie[40][10];
 double nansheng[40],nvsheng[40];
 int m=0,f=0;
 int i;
 for(i=0;i<n;i++)
 {
  scanf("%s",xingbie[i]);
  scanf("%lf",&shengao[i]);
 }
 for(i=0;i<n;i++)
 {
  if (strcmp(xingbie[i],"male")==0)
  {
   nansheng[m]=shengao[i];
   m++;
  }
  else if(strcmp(xingbie[i],"female")==0)
  {
   nvsheng[f]=shengao[i];
   f++;
  }
 }
 int j;
 double t;
 for(j=1;j<m;j++)
 {
  for (i=0;i<m-j;i++)
  {
   if (nansheng[i]>nansheng[i+1])
   {
    t=nansheng[i];
    nansheng[i]=nansheng[i+1];
    nansheng[i+1]=t;
   }
  }
 }
 double r;
 for (j=1;j<f;j++)
 {
  for(i=0;i<f-j;i++)
  {
   if(nvsheng[i]<nvsheng[i+1])
   {
    r=nvsheng[i];
    nvsheng[i]=nvsheng[i+1];
    nvsheng[i+1]=r;
   }
  }
 }
 for (i=0;i<m;i++)
 {
  printf("%.2lf ",nansheng[i]);
 }
 for(i=0;i<f;i++)
 {
  if(i<f-1)
{
printf("%.2lf ",nvsheng[i]);
}
else if(i==f-1)
{
printf("%.2lf",nvsheng[i]);
}
 }
 return 0;
}


typedef long long ll;

const int maxn = 100;
double d0[maxn], d1[maxn];
int cnt0, cnt1;
int n;

int main()
{
	while(scanf("%d", &n) == 1)
	{
		cnt0 = cnt1 = 0;
		for(int i = 0; i < n; i++)
		{
			char s[100];
			double tmp;

			scanf("%s%lf", s, &tmp);
			if(s[0] == 'm')
				d0[cnt0++] = tmp;
			else
				d1[cnt1++] = tmp;
		}

		sort(d0, d0 + cnt0);
		sort(d1, d1 + cnt1);
		char flag = 0;
		for(int i = 0; i < cnt0; i++)
		{
			if(flag)	putchar(' ');
			flag = 1;
			printf("%.2lf", d0[i]);
		}

		for(int i = cnt1 - 1; i >= 0; i--)
		{
			if(flag)	putchar(' ');
			flag = 1;

			printf("%.2lf", d1[i]);
		}

		puts("");
	}
	return 0;
}


int main()
{
	int n;
	double a[41], b[41];
	char str[7];
	int p, q;
	double temp;

	cin >> n;
	p = 0; q = 0;
	for (int i = 1; i <= n; i++)
	{
		cin.get();
		cin >> str;
		if (str[0] == 'm')
		{
			p++;
			cin >> a[p];
		}
		else
		{
			q++;
			cin >> b[q];
		}
	}
	for (int i = 1; i <= p - 1; i++)
		for (int j = 1; j <= p - i; j++)
			if (a[j] > a[j + 1])
			{
				temp = a[j];
				a[j] = a[j + 1];
				a[j + 1] = temp;
			}
	for (int i = 1; i <= q - 1; i++)
		for (int j = 1; j <= q - i; j++)
			if (b[j] < b[j + 1])
			{
				temp = b[j];
				b[j] = b[j + 1];
				b[j + 1] = temp;
			}
	for (int i = 1; i <= p; i++)
		cout << fixed << setprecision(2) << a[i] << " ";
	for (int i = 1; i <= q - 1; i++)
		cout << b[i] << " ";
	cout << b[q];
	return 0;
}


const int MAXN = 50;
int n;
double a[MAXN], b[MAXN];
int nummale, numfemale;
int main() {
    nummale = 0;
    numfemale = 0;
    scanf("%d", &n);
    char sex[10];
    double h;
    for (int i = 0; i < n; ++i) {
        scanf("%s%lf", sex, &h);
        if (strcmp(sex, "male") == 0) {
                        a[nummale++] = h;
        } else {
               b[numfemale++] = h;
        }
        }
        sort(a, a + nummale);
        sort(b, b + numfemale);
        for (int i = 0; i < nummale; ++i)
            printf("%.2lf ", a[i]);
        for (int i = numfemale - 1; i > 0; --i)
            printf("%.2lf ", b[i]);
        if (numfemale > 0)
           printf("%.2lf\n", b[0]);

    return 0;
}


int main()
{
	int n,male=0,female=0;
	char sex[41][10];
	float high[41];
	float male_high[41];
	float female_high[41];
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%s %f",sex[i],&high[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(sex[i][0]=='m')
		{
			male++;
			male_high[male]=high[i];
		}
		else
		{
			female++;
			female_high[female]=high[i];
		}
	}
	sort(male_high+1,male_high+male+1);
	sort(female_high+1,female_high+female+1);
	for(int i=1;i<=male;i++)
		printf("%.2f ",male_high[i]);
	for(int i=female;i>=2;i--)
		printf("%.2f ",female_high[i]);
	printf("%.2f\n",female_high[1]);
	return 0;
}


int comp(const void*a,const void*b){
    return *(float*)a-*(float*)b;
    }

int main(){
    int n,count1=0,count2=0,i,j;
    float num,a[40],b[40],temp;
    char string[10];
    scanf("%d",&n);
    for(i=0;i<=n-1;i++){
        scanf("%s",string);
        scanf("%f",&num);
        if(string[0]=='m')
             a[count1++]=num;
        else if(string[0]=='f')
             b[count2++]=num;

    }
    //qsort(a,count1,sizeof(float),comp);
    //qsort(b,count2,sizeof(float),comp);
    for(i=0;i<=count1-2;i++)
        for(j=0;j<=count1-2-i;j++)
            if(a[j]>a[j+1]){
                temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }
    for(i=0;i<=count2-2;i++)
        for(j=0;j<=count2-2-i;j++)
            if(b[j]<b[j+1]){
                temp=b[j];
                b[j]=b[j+1];
                b[j+1]=temp;
            }
    for(i=0;i<=count1-1;i++)
        printf("%.2f ",((float)(a[i])));
    for(i=0;i<=count2-2;i++)
        printf("%.2f ",((float)(b[i])));
    printf("%.2f",((float)(b[count2-1])));
    printf("\n");

    return 0;
    }


int main()
{
    int n, i, j;
    float height[40], hmale[40], hfemale[40];
    char sex[40][7];
    cin >> n;
    cin.get();
    for(i = 0; i < n; i++)
    {
        cin >> sex[i];
        cin >> height[i];
        cin.get();
    }
    int k = 0, m = 0;
    float t;
    for(i = 0; i < n; i++)
    {
        if(sex[i][0] == 'm')
        {
            hmale[m] = height[i];
            m++;
        }
        else
        {
            hfemale[k] = height[i];
            k++;
        }
    }
    for(i = 0; i < m - 1; i++)
        for(j = 0; j < m - 1 - i; j++)
    {
        if(hmale[j] > hmale[j + 1])
        {
            t = hmale[j + 1];
            hmale[j + 1] = hmale[j];
            hmale[j] = t;
        }

    }
    for(i = 0; i < k - 1; i++)
        for(j = 0; j < k - 1 - i; j++)
    {

        if(hfemale[j] < hfemale[j + 1])
        {
            t = hfemale[j + 1];
            hfemale[j + 1] = hfemale[j];
            hfemale[j] = t;
        }
    }
    for(i = 0; i < m; i++)
        printf("%.2f ", hmale[i]);
    for(i = 0; i < k - 1; i++)
        printf("%.2f ", hfemale[i]);
    printf("%.2f", hfemale[k - 1]);
    return 0;
}


int compare1(const void *elem1,const void *elem2)
{
 float *p1,*p2;
 p1=(float *)elem1;
 p2=(float *)elem2;
 if(*p1>*p2)
	 return 1;
 else
	 return 0;
}

int compare2(const void *elem1,const void *elem2)
{
 float *p1,*p2;
 p1=(float *)elem1;
 p2=(float *)elem2;
 if(*p2>*p1)
	 return 1;
 else
	 return 0;
}

int main()
{
    int i,n,k1=0,k2=0;
	char c[7];
	float MH[40],FH[40];

	scanf("%d",&n);
	while(n--)
	{
		scanf("%s",c);
		if(strcmp(c,"male")==0)
			scanf("%f",&MH[k1++]);
		else if(strcmp(c,"female")==0)
			scanf("%f",&FH[k2++]);
	}
    qsort(MH,k1,sizeof(float),compare1);
	qsort(FH,k2,sizeof(float),compare2);
	for(i=0;i<k1;i++)
		printf("%.2f ",MH[i]);
	for(i=0;i<k2-1;i++)
		printf("%.2f ",FH[i]);
	printf("%.2f\n",FH[k2-1]);
	return 0;
}


int cmpdouble(const void *x, const void *y)
{
    return (*(double*)x > *(double*)y ? 1 : -1);
}
main()
{
int n,i,j,k;
double boy[41],girl[41];
scanf("%d",&n);
struct student
{char gender[10];
double height;
}student[41];
for(i=0;i<=n-1;i++)
scanf("%s %lf",&student[i].gender,&student[i].height);
i=0;
j=0;
k=0;
while(i<=n-1)
{
	if(student[i].gender[0]=='m')
	{boy[j]=student[i].height;
	j++;}
	else
	{girl[k]=student[i].height;
	k++;}
	i++;
}

qsort(boy,j,sizeof(boy[0]),cmpdouble);
qsort(girl,k,sizeof(girl[0]),cmpdouble);
for(i=0;i<=j-1;i++)
printf("%.2f ",boy[i]);
for(i=k-1;i>0;i--)
printf("%.2f ",girl[i]);
printf("%.2f",girl[0]);
}


int main()
{
int n,i,j,k,male,female;
double t;
char xingbie[50][10];
double shengao[50],nan[50],nv[50];
scanf("%d",&n);
for(j=0;j<n;j++){
                  scanf("%s",xingbie[j]);
                  scanf("%lf",&shengao[j]);
                  }
i=0;
k=0;
for(j=0;j<n;j++){
                 if(xingbie[j][0]=='m'){
                                        nan[i]=shengao[j];
                                        i++;
                                        }
                 else{
                      nv[k]=shengao[j];
                      k++;
                      }
                 }
male=i;
female=k;
for(i=0;i<male-1;i++){
                 for(j=0;j<male-i-1;j++){
                                     if(nan[j]>nan[j+1]){
                                                         t=nan[j];
                                                         nan[j]=nan[j+1];
                                                         nan[j+1]=t;
                                                         }
                                     }
                 }
 for(i=0;i<female;i++){
                 for(j=0;j<female-i-1;j++){
                                     if(nv[j]>nv[j+1]){
                                                         t=nv[j];
                                                         nv[j]=nv[j+1];
                                                         nv[j+1]=t;
                                                         }
                                     }
                 }
 for(i=0;i<male;i++){printf("%.2lf ",nan[i]);}
 for(i=female-1;i>0;i--){printf("%.2lf ",nv[i]);}
 printf("%.2lf",nv[0]);

return 0;
}


struct photo
{
       char gen[10];
       double height;
};
main()
{
      int n;
      scanf("%d",&n);
      struct photo a[50];
      struct photo b;
      int i,j,k=0;
      for(i=0;i<n;i++)
      scanf("%s %lf",a[i].gen,&a[i].height);
      for(i=0;i<n;i++)
      {
            for(j=0;j<n-1-i;j++)
            {
                if(a[j].height<a[j+1].height)
                {
                    b=a[j];
                    a[j]=a[j+1];
                    a[j+1]=b;
                }
            }
      }
      for(i=n-1;i>=0;i--)
      {
             if(strcmp(a[i].gen,"male")==0&&k!=0)
             printf(" %.2f",a[i].height);
             if(strcmp(a[i].gen,"male")==0&&k==0)
             {
                printf("%.2f",a[i].height);
                k=k+1;
             }
      }
      for(i=0;i<n;i++)
      {
             if(strcmp(a[i].gen,"female")==0)
             printf(" %.2f",a[i].height);
      }
      }


int cmp(const void * a,const void *b)
{
	return *((int *)a)-*((int *)b);
}
typedef struct{
  int  sex;
  float high;
} Man;
Man man[41];
float male[41];
float female[41];
int main()
{
 int n;
 scanf("%d",&n);
 int i;
char  str[10];
int j=0;
int k=0;
 for(i=0;i<n;i++)
 {
	 scanf("%s%f",str,&man[i].high);

	 if(strcmp(str,"male")==0)
	 {
		 man[i].sex=0;
		 male[j++]=man[i].high;
	 }
	 else  {
		 man[i].sex=1;
		 female[k++]=man[i].high;
	 }
}
 qsort(male,j,sizeof(float),cmp);
 qsort(female,k,sizeof(float),cmp);
 for(i=0;i<j;i++)
  printf("%.2f ",male[i]);
  for(i=k-1;i>0;i--)
  printf("%.2f ",female[i]);
   printf("%.2f",female[i]);
  printf("\n");
return 0;
}


void px(double *sz,int n);
int main(){
	char s[10];
	double hehe;
	double b[40];
	double g[40];
	int by=0;
	int gl=0;
	int n;
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++){
		scanf("%s %lf",s,&hehe);
		if(strcmp(s,"female")==0){
			g[gl]=hehe;
			gl++;
		}else{
			b[by]=hehe;
			by++;
		}
	}
	px(b,by);
	px(g,gl);
	printf("%.2lf",b[0]);
	for(i=1;i<by;i++){
		printf(" %.2lf",b[i]);
	}
	for(i=gl-1;i>=0;i--){
		printf(" %.2lf",g[i]);
	}
	return 0;
}
void px(double *sz,int n){
	int i,k;
	for(k=1;k<=n;k++){
		for(i=0;i<=n-k-1;i++){
			if(sz[i]>=sz[i+1]){
				double ex;
				ex=sz[i];
				sz[i]=sz[i+1];
				sz[i+1]=ex;
			}
		}
	}
}


void array(double*A,int n)
{
	int i,j,k;
	double t;
	for(i=0;i<n;i++)
	{
		k=i;
		for(j=i+1;j<n;j++)
		{
			if(A[j]<A[k])
				k=j;
		}
		if(k!=i)
		{
			t=A[k];
			A[k]=A[i];
			A[i]=t;
		}
	}
}
int main(){
	int i,j,n,m=0,l=0;
	double h,nan[50],nv[50];
	char s[6];
	scanf("%d\n",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s\n",s);
		scanf("%lf",&h);
	if(s[0]=='m')
	{
		nan[m]=h;
		m++;

}
	else
	{
		nv[l]=h;
		l++;
	}
	}
array(nan,m);
for(i=0;i<m;i++)
       printf("%.2lf ",nan[i]);
array(nv,l);
for(i=l-1;i>0;i--)
printf("%.2lf ",nv[i]);
printf("%.2lf",nv[0]);
  return 0;
}


void main()
{

	int male=0,female=0,n,i,j;
	char cn,m,f;
	char exam1[]="mmm",exam2[]="fff";

    float an[40],bn[40],high,temp1;
    char temp[6];
	m=exam1[0];
	f=exam2[0];
	scanf("%d",&n);
    for(i=0;i<n;i++)
	{
        scanf("%s %f",&temp,&high);
			cn=temp[0];
		if(cn==m)
		{
			an[male]=high;
             male=male+1;

		}
         if(cn==f)
		 {
			 bn[female]=high;
			 female=female+1;
		 }

	}

	for(i=0;i<female;i++)
	{
	 for(j=0;j<female-i-1;j++)
	 {
       if(bn[j]<bn[j+1])
	   {
          temp1=bn[j];
		  bn[j]=bn[j+1];
		  bn[j+1]=temp1;

	   }
	 }
	}

	for(i=0;i<male;i++)
	{
	 for(j=0;j<male-i-1;j++)
	 {
       if(an[j]>an[j+1])
	   {
          temp1=an[j];
		  an[j]=an[j+1];
		  an[j+1]=temp1;

	   }
	 }
	}

for(i=0;i<male;i++)
{
    printf("%.2f",an[i]);
	printf(" ");
}
for(i=0;i<female-1;i++)

{
	printf("%.2f",bn[i]);
	printf(" ");
}
printf("%.2f",bn[female-1]);

}


main()
{
  int n,m=0,x=0,y=0,q,s;
  scanf("%d",&n);
  struct person
  {
    char sex[7];
    float height;
  };
  struct person people[n];

  for(int i=0;i<=n-1;i++)
    scanf("%s %f",people[i].sex,&people[i].height);
  for(int j=0;j<=n-1;j++)
  {
    if(people[j].sex[0]=='m')
    m++;
  }
  struct person male[m];
  struct person female[n-m];
  struct person b;
  for(int k=0;k<=n-1;k++)
  {
    if(people[k].sex[0]=='m')
    {
      male[x]=people[k];
      x++;
    }
    else
    {
      female[y]=people[k];
      y++;
    }
  }
  for(int p=0;p<=m-2;p++)
  {
     for(q=0;q<=m-2-p;q++)
     {
       if(male[q+1].height<male[q].height)
       {
         b=male[q+1];
         male[q+1]=male[q];
         male[q]=b;
       }
     }
  }
  for(int r=0;r<=y-2;r++)
  {
     for(s=0;s<=y-2-r;s++)
     {
       if(female[s+1].height>female[s].height)
       {
         b=female[s+1];
         female[s+1]=female[s];
         female[s]=b;
       }
     }
  }
  for(int t=0;t<=m-1;t++)
  {
    printf("%.2f ",male[t].height);
  }
  for(int u=0;u<=y-2;u++)
  {
    printf("%.2f ",female[u].height);
  }
  printf("%.2f",female[y-1].height);
}


int main()
{
	int i,a,b,n,k;
	char m[40][8];
	double male[40],female[40],p;
scanf("%d",&n);
a=0;b=0;
for(i=0;i<n;i++)
{
	scanf("%s %lf",m[i],&p);
	if(strcmp(m[i],"male")==0)
	{
		male[a]=p;
		a++;
	}
	else if(strcmp(m[i],"female")==0)
	{
		female[b]=p;
		b++;
	}
}
for(k=a-1;k>0;k--)
for(i=0;i<k;i++){
	if( male[i]>male[i+1])
	{
		double tmp;
		tmp=male[i+1];
		male[i+1]=male[i];
		male[i]=tmp;
	}
}
for(k=b-1;k>0;k--)
for(i=0;i<k;i++){
	if( female[i]>female[i+1])
	{
		double tmp;
		tmp=female[i+1];
		female[i+1]=female[i];
		female[i]=tmp;
	}
}
printf("%.2lf",male[0]);
for(i=1;i<a;i++)
printf(" %.2lf",male[i]);
for(i=b-1;i>=0;i--)
printf(" %.2lf",female[i]);
return 0;
}


int main()
{
	char a[8];
	float male[44] = {0}, female[44] = {0}, temple;
	int n, i = 0, j = 0;

	cin >> n;
	for ( int k = 0; k < n; k++ )
	{
		cin.get();
		a[0] = cin.get();
		for ( int l = 0; a[l] != ' '; l++ )
			a[l + 1] = cin.get();
		if ( a[0] == 'm' )
		{
			cin >> male[i];
			i++;
		}
		else
		{
			cin >> female[j];
			j++;
		}
	}
	for ( int k = 0; k < i; k++ )
	{
		for ( int l = 1; l < i - k; l++ )
		{
			if ( male[l] < male[l - 1] )
			{
				temple = male[l];
				male[l] = male[l - 1];
				male[l - 1] = temple;
			}
		}
	}
	for ( int k = 0; k < j; k++ )
	{
		for ( int l = 1; l < j - k; l++ )
		{
			if ( female[l] > female[l - 1] )
			{
				temple = female[l];
				female[l] = female[l - 1];
				female[l - 1] = temple;
			}
		}
	}
	cout << fixed << setprecision(2) << male[0];
	for ( int k = 1; k < i; k++ )
		cout << " " << setprecision(2) << male[k];
	for ( int k = 0; k < j; k++ )
		cout << " " << setprecision(2) << female[k];
	return 0;
}


main()
{
      int n,i,j;
      char s[10];
      float k;
      scanf("%d",&n);
      struct
      {
      char sex[10];
      float hei;
      } peo[n];
      for(i=0;i<n;i++)
      scanf("%s %f",peo[i].sex,&peo[i].hei);
      for(i=1;i<=n;i++)
      for(j=n-1;j>=i;j--)
      if(peo[j].hei<peo[j-1].hei)
      {
          k=peo[j].hei;
          peo[j].hei=peo[j-1].hei;
          peo[j-1].hei=k;
          strcpy(s,peo[j].sex);
          strcpy(peo[j].sex,peo[j-1].sex);
          strcpy(peo[j-1].sex,s);
      }
      for(i=0;i<n;i++)
      if(strcmp(peo[i].sex,"male")==0)
      {printf("%.2f",peo[i].hei);break;}
      for(i=i+1;i<n;i++)
      if(strcmp(peo[i].sex,"male")==0)
      printf(" %.2f",peo[i].hei);

      for(i=n-1;i>=0;i--)
      if(strcmp(peo[i].sex,"female")==0)
      printf(" %.2f",peo[i].hei);
}


int main(){
	char sex[10];
	double shengao;
	int n,i,male=0,female=0;
	double m[40],f[40];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %lf",sex,&shengao);
		if(sex[0]=='m') {
			m[male++]=shengao;//???
		}
		if(sex[0]=='f'){
			f[female++]=shengao;//???
		}
	}

	int k;
	double e;
	for(k=1;k<=male;k++){//???????
		for(i=male-1;i>=k;i--){
			if(m[i]<m[i-1]){
				e=m[i];
				m[i]=m[i-1];
				m[i-1]=e;
			}
		}
	}

	for(k=1;k<=female;k++){
		for(i=0;i<female-k;i++){
			if(f[i]<f[i+1]){
				e=f[i+1];
				f[i+1]=f[i];
				f[i]=e;
			}
		}
	}

	for(k=0;k<male;k++)
		printf("%.2lf ",m[k]);
	for(k=0;k<female;k++)
	{
		if(k<female-1)
			printf("%.2lf ",f[k]);
		else
			printf("%.2lf",f[k]);
	}

return 0;
}


int main()
{
	int n,i,j=0,k=0,q;
	char sex[42][10];
	double height[42];
	double male[42];
	double female[42];
	double x;
	double *h;
	cin>>n;
	h = height;
	for(i=0;i<n;i++)
	{
		cin>>sex[i];
		cin>>*h++;
		cin.get();
	}
	h = height;
	for(i=0;i<n;i++)
	{
		if(sex[i][0]=='m')
		{
			male[j] = height[i];
			j++;
		}
		else
		{
			female[k] = height[i];
			k++;
		}
	}
	for(i=1;i<=j-1;i++)
	{
		for(q=0;q<=j-i-1;q++)
		{
			if(male[q]>male[q+1])
			{
				x = male[q];
				male[q] = male[q+1];
				male[q+1] = x;
			}
		}
	}
	for(i=1;i<=k-1;i++)
	{
		for(q=0;q<=k-i-1;q++)
		{
			if(female[q]<female[q+1])
			{
				x = female[q];
				female[q] = female[q+1];
				female[q+1] = x;
			}
		}
	}
	cout<<fixed<<setprecision(2)<<male[0];
	for(i=1;i<=j-1;i++)
	{
		cout<<" "<<fixed<<setprecision(2)<<male[i];
	}
	for(i=0;i<=k-1;i++)
	{
		cout<<" "<<fixed<<setprecision(2)<<female[i];
	}
	cout<<endl;
	return 0;
}


void bubblesort1(float a[],int n)
{
	int i,j;
	float tmp;
	for(i=0;i<n-1;i++)
	for(j=i+1;j<n;j++)
	{
		if(a[i]>a[j])
		{
			tmp=a[i];
			a[i] = a[j];
			a[j]=tmp;
		}
	}
}
void bubblesort2(float a[],int n)
{
	int i,j;
	float tmp;
	for(i=0;i<n-1;i++)
	for(j=i+1;j<n;j++)
	{
		if(a[i]<a[j])
		{
			tmp=a[i];
			a[i] = a[j];
			a[j]=tmp;
		}
	}
}
int main()
{
	int n;
	char ss[10];
	float height;
	float male[40];
	float female[40];
	int c_m=0;
	int c_f=0;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%s %f",ss,&height);
		if(ss[0]=='m')
		{
			male[c_m]=height;
			c_m++;
		}
		else
		{
			female[c_f]=height;
			c_f++;
		}
	}
	bubblesort1(male, c_m);
	bubblesort2(female,c_f);
	for(int i=0;i<c_m;i++)
		printf("%.2f ",male[i]);
	for(int j=0;j<c_f-1;j++)
		printf("%.2f ",female[j]);
	printf("%.2f",female[c_f-1]);
	//scanf("%s",ss);
	return 0;
}


int main()
{
    struct student {
        char gender[7];
        float height;
    } students[40], ts;
    int n, i, j;
    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%s %f", students[i].gender, &students[i].height);
    }
    for (i=0; i<n; i++) {
        for (j=i+1; j<n; j++) {
            int ex = 0;
            if (students[i].gender[0] == 'f' && students[j].gender[0] == 'm')
                ex = 1;
            else if (students[i].gender[0] == 'm' && students[j].gender[0] == 'm')
                ex = (students[i].height > students[j].height);
            else if (students[i].gender[0] == 'f' && students[j].gender[0] == 'f')
                ex = (students[i].height < students[j].height);
            if (ex) {
                ts = students[i];
                students[i] = students[j];
                students[j] = ts;
            }
        }
    }
    for (i=0; i<n; i++) {
        if (i == 0) {
            printf("%.2f", students[i].height);
        }
        else {
            printf(" %.2f", students[i].height);
        }
    }
    return 0;
}


main()
{
      int n,m,f;
      m=0;
      f=0;
      scanf("%d\n",&n);
      struct student
      {
             char sex[6];
             float tall;
      };
      struct student std1[40];
      struct student std2[40];
      struct student std3[40];
      for(int i=0;i<n;i++)
      {
              scanf("%s %f",std1[i].sex,&std1[i].tall);
              if(strcmp(std1[i].sex,"male")==0)
              {
                       std2[m]=std1[i];
                       m=m+1;
              }
              else
              {
                       std3[f]=std1[i];
                       f=f+1;
              }
      }
      for(int p=m-1;p>0;p--)
      {
              for(int q=0;q<p;q++)
              {
                      if(std2[q].tall>std2[q+1].tall)
                      {
                                 float t;
                                 t=std2[q].tall;
                                 std2[q].tall=std2[q+1].tall;
                                 std2[q+1].tall=t;
                      }
              }

      }
      for(int p=f-1;p>0;p--)
      {
              for(int q=0;q<p;q++)
              {
                      if(std3[q].tall<std3[q+1].tall)
                      {
                                 float t;
                                 t=std3[q].tall;
                                 std3[q].tall=std3[q+1].tall;
                                 std3[q+1].tall=t;
                      }
              }
      }
      for(int z=0;z<m;z++)
      {
              if(z==0)
              printf("%.2f",std2[z].tall);
              else printf(" %.2f",std2[z].tall);
      }
      for(int z=0;z<f;z++)
      {
              printf(" %.2f",std3[z].tall);
      }

}


int main ()
{
    int n,i,j,s,f,m;
    double male[41],female[41];
    char tip[7];
    scanf("%d\n",&n);
    f=0;
    m=0;
    for(i=0;i<n-1;i++)
    {
                    scanf("%s",tip);
                    if(tip[0]=='f') {scanf("%lf\n",&female[f]);f++;}
                    else
                    {scanf("%lf\n",&male[m]);m++;}
                    }
    scanf("%s",tip);
    if(tip[0]=='f') {scanf("%lf",&female[f]);f++;}
    else
    {scanf("%lf",&male[m]);m++;}
    s=1;
    while (s>0)
    {s=0;
    for (i=0;i<m-1;i++)
    if (male[i]>male[i+1]) {male[i]=male[i]+male[i+1];male[i+1]=male[i]-male[i+1];male[i]=male[i]-male[i+1];s++;}
    }
    s=1;
    while (s>0)
    {s=0;
    for (i=0;i<f-1;i++)
    if (female[i]<female[i+1]) {female[i]=female[i]+female[i+1];female[i+1]=female[i]-female[i+1];female[i]=female[i]-female[i+1];s++;}
    }
    for(i=0;i<m;i++) printf("%.2lf ",male[i]);
    for(i=0;i<f-1;i++) printf("%.2lf ",female[i]);
    printf("%.2lf\n",female[f-1]);
    return 0;
}


int main()
{
	char sex[40][7];
	double height[40], male[40]={0.00}, female[40]={0.00};
	int n, num_male, num_female;
	cin >> n;
	int i, j = 0, k = 0;
	double temp;
	for ( i = 0; i < n; i ++)
	{
		cin >> sex[i] >> height[i];
		if ( strcmp(sex[i],"male")==0 )
		{
			male[j] = height[i];
			j ++;
		}
		else
		{
			female[k] = height[i];
			k ++;
		}
	}
	for ( num_male = 0; num_male < n; num_male ++)
	{
		if (male[num_male] <= 0)
			break;
	}
	for ( num_female = 0; num_female < n; num_female ++)
	{
		if (female[num_female] <= 0)
			break;
	}
	for ( i = 0; i < num_male - 1; i ++)
		for ( j = 0; j < num_male - i - 1; j ++)
		{
			if (male[j] > male[j + 1])
			{
				temp = male[j];
				male[j] = male[j + 1];
				male[j + 1] = temp;
			}
		}
	for ( i = 0; i < num_female - 1; i ++)
		for ( j = 0; j < num_female - i - 1; j ++)
		{
			if (female[j] > female[j+1])
			{
				temp = female[j];
				female[j] = female[j + 1];
				female[j + 1] = temp;
			}
		}
	cout << fixed << setprecision(2) << male[0];
	for ( i = 1; i < num_male; i ++)
		cout << fixed << setprecision(2) <<" "<< male[i];
	for ( i =( num_female - 1); i >= 0; i --)
		cout << fixed << setprecision(2) <<" "<< female[i];
	return 0;
}


/*
 * ????first.cpp
 * ???00948343_??
 * ?????2012/9/16
 * ?????1???100?????????
 */

int main(){
	int n, i, j;
	cin >> n;
	float male[n], female[n], height;
	int count_male=0, count_female=0;
	char gender[8];
	for (i=0;i<n;i++){
		cin >> gender >> height;
		if (strcmp(gender,"male")==0){
			male[count_male]=height;
			count_male++;
		}
		else{
			female[count_female]=height;
			count_female++;
		}
	}
	float temp;
	for (i=0;i<count_male-1;i++){
		for (j=0;j<count_male-1-i;j++){
			if (male[j]>male[j+1]){
				temp=male[j];
				male[j]=male[j+1];
				male[j+1]=temp;
			}
		}
	}
	for (i=0;i<count_female-1;i++){
		for (j=0;j<count_female-i-1;j++){
			if (female[j]<female[j+1]){
				temp=female[j];
				female[j]=female[j+1];
				female[j+1]=temp;
			}
		}
	}
	for (i=0;i<count_male;i++){
		cout << fixed << setprecision(2)<< male[i] << ' ';
	}
	for (i=0;i<count_female;i++){
		cout << fixed << setprecision(2) << female[i];
		if (i!=count_female-1)
			cout << ' ';
	}
	return 0;
}


int main(){
    int i,nanshu=0,nvshu=0,k,zongrenshu;
    double shengao;
    scanf("%d",&zongrenshu);
    double nanshengao[zongrenshu],nvshengao[zongrenshu],zhongjianliang;
    char xingbie[7],nv[7]="female",nan[5]="male";
    for(i=0;i<zongrenshu;i++){
        scanf("%s %lf",xingbie,&shengao);
        if(strcmp(xingbie,nv)==0){
            nvshengao[nvshu]=shengao;
            nvshu++;
        }else{
            nanshengao[nanshu]=shengao;
            nanshu++;
        }
    }
    for(i=1;i<=nanshu;i++){
        for(k=0;k<(nanshu-i);k++){
            if(nanshengao[k]>nanshengao[k+1]){
                zhongjianliang=nanshengao[k+1];
                nanshengao[k+1]=nanshengao[k];
                nanshengao[k]=zhongjianliang;
            }
        }
    }
    for(i=1;i<=nvshu;i++){
        for(k=0;k<(nvshu-i);k++){
            if(nvshengao[k]<nvshengao[k+1]){
                zhongjianliang=nvshengao[k+1];
                nvshengao[k+1]=nvshengao[k];
                nvshengao[k]=zhongjianliang;
            }
        }
    }
    for(i=0;i<nanshu;i++){
        printf("%.2lf ",nanshengao[i]);
    }
    for(i=0;i<(nvshu-1);i++){
        printf("%.2lf ",nvshengao[i]);
    }
    printf("%.2lf",nvshengao[nvshu-1]);
    return 0;
}


double h[100];

/*void swap(int x, int y) {
        double t;
        t = h[x];
        h[x] = h[y];
        h[y] = t;
    }

int partition(int l, int r) {
        int mark = l;
        for(int i = l; i < r; i++)
            if(h[l] <= h[r]) {
                swap(mark, i);
                mark++;
            }
        swap(mark, r);
        return mark;
    }

void sort(int l, int r) {
        if(l < r) {
            int q;
            q = partition(l, r);
            sort(l, q - 1);
            sort(q + 1, r);
        }
    }*/

void sort(int n) {
    int i, j;
    for(i = 0; i < n - 1; i++)
        for(j = 0; j < n - i - 1; j++)
            if(h[j] > h[j + 1]) {
                double t = h[j];
                h[j] = h[j + 1];
                h[j + 1] = t;
            }
}

int main() {
    int n;
    char in[10];
    scanf("%i", &n);
    for(int i = 0; i < n; i++) {
        scanf("%s%lf", in, &h[i]);
        if(strcmp(in,"male") != 0)
            h[i]= 1000000.0 - h[i];
    }
    sort(n);
    for(int i = 0; i < n; i++) {
        if(i)
            printf(" ");
        if(h[i] > 500000.0)
            printf("%.2lf", 1000000.0 - h[i]);
        else
            printf("%.2lf", h[i]);

    }
    return 0;
}


int main()
{
	int n,i,j,k=0,l=0;
	double a[1000],male[1000],female[1000],m;
	char sex[1000][10];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",sex[i]);
		scanf("%lf",&a[i]);
		if(sex[i][0]=='m')
		{
			male[k]=a[i];
			k++;
		}else if(sex[i][0]=='f')
		{
			female[l]=a[i];
			l++;
		}
	}
	for(i=0;i<k;i++)
	{
		for(j=i+1;j<k;j++)
		{
			if(male[i]>male[j])
			{
				m=male[j];
				male[j]=male[i];
				male[i]=m;
			}
		}
	}
	for(i=0;i<l;i++)
	{
		for(j=i+1;j<l;j++)
		{
			if(female[i]<female[j])
			{
				m=female[j];
				female[j]=female[i];
				female[i]=m;
			}
		}
	}
	for(i=0;i<k;i++)
	{
		printf("%.2lf ",male[i]);
	}
	for(j=0;j<l-1;j++)
	{
		printf("%.2lf ",female[j]);
	}
	printf("%.2lf",female[l-1]);
	return 0;
}


int main()
{
	int i,j,n,nm=0,nf=0;
	char c[50][10];
	float a[50];
	float male[50],female[50],temp;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%s %f",&c[i],&a[i]);
		if (c[i][0]=='m')
		{
			male[nm]=a[i];
			nm++;
		}
		else
		{
			female[nf]=a[i];
			nf++;
		}
	}
	for (i=0;i<nm-1;i++)
	{
		for (j=0;j<nm-1-i;j++)
		{
			if (male[j]>male[j+1])
			{
				temp=male[j];
				male[j]=male[j+1];
				male[j+1]=temp;
			}
		}
	}
	for (i=0;i<nf-1;i++)
	{
		for (j=0;j<nf-1-i;j++)
		{
			if (female[j]<female[j+1])
			{
				temp=female[j];
				female[j]=female[j+1];
				female[j+1]=temp;
			}
		}
	}
	for (i=0;i<nm;i++)
	{
		printf("%.2f ",male[i]);
	}
	for (i=0;i<nf-1;i++)
	{
		printf("%.2f ",female[i]);
	}
	printf("%.2f",female[i]);
	return 0;
}


int main()
{
	int n,i,j;
	float root[40],male[40],famale[40];
	char name[40][7];
	scanf("%d",&n);
	int k=0,p=0;
	for(i=0;i<n;i++)
	{
		scanf("%s %f",name[i],&root[i]);
		if(strcmp(name[i],"male")==0)
			male[k++]=root[i];
		else
			famale[p++]=root[i];
	}
	float t;
	for(i=0;i<k;i++)
	{
		for(j=0;j<k-1-i;j++)
		{
			if(male[j]>male[j+1])
			{
				t=male[j];
				male[j]=male[j+1];
				male[j+1]=t;
			}
		}
	}
	for(i=0;i<p;i++)
	{
		for(j=0;j<p-1-i;j++)
		{
			if(famale[j]<famale[j+1])
			{
				t=famale[j];
				famale[j]=famale[j+1];
				famale[j+1]=t;
			}
		}
	}
	for(i=0;i<k;i++)
		printf("%.2f ",male[i]);
	printf("%.2f",famale[0]);
	if(p==1);
	else
	{
		for(i=1;i<p;i++)
			printf(" %.2f",famale[i]);
	}
	printf("\n");
	return 0;
}


int main()
{
	int num;
	int b=0,g=0;
	double temp;
	char sex[40][10] = {NULL};
	double h[40] = {0.0};
	double boy[40] = {0.0};
	double girl[40] = {0.0};
	int i,j;
	cin>>num;
	for(i=0;i<num;i++)
		cin>>sex[i]>>h[i];
	for(i=0;i<num;i++)
	{
		if(!strcmp(sex[i],"male"))
		{
			boy[b] = h[i];
			b++;
		}
		if(!strcmp(sex[i],"female"))
		{
			girl[g] = h[i];
			g++;
		}

	}
	for(i=0;i<b-1;i++)
		for(j=i;j<b;j++)
		{
			if(boy[i]>boy[j])
			{
				temp = boy[j];
				boy[j] = boy[i];
				boy[i] = temp;
			}
		}
	for(i=0;i<g-1;i++)
		for(j=i;j<g;j++)
		{
			if(girl[i]<girl[j])
			{
				temp = girl[j];
				girl[j] = girl[i];
				girl[i] = temp;
			}
		}
	for(i=0;i<b;i++)
		printf("%.2f ",boy[i]);
	for(i=0;i<g;i++)
	{
		printf("%.2f",girl[i]);
		if(i<g-1)
			printf(" ");
	}

	return 0;
}


char sex[10];
double f[40];
double m[40];
int fsize;
int msize;
int desend(const void *a, const void *b)
{
	if(*((double*)a)>*((double*)b))
		return -1;
	else
		return 1;
}
int asend(const void *a, const void *b)
{
	if(*((double*)a)>*((double*)b))
		return 1;
	else
		return -1;
}
int main()
{
	int p; int i,j,k;
	double h;
	while(scanf("%d",&p)!=EOF)
	{
		fsize=msize=0;
		for(i=0;i<p;i++)
		{
			cin>>sex;
			cin>>h;
			if(strcmp(sex,"male")==0)
			{
				m[msize]=h;
				msize++;
			}
			else
			{
				f[fsize]=h;
				fsize++;
			}
		}
		qsort(f,fsize,sizeof(double),desend);
		qsort(m,msize,sizeof(double),asend);
		for(i=0;i<msize;i++)
			printf("%.2lf ",m[i]);
		for(i=0;i<fsize-1;i++)
			printf("%.2lf ",f[i]);
		printf("%.2lf\n",f[fsize-1]);
	}
	return 0;
}


int main(){
	struct std{
		char sex[7];
		double height;
	}ss[50];

	int n;
	scanf("%d",&n);
	double man[50];
	double wam[50];
    int i,j=0,m=0;
	for(i=0;i<n;i++){
	   scanf("%s",ss[i].sex);
	   scanf("%lf",&ss[i].height);
	   if(strcmp(ss[i].sex,"male")==0){
	   man[j]=ss[i].height;
	   j++;}
	   if(strcmp(ss[i].sex,"female")==0){
	   wam[m]=ss[i].height;
	   m++;}

	}
	int k,x;
	double e;
	for(k=1;k<=j;k++){
		for(x=0;x<j-k;x++){
			if(man[x]>man[x+1]){e=man[x];
			man[x]=man[x+1];
			man[x+1]=e;}

		}
	}
	for(k=1;k<=m;k++){
		for(x=0;x<m-k;x++){
			if(wam[x]<wam[x+1]){
			e=wam[x];
			wam[x]=wam[x+1];
			wam[x+1]=e;

			}

		}

	}
int a,b;
for(a=0;a<j;a++){printf("%.2lf ",man[a]);}
for(b=0;b<m-1;b++){printf("%.2lf ",wam[b]);}
printf("%.2lf",wam[m-1]);
return 0;
}


void main()
{
	int n,i,j,index_male=0,index_female=0;
	char sex[10];
	float *male,*female,temp;
	scanf("%d",&n);
	male=(float*)malloc(sizeof(float)*n);
	female=(float*)malloc(sizeof(float)*n);
	for(i=0;i<n;i++)
	{
		male[i]=0;
		female[i]=0;
	}

	for(i=0;i<n;i++)
	{
		scanf("%s",sex);
		if(strcmp(sex,"male")==0)
		{
			scanf("%f",&temp);
			male[index_male]=temp;
			index_male++;
		}
		else
		{
			scanf("%f",&temp);
			female[index_female]=temp;
			index_female++;
		}
	}
	for(i=0;i<n-1;i++)
	{
		for(j=0;j<n-1-i;j++)
		{
			if(male[j]>male[j+1])
			{
				temp=male[j];
				male[j]=male[j+1];
				male[j+1]=temp;
			}
			if(female[j]<female[j+1])
			{
				temp=female[j];
				female[j]=female[j+1];
				female[j+1]=temp;
			}
		}
	}

	for(i=0;i<n;i++)
	{
		if(male[i]!=0)
			printf("%3.2f",male[i]);
		if(male[i]!=0&&i+1<n&&male[i+1]!=0)
			printf(" ");
	}
         printf(" ");
	for(i=0;i<n;i++)
	{
		if(female[i]!=0)
			printf("%3.2f",female[i]);
		if(female[i]!=0&&i+1<n&&female[i+1]!=0)
			printf(" ");
	}

}


//xyx3.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"

int main()
{
	int fnum = 0, mnum = 0;
	int num;
	cin >> num;
	int i, j, k;
	float temp;
    float fe[50], ma[50];
	float height, res[50];
	char xinbie[50][10];
	for(i = 1; i <= num; i++)
	{
		scanf("%s %f", &xinbie[i], &height);
		if(xinbie[i][0] == 'f')
		{
			fnum += 1;
			fe[fnum] = height;
		}
		else
		{
			mnum += 1;
			ma[mnum] = height;
		}
	}

	for(i = fnum; i > 1; i--)
		for(j = 1; j<i; j++)
		{
			if(fe[j] > fe[j+1])
			{
				temp = fe[j];
				fe[j] = fe[j+1];
				fe[j+1] = temp;
			}
		}
	for(i = mnum; i > 1; i--)
		for(j = 1; j<i; j++)
		{
			if(ma[j] > ma[j+1])
			{
				temp = ma[j];
				ma[j] = ma[j+1];
				ma[j+1] = temp;
			}
		}

    char out[10];
	for(i = 1; i <= mnum ; i++)
	{
		printf("%.2f ", ma[i]);
	}
	for(i = fnum; i >= 2; i--)
	{
		printf("%.2f ", fe[i]);
	}
	printf("%.2f", fe[1]);
//	cin >> j;
	return 0;
}


double male[41];
double female[41];

int compare(const void* e1,const void* e2)
{
	double* p1=(double* )e1;
	double* p2=(double* )e2;
	if(*p1<*p2)
		return 0;
	else return 1;
}

int main()
{
	int nCase,i;
	int f=0,m=0;
	char sex[10];
	double height;
	scanf("%d",&nCase);
	for(i=0;i<nCase;i++)
	{
		scanf("%s %lf",sex,&height);
		if(sex[0]=='m')
		{
			male[m]=height;
			m++;
		}
		else
		{
			female[f]=height;
			f++;
		}
	}

	qsort(male,m,sizeof(double),compare);
	qsort(female,f,sizeof(double),compare);

	for(i=0;i<m;i++)
		printf("%.2f ",male[i]);
	for(i=f-1;i>0;i--)
		printf("%.2f ",female[i]);
	printf("%.2f\n",female[0]);
	return 0;
}


int nan[50],nv[50];

void paixu(int a[],int n)
{
	int i,j;
	int tmp;
	for(i=n-1;i>=0;i--)
	{
		for(j=0;j<i;j++)
		{
			if(a[j]>a[j+1])
			{
				tmp=a[j];
				a[j]=a[j+1];
				a[j+1]=tmp;
			}
		}
	}
}

int main()
{
	int nannum=0,nvnum=0;
	int n,i;
	double tmp;
	int flag=0;
	char str[100];
	scanf("%d",&n);
	while(n--)
	{
		scanf("%s %lf",str,&tmp);
		if(str[0]=='m')
			nan[nannum++]=tmp*1000;
		else
			nv[nvnum++]=tmp*1000;
	}
	paixu(nan,nannum);
	paixu(nv,nvnum);
	for(i=0;i<nannum;i++)
	{
		tmp=(double)nan[i]/1000;
		printf("%.2lf ",tmp);
	}
	for(i=nvnum-1;i>=0;i--)
	{
		tmp=(double)nv[i]/1000;
		if(i!=0)
			printf("%.2lf ",tmp);
		else
			printf("%.2lf",tmp);
	}
	printf("\n");
	return 0;
}


struct student{
	char sex[10];
	float h;
};
int main()
{
	int n;
	struct student stu1[40],stu2[40],t,stu[40];
	char str1[]="male",str2[]="female";
	int k1=0,k2=0;
	cin>>n;
	cin.get();
	for(int i=0;i<n;i++)
	{
		cin>>stu[i].sex>>stu[i].h;
		if(strcmp(stu[i].sex,str1)==0)
		{
			stu1[k1++]=stu[i];
		}
		if(strcmp(stu[i].sex,str2)==0)
		{
			stu2[k2++]=stu[i];
		}
	}
	for(int i=0;i<k1;i++)
	{
		for(int j=i+1;j<k1;j++)
		{
			if(stu1[i].h>stu1[j].h)
			{
				t=stu1[i];
				stu1[i]=stu1[j];
				stu1[j]=t;
			}
		}
	}
	for(int i=0;i<k2;i++)
	{
		for(int j=i+1;j<k2;j++)
		{
			if(stu2[i].h<stu2[j].h)
			{
				t=stu2[i];
				stu2[i]=stu2[j];
				stu2[j]=t;
			}
		}
	}
	for(int i=0;i<k1;i++)
	{
		cout<<fixed<<setprecision(2)<<stu1[i].h<<" ";
	}
	for(int i=0;i<k2-1;i++)
	{
		cout<<fixed<<setprecision(2)<<stu2[i].h<<" ";
	}
	cout<<stu2[k2-1].h<<endl;
	return 0;
}


int main(){
	int n;
	scanf("%d",&n);
	struct point{
		char a[10];
		double b;
	}sz[40];
	int i;
	for(i=0;i<n;i++){
		scanf("%s",sz[i].a);
		scanf("%lf",&sz[i].b);
	}
	int count1=0;
	for(i=0;i<n;i++){
		if(strcmp(sz[i].a,"male")==0){
			count1+=1;
		}
	}
	int count2=n-count1;
	double xsz[40];
	int k=0;
	for(i=0;i<n;i++){
		if(strcmp(sz[i].a,"male")==0){
			xsz[k]=sz[i].b;
			k+=1;
		}
	}
	int j;
	double p;
	for(j=1;j<=count1;j++){
		for(i=0;i<count1-j;i++){
			if(xsz[i]>xsz[i+1]){
				p=xsz[i];
				xsz[i]=xsz[i+1];
				xsz[i+1]=p;
			}
		}
	}
	int o=0;
	double xxsz[40];
	for(i=0;i<n;i++){
		if(strcmp(sz[i].a,"female")==0){
			xxsz[o]=sz[i].b;
			o+=1;
		}
	}
	double q;
	for(j=1;j<n-count1;j++){
		for(i=0;i<n-count1-j;i++){
			if(xxsz[i]<xxsz[i+1]){
				q=xxsz[i];
				xxsz[i]=xxsz[i+1];
				xxsz[i+1]=q;
			}
		}
	}
	for(i=0;i<count1;i++){
		printf("%.2lf ",xsz[i]);
	}
	for(i=0;i<n-count1-1;i++){
		printf("%.2lf ",xxsz[i]);
	}
	printf("%.2lf",xxsz[n-count1-1]);
	return 0;
}


int pfCompare(const void * elem1, const void * elem2)
{
    int *p1,*p2;
    p1=(int *)elem1;
    p2=(int *)elem2;
    return (*p2-*p1);
}

int main()
{
    int n,i,j,mi=0,fi=0;
    scanf("%d",&n);
    char s[7];
    float c;
    float m[40]={0};
    float f[40]={0};
    for(i=0;i<n;i++)
    {
        scanf("%s %f",s,&c);
        if(s[0]=='m')
        {m[mi]=c;mi++;}
        else
        {f[fi]=c;fi++;}
    }
//
    qsort(m,mi,sizeof(int),pfCompare);//for(i=0;i<mi;i++) printf ("%.2f ",m[i]);
    qsort(f,fi,sizeof(int),pfCompare);
    for(i=mi;i>0;i--)
    printf("%.2f ",m[i-1]);
    for(i=0;i<fi;i++)
    {
        if(i==(fi-1)) printf("%.2f",f[i]);
        else printf("%.2f ",f[i]);
    }
}


int main(int argc, char* argv[])
{
	int n,i,j,mp=0,fp=0;
	double male[40],female[40],h,tmp;
	scanf("%d",&n);
	char s[10];
	for(i=0;i<n;i++){
		scanf("%s",&s);
		scanf("%lf",&h);
		if(s[0]=='f'){
			female[fp]=h;
			fp++;
		}else{
			male[mp]=h;
			mp++;
		}
	}
	for(i=0;i<mp;i++){
		for(j=0;j<mp-1;j++){
			if(male[j]>male[j+1]){
				tmp=male[j];
				male[j]=male[j+1];
				male[j+1]=tmp;
			}
		}
	}
	for(i=0;i<fp;i++){
		for(j=0;j<fp-1;j++){
			if(female[j]<female[j+1]){
				tmp=female[j];
				female[j]=female[j+1];
				female[j+1]=tmp;
			}
		}
	}
	for(i=0;i<mp;i++){
		printf("%.2lf ",male[i]);
	}
	for(i=0;i<fp;i++){
		printf("%.2lf",female[i]);
		if(i!=fp-1){
			printf(" ");
		}
	}

	return 0;
}


/*
 * poj03.cpp
 *
 *  Created on: 2011-9-23
 *      Author: G199
 */

int main()
{
	int n, i, j, m, f;
	double male[50], female[50], h, temp;
	char sex[20];
	cin >> n;
	m = f = 0;
	while(n--)
	{
		cin >> sex >> h;
		if(sex[0] == 'm')
		{
			male[m++] = h;
		}
		else
		{
			female[f++] = h;
		}
	}
	for(i = 0; i < m; i++)
	{
		for(j = m-1; j > i; j--)
		{
			if(male[j-1] > male[j])
			{
				temp = male[j-1];
				male[j-1] = male[j];
				male[j] = temp;
			}
		}
	}
	for(i = 0; i < f; i++)
	{
		for(j = f-1; j > i; j--)
		{
			if(female[j-1] < female[j])
			{
				temp = female[j-1];
				female[j-1] = female[j];
				female[j] = temp;
			}
		}
	}
	for(i = 0; i < m; i++)
	{
		cout << fixed << setprecision(2) << male[i] << ' ';
	}
	for(i = 0; i < f-1; i++)
	{
		cout << fixed << setprecision(2) << female[i] << ' ';
	}
	cout << female[f-1] << endl;
	return 0;
}


void arrange(float *arrangearry,int nt,int kd_order)
{
	int flagi,flagj;
	float temporary;
	if(kd_order==1)
	{
		for(flagi=nt-1;flagi>0;flagi--)
		{
			for(flagj=0;flagj<flagi;flagj++)
			{
				if(arrangearry[flagj]<arrangearry[flagj+1])
				{
					temporary=arrangearry[flagj];
					arrangearry[flagj]=arrangearry[flagj+1];
					arrangearry[flagj+1]=temporary;
				}
			}
		}
	}
	else
	{
		for(flagi=nt-1;flagi>0;flagi--)
		{
			for(flagj=0;flagj<flagi;flagj++)
			{
				if(arrangearry[flagj]>arrangearry[flagj+1])
				{
					temporary=arrangearry[flagj];
					arrangearry[flagj]=arrangearry[flagj+1];
					arrangearry[flagj+1]=temporary;
				}
			}
		}
	}
}
int main()
{
	int i,n,len,male=0,female=0;
	float a[40],b[40],height;
	char sex[10];
	cin>>n;
	for(i=0;i<n;i++)
	{
		scanf("%s%f",sex,&height);
		len=strlen(sex);
		if(len==4)
		{
			a[male]=height;
			male++;
		}
		if(len==6)
		{
			b[female]=height;
			female++;
		}
	}
	arrange(a,male,0);
	arrange(b,female,1);
	printf("%.2f",a[0]);
	for(i=1;i<male;i++)
		printf(" %.2f",a[i]);
	for(i=0;i<female;i++)
		printf(" %.2f",b[i]);
	return 0;
}


float male[50];
int nm=0;
float fema[50];
int nf=0;

int mcmp(const void *a, const void *b)
{
	float x = *(float*)a;
	float y = *(float*)b;
	if(x>y) return 1;
	if(x==y) return 0;
	if(x<y) return -1;
}

int fcmp(const void *a, const void *b)
{
	return -mcmp(a,b);
}

void main()
{
	char buf[100];
	char *p;
	int n;
	int i;
	float a;

	fgets(buf, sizeof(buf), stdin);
	n=atoi(buf);
	for(;n>0;n--)
	{
		fgets(buf, sizeof(buf), stdin);
		p=strtok(buf, " ");
		a = atof(strtok(NULL, " "));
		if(strcmp(p,"male")==0)
			male[nm++]=a;
		else
			fema[nf++]=a;
	}

	qsort(male, nm, sizeof(float), mcmp);
	qsort(fema, nf, sizeof(float), fcmp);

	for(i=0;i<nm;i++)
		printf("%.2f ", male[i]);
	for(i=0;i<nf-1;i++)
		printf("%.2f ", fema[i]);
	printf("%.2f", fema[i]);

}


int main()
{
    int n,sum=0;
    float h[100];
    char gender[10];
    cin>>n;
    for (int i=1;i<=n;i++)
    {cin>>gender>>h[i];
    if (strcmp(gender,"male")==0)
    { h[i]=h[i]*10;
    sum++;}

    }
    sort(h+1,h+n+1);
    for (int i=n-sum+1;i<=n;i++)
    printf("%.2lf ",h[i]/10);
    for (int i=n-sum;i>=2;i--)
    printf("%.2lf ",h[i]);

    printf("%.2lf",h[1]);

    return 0;
}


void insertSort(float* arr,long len)
{
	long i=0,j=0;
	float tmpData;
	for(i=1;i<len;i++)
	{
		j=i;
		tmpData=*(arr + i);
		while(j > 0 && tmpData < arr[j-1])
		{
			arr[j]=arr[j-1];
			j--;
		}
		arr[j]=tmpData;
	}
}

int main()
{
	int n = 0;
	float male[40];
	float female[40];
	int maleNum = 0;
	int femaleNum = 0;
	char sex[10];
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%s", sex);
		if (strcmp(sex, "male") == 0)
			scanf("%f", &male[maleNum++]);
		else
			scanf("%f", &female[femaleNum++]);
	}

	insertSort(male, maleNum);
	insertSort(female, femaleNum);

	int i = 0;
	for (i = 0; i < maleNum - 1; ++i)
	{
		printf("%.2f ", male[i]);
	}
	printf("%.2f ", male[i]);

	for (i = femaleNum - 1; i > 0; --i)
	{
		printf("%.2f ", female[i]);
	}
	printf("%.2f", female[i]);

	return 0;
}


int main(){
int n,j,t,i,m,b,u,v,k,e;
double tall[45],man[40],woman[40],q;
char sex[8];
j=0;
t=0;
scanf("%d",&n);
for(i=0;i<n;i++){
     scanf("%s %lf",sex,&tall[i]);
     if(sex[0]=='m'){
        man[j]=tall[i];
        j++;}
        else{
        woman[t]=tall[i];
        t++;}
}
for(k=1;k<j;k++){
	for(e=0;e<j-k;e++){
		if(man[e]>man[e+1]){
        q=man[e];
		man[e]=man[e+1];
		man[e+1]=q;
		}
	}

}

for(u=1;u<t;u++){
	for(v=0;v<t-u;v++){
		if(woman[v]<woman[v+1]){
        q=woman[v];
		woman[v]=woman[v+1];
		woman[v+1]=q;
		}
	}

}
 for(m=0;m<j;m++)
 {
 printf("%.2lf ",man[m]);
 }

 for(b=0;b<t-1;b++)
 {
 printf("%.2lf ",woman[b]);
 }
 printf("%.2lf",woman[t-1]);
 return 0;
}


int cmp(const void * x,const void * y)
{
	return *(float *)x>*(float *)y?1:-1;
}
int main()
{
   // ifstream if1("e:\\input1.txt");
	int n,ptra=0,ptrb=0;
    float a[40],b[40];
	char s[10];
//	if1>>n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s;
	//	if1>>s;
		if(s[0]=='m')
			cin>>a[ptra++];
	//	if1>>a[ptra++];
		else
			cin>>b[ptrb++];
	//	if1>>b[ptrb++];
	}
    qsort(a,ptra,sizeof(float),cmp);
	qsort(b,ptrb,sizeof(float),cmp);
	for(int j=0;j<ptra;j++)
	{
	//	cout<<setprecision(3)<<a[j]<<" ";
		printf("%.2f ",a[j]);
	}
	for(int k=ptrb-1;k>0;k--)
	{
	//	cout<<setprecision(3)<<b[k]<<" ";
		printf("%.2f ",b[k]);
	}
//	cout<<setprecision(3)<<b[0];
			printf("%.2f",b[0]);
	return 0;
}


int main(){
    int n,i,f,m;
    char sex[40][7];
    double height[40],female[40],male[40],c;
    scanf("%d",&n);
    f=0;
    m=0;
    for(i=0;i<n;i++){
                     scanf("%s %lf",sex[i],&height[i]);
                     if(sex[i][0]=='f'){
                                        female[f]=height[i];
                                        f++;
                                        }
                     if(sex[i][0]=='m'){
                                        male[m]=height[i];
                                        m++;
                                        }
                                        }
    for(n=1;n<m;n++){
                     for(i=0;i<m-n;i++){
                                        if(male[i]>male[i+1]){
                                                              c=male[i];
                                                              male[i]=male[i+1];
                                                              male[i+1]=c;
                                                              }
                                                              }
                                                              }
    for(n=1;n<f;n++){
                     for(i=0;i<f-n;i++){
                                        if(female[i]<female[i+1]){
                                                              c=female[i];
                                                              female[i]=female[i+1];
                                                              female[i+1]=c;
                                                              }
                                                              }
                                                              }
    for(i=0;i<m;i++){
                     printf("%.2lf ",male[i]);
                     }
    for(i=0;i<f-1;i++){
                       printf("%.2lf ",female[i]);
                       }
    printf("%.2lf",female[i]);
    return 0;
}


char sex[45][7];
float height[45];
int seq[45];

int compare(const void* a, const void* b) {
	int i = *(int*)a;
	int j = *(int*)b;
	if( strcmp(sex[i],"male") == 0 && strcmp(sex[j],"female") == 0 )  return 0;
	if( strcmp(sex[i],"female") == 0 && strcmp(sex[j],"male") == 0 )  return 1;
	// else same sex
	if( strcmp(sex[i],"male") == 0 && strcmp(sex[j],"male") == 0 ) return height[i] > height[j];
	if( strcmp(sex[i],"female") == 0 && strcmp(sex[j],"female") == 0 ) return height[i] < height[j];
}

int main() {
	int n;
	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> sex[i] >> height[i];
		seq[i] = i;
	}
	qsort(seq,n,sizeof(int),compare);
	int startFlag = true;
	for(int i=0;i<n;i++) {
		if(startFlag) {
			printf("%.2f",height[seq[i]]);
			startFlag = false;
		} else {
			printf(" %.2f",height[seq[i]]);
		}
	}
	cout << endl;

}


int main()
{
	int n;
	cin >> n;

	double male[40], female[40];
	int indm=0, indf=0;
	for(int k=0;k<n;k++)
	{
		char str[10];

		cin >> str;
		if(!strcmp(str,"male"))
		{
			cin >> male[indm];
			indm++;
		}
		else
		{
			cin >> female[indf];
			indf++;
		}
	}
	//sort
	int i,j;
	for(i=0;i<indm;i++)
		for(j=i;j<indm;j++)
			if(male[i] > male[j])
			{
				double t = male[i];
				male[i] = male[j];
				male[j] = t;
			}
	for(i=0;i<indf;i++)
		for(j=i;j<indf;j++)
			if(female[i] < female[j])
			{
				double t = female[i];
				female[i] = female[j];
				female[j] = t;
			}
	//show
	for(i=0;i<indm;i++)
		printf("%.2lf ",male[i]);
	for(i=0;i<indf-1;i++)
		printf("%.2lf ",female[i]);
	printf("%.2lf",female[indf-1]);
	cout << endl;

	return 0;
}


int compare1(const void *elem1,const void *elem2)
{
    float *p1,*p2;
    p1=(float *)elem1;
    p2=(float *)elem2;
    if(*p1-*p2<0) return -1;
    else if(*p1-*p2>0) return 1;
    else return 0;
}
int compare2(const void *elem1,const void *elem2)
{
    float *p1,*p2;
    p1=(float *)elem1;
    p2=(float *)elem2;
    if(*p1-*p2<0) return 1;
    else if(*p1-*p2>0) return -1;
    else return 0;
}
main()
{
      int n,i=0,g,j=0,a,b;
      char c[100];
      float m[100],f[100];
      float h;
      scanf("%d",&n);
      for(g=0;g<n;g++)
      {
                      scanf("%s %f",c,&h);
                      if(c[0]=='m')
                      {
                                    m[i]=h;
                                    i++;
                      }
                      else
                      {
                           f[j]=h;
                           j++;
                      }
      }
      a=i;
      b=j;
      qsort(m,a,sizeof(float),compare1);
      qsort(f,b,sizeof(float),compare2);
      for(i=0;i<a;i++)
      {
                       if(i==0) printf("%.2f",m[i]);
                       else printf(" %.2f",m[i]);
      }
      for(j=0;j<b;j++)
      {
                       printf(" %.2f",f[j]);
      }

}


int main()
{
	int n,i,j,p=0,q=0;
	char tmp[10];
	double man[50],woman[50],temp;
	int flag=0;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%s",tmp);
		if(tmp[0]=='f')
		scanf("%lf",&woman[p++]);
		else scanf("%lf",&man[q++]);
	}
	for(i=p-1;i>0;i--)
	{
		for(j=0;j<i;j++)
		{
			if(woman[j]<woman[j+1])
			{
				temp=woman[j];
				woman[j]=woman[j+1];
				woman[j+1]=temp;
			}
		}
	}
	for(i=q-1;i>0;i--)
	{
		for(j=0;j<i;j++)
		{
			if(man[j]>man[j+1])
			{
				temp=man[j];
				man[j]=man[j+1];
				man[j+1]=temp;
			}
		}
	}
	for(i=0;i<q;i++)
	{
		if(flag==0) flag=1;
		else printf(" ");
		printf("%.2f",man[i]);
	}
	for(i=0;i<p;i++)
	{
		if(flag==0) flag=1;
		else printf(" ");
		printf("%.2f",woman[i]);
	}
}


void main(){
int n,i,j,min;
float re[40],t;
char str[40][8],tc[8];
scanf("%d",&n);
for(i=0;i<n;i++){
getchar();
scanf("%s%f",str[i],&re[i]);
}
for(i=0;i<n;i++){
min=i;
for(j=i;j<n;j++){
if(re[j]<re[min]){
min=j;
}
}
t=re[min];
strcpy(tc,str[min]);
re[min]=re[i];
strcpy(str[min],str[i]);
re[i]=t;
strcpy(str[i],tc);
}
for(i=0;i<n;i++){
if(str[i][0]=='m')
printf("%.2f ",re[i]);
}
i=n-1;
while(str[i][0]=='m')
i--;
printf("%.2f",re[i]);
for(i=i-1;i>=0;i--){
if(str[i][0]=='f')
printf(" %.2f",re[i]);
}
}


int main()
{
	struct a
	{
		char x[6];
		double y;
	}as[40],t;
	int n,i,k,I;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%s%lf",as[i].x,&as[i].y);
	for(k=0;k<n;k++)
	{
		for(i=1;i<n-k;i++)
		if(as[i].y<as[i-1].y)
		{
			t=as[i];
			as[i]=as[i-1];
			as[i-1]=t;
		}
	}
	for(i=0;i<n;i++)
	{
		if(strcmp(as[i].x,"male")==0) printf("%.2lf ",as[i].y);
	}
	for(i=n-1;i>=0;i--)
	{
		if(strcmp(as[i].x,"female")==0) {printf("%.2lf",as[i].y);I=i;break;}
	}
	for(i=I-1;i>=0;i--)
	{
		if(strcmp(as[i].x,"female")==0) printf(" %.2lf",as[i].y);
	}
	return 0;
}


int main()
{
	int n;
	cin>>n;
	char sex[100][30];
	double high[100];
	for(int i = 1; i <= n; ++i)
		cin >> sex[i] >> high[i];
	for(int i = 1; i <= n; ++i)
	{
		for(int t = 1; t <= n; ++t)
		{
			double s;
			char c[30];
			if(high[t] > high[i])
			{
				s=high[t];
				high[t]=high[i];
				high[i]=s;
				strcpy(c,sex[i]);
				strcpy(sex[i],sex[t]);
				strcpy(sex[t],c);
			}
		}
	}
	//for(int i = 1; i <= n; ++i) cout<<high[i]<<sex[i]<<endl;
	int step = 0;
	for(int i = 1; i <= n; ++i)
	{
		if(strcmp(sex[i],"female") == 0)
			continue;
		if(step != (n-1))
		{
			printf("%.2f ",high[i]);
			step = step + 1;
            //cout<<step<<endl;
		}
		else
			printf("%.2f",high[i]);
        //cout<<step<<endl;
	}

	for(int i = n; i >= 1; --i)
	{
		if(strcmp(sex[i],"male") ==0)
			continue;
		if(step != (n-1))
		{
			printf("%.2f ",high[i]);
			step = step + 1;
            //cout<<step<<endl;
		}
		else
			printf("%.2f",high[i]);
		//if(step == n) break;
		//cout<<step<<endl;
	}
	//while(1);
	return 0;
}


int cmp(const void *x,const void *y)
{
	return *(int*)x-*(int *)y;
}
int main()
{
	int n;
	scanf("%d",&n);
	int i=0,j,k,a=0,b=0;
	char sex[10];
	float man[40],woman[40],h;
	while(i<n)
	{
		scanf("%s %f",sex,&h);
		if(sex[0]=='m')
		{
			man[a]=h;
			a++;
		}
		else
		{
			woman[b]=h;
			b++;
		}
		i++;
	}
	qsort(man,a,sizeof(float),cmp);
	qsort(woman,b,sizeof(float),cmp);
	printf("%.2f",man[0]);
	for(k=1;k<a;k++)
		printf(" %.2f",man[k]);
	for(k=b-1;k>0;k--)
		printf(" %.2f",woman[k]);
	printf(" %.2f\n",woman[0]);
}


void main()
{
	int i,j,n,num=0;
	struct p{
		char sex[8];
		double ag;
	}a[300],temp;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %lf",a[i].sex,&a[i].ag);
	}
	for(i=0;i<n-1;i++){
		for(j=1;j<n-i;j++){
			if(strcmp(a[j-1].sex,"female")==0&&strcmp(a[j].sex,"female")==0){
				if(a[j-1].ag<a[j].ag){
					temp=a[j-1];
					a[j-1]=a[j];
					a[j]=temp;
				}
			}
			else if(strcmp(a[j-1].sex,"female")==0&&strcmp(a[j].sex,"male")==0){
				temp=a[j-1];
				a[j-1]=a[j];
				a[j]=temp;
			}
			else if(strcmp(a[j-1].sex,"male")==0&&strcmp(a[j].sex,"male")==0){
				if(a[j-1].ag>a[j].ag){
					temp=a[j-1];
					a[j-1]=a[j];
					a[j]=temp;
				}
			}
		}
	}
	for(i=0;i<n;i++)printf("%.2lf%c",a[i].ag,i==n-1?'\n':' ');
}


int com( const void * a , const void * b )
{
	double a1 = *(double*) a;
	double a2 = *(double*) b;

	if( a1 > a2 )
		return 1;
	else
		return 0;
}

int main()
{
	int i , j , k , r , ren , max , i_nan , i_nv ;
	char c;
	double nan[200];
	double nv[200];

	scanf( "%d" , &ren );
	getchar();

	i_nan = i_nv = 0;
	for( i = 0 ; i < ren ; i++ ){
		for( j = 0 ; j < 4 ; j++ ){
			c = getchar();
		}

		if( c == 'e' ){
			getchar();
			scanf( "%lf" , &nan[i_nan++] );
			getchar();
		}

		else{
			for( k = 0 ; k < 3 ; k++ )
				getchar();
			scanf( "%lf" , &nv[i_nv++] );
			getchar();
		}
	}

	qsort( (void*)nan , i_nan , sizeof( nan[0] ) , com  );
	qsort( (void*)nv , i_nv , sizeof( nv[0] ) , com  );

	for( i = 0 ; i < i_nan ; i++ ){
		printf( "%.2lf" , nan[i] );
		printf( " " );
	}
	for( j = i_nv-1 ; j >= 0 ; j-- ){
		printf( "%.2lf" , nv[j] );
		if( j != 0 )
			printf( " " );
		else
			printf( "\n" );
	}

	return 0;
}


int main(){
    double male[40]={0};
    double female[40]={0};
    char sex[10];
	int i,j,n;
	int m=0,f=0;
	double h,t;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s%lf",sex,&h);
		if(sex[0]=='m'){
           male[m]=h;
           m++;
        }else{
           female[f]=h;
           f++;
        }
	}
	for(i=1;i<=m;i++){
		for(j=0;j<m-i;j++){
			if(male[j]>male[j+1]){
				t=male[j];
				male[j]=male[j+1];
				male[j+1]=t;
			}
		}
    }
	for(i=1;i<=f;i++){
		for(j=0;j<f-i;j++){
			if(female[j]>female[j+1]){
				t=female[j];
				female[j]=female[j+1];
				female[j+1]=t;
			}
		}
	}
	printf("%.2lf",male[0]);
	for(i=1;i<m;i++){
		printf(" %.2lf",male[i]);
	}for(i=f-1;i>=0;i--){
		printf(" %.2lf",female[i]);
	}

   return 0;
}


int main ()
{
    char gender[10];
    float high_male[40], high_female[40];
    int counter_male = 0, counter_female = 0, n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> gender;
        switch (gender[0]){
            case 'f' : {
                cin >> high_female[counter_female];
                counter_female++;
                break;
            }
            case 'm' : {
                cin >> high_male[counter_male];
                counter_male++;
                break;
            }
        }
    }
    for (int i = 1; i <= counter_male; i++)
        for (int j = 0; j < counter_male-i; j++)
            if (high_male[j] > high_male[j+1]){
                float temp = high_male[j];
                high_male[j] = high_male[j+1];
                high_male[j+1] = temp;
            }
    for (int i = 1; i <= counter_female; i++)
        for (int j = 0; j < counter_female-i; j++)
            if (high_female[j] < high_female[j+1]){
                float temp = high_female[j];
                high_female[j] = high_female[j+1];
                high_female[j+1] = temp;
            }
    for (int i = 0; i < counter_male; i++) cout << fixed << setprecision(2) << high_male[i] << " ";
    for (int i = 0; i < counter_female-1; i++) cout << high_female[i] << " ";
    cout << high_female[counter_female-1];
    return 0;
}


int main()
{
	int n,i,k=0,j=0,t;
	struct ren{
		char sex[41];
		double high;
	}xue[41],huan,man[41],woman[41];

scanf("%d",&n);
		for(i=0;i<n;i++){
scanf("%s %lf",&xue[i].sex,&xue[i].high);
		}
		for(i=0;i<n;i++){
			if(strcmp(xue[i].sex,"male")==0){
			man[k]=xue[i];
			k++;
			}
			if(strcmp(xue[i].sex,"female")==0){
				woman[j]=xue[i];
				j++;
			}
		}
		for(i=0;i<k;i++){
			for(t=0;t<k-i-1;t++){
				if(man[t].high>man[t+1].high){
			huan=man[t];
			man[t]=man[t+1];
			man[t+1]=huan;
				}
			}
		}

		for(i=0;i<j;i++){
			for(t=0;t<j-i-1;t++){
				if(woman[t].high<woman[t+1].high){
			huan=woman[t];
			woman[t]=woman[t+1];
			woman[t+1]=huan;
				}
			}
		}
		for(t=0;t<k;t++){
		printf("%.2lf ",man[t].high);
		}
		for(t=0;t<j-1;t++){
		printf("%.2lf ",woman[t].high);
		}
		printf("%.2lf",woman[j-1].high);
		return 0;
}


int mao(double * a,int n)
{
    double tmp=0;
    for (int i=0;i<n;i++)
    {
        for (int j=1;j<n;j++)
        {
            if (a[j]<a[j-1]){ tmp=a[j];a[j]=a[j-1]; a[j-1]=tmp;}
        }
    }
    return 0;
}
int mao1(double * a,int n)
{
    double tmp=0;
    for (int i=0;i<n;i++)
    {
        for (int j=1;j<n;j++)
        {
            if (a[j]>a[j-1]){ tmp=a[j];a[j]=a[j-1]; a[j-1]=tmp;}
        }
    }
    return 0;
}
int main()
{
    double m[40],f[40],r;
    int n,i;
    int ml=0,fl=0;
    char type[10];
    cin>>n;
    for (i=0;i<n;i++)
    {
        scanf("%s%lf",type,&r);
        if (type[0]=='m') m[ml++]=r;
        else f[fl++]=r;
    }
    mao(m,ml);
    mao1(f,fl);
    for (i=0;i<ml;i++)
    printf("%.2lf ",m[i]);
    printf("%.2lf",f[0]);
    for (i=1;i<fl;i++)
    printf(" %.2lf",f[i]);
    cout<<endl;

    return 0;
}


main()
{
 struct student
 {
  char sex[6];
  float height;
 }stu[40];
 int n, bnum=0, gnum=0;
 int i, j;
 float temp;
 float boy[40], girl[40];
 scanf("%d", &n);
 for (i=0; i<n; i++)
 {
  scanf("%s", stu[i].sex);
  scanf("%f", &stu[i].height);
  if (strcmp(stu[i].sex, "female")>0)
  {
   boy[i-gnum]=stu[i].height;
   bnum++;
  }
  else
  {
   girl[i-bnum]=stu[i].height;
   gnum++;
  }
 }

 for (i=0; i<bnum; i++)
 {
  for (j=bnum-1; j>i; j--)
  {
   if (boy[j]<boy[j-1])
   {
    temp=boy[j-1];
    boy[j-1]=boy[j];
    boy[j]=temp;
   }
  }
 }

 for (i=0; i<gnum; i++)
 {
  for (j=gnum-1; j>i; j--)
  {
   if (girl[j]>girl[j-1])
   {
    temp=girl[j-1];
    girl[j-1]=girl[j];
    girl[j]=temp;
   }
  }
 }

 for (i=0; i<bnum; i++)
     printf("%.2f ", boy[i]);
 for (i=0; i<gnum-1; i++)
     printf("%.2f ", girl[i]);
 printf("%.2f", girl[gnum-1]);

 }


int main()
{
    int n,i,j,nan=0,nv=0;
    char s[10];
    double h,male[40],female[40];
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
         scanf("%s%lf",s,&h);
         if(strlen(s)==4)
         {
             nan++;
             male[nan-1]=h;
         }else if(strlen(s)==6){
             nv++;
             female[nv-1]=h;
         }
    }
    for(i=1;i<=nan;i++)
    {
         for(j=0;j<nan-i;j++)
         {
             if(male[j]>male[j+1])
             {
                 double e;
                 e=male[j];
                 male[j]=male[j+1];
                 male[j+1]=e;
             }
         }
    }
    for(i=1;i<=nv;i++)
    {
         for(j=0;j<=nv-i;j++)
         {
             if(female[j]<female[j+1])
             {
                 double e;
                 e=female[j];
                 female[j]=female[j+1];
                 female[j+1]=e;
             }
         }
    }
    printf("%.2lf",male[0]);
    for(i=1;i<nan;i++)
    {
                      printf(" %.2lf",male[i]);
    }
    for(i=0;i<nv;i++)
    {
                      printf(" %.2lf",female[i]);
    }
    return 0;
}


int cmp(const void* a,const void * b)
{   float x=*(float*)a;
    float y=*(float*)b;
	if(x>y)
	 return 1;
	 else return -1;
	}

int main()
{
	int n;
	scanf("%d",&n);
  float s1[50];
  float s2[50];
	    int m=0,f=0;
	for(int i=0;i<n;i++)
	{   	char sex[10];
	    float h;
		cin>>sex>>h;
		if(strcmp(sex,"male")==0)
		{s1[m]=h;
		 m++;}
		if(strcmp(sex,"female")==0)
		{s2[f]=h;f++;}

		}
	qsort(s1,m,sizeof(s1[0]),&cmp);
	qsort(s2,f,sizeof(s2[0]),&cmp);
	for(int i=0;i<m;i++)
	printf("%.2f ",s1[i]);
	for(int i=f-1;i>0;i--)
		printf("%.2f ",s2[i]);
	printf("%.2f",s2[0]);
	}


main()
{
    int n,i,j,k;
    double w;
    scanf("%d",&n);
    char sex[100][100];
    double height1[100];
    double height3[100];
    double height2[100];
    for(i=0;i<n;i++)
    {
        char b[100];
        scanf("%s",sex[i]);
        scanf("%lf",&height1[i]);
    }
    char *p={"female"};
    int count1=0;
    int count2=0;
    j=0;
    k=0;
    for(i=0;i<n;i++)
    {
        if(strcmp(sex[i],p)==0)
        {
            count1++;
            w=height1[i];//???2
            height2[j]=w;
            j++;
        }
        else
        {
            count2++;
            w=height1[i];//???3
            height3[k]=w;
            k++;
        }
    }
    /*qsort(height2,count1,sizeof(double),cmp);
    qsort(height3,count2,sizeof(double),cmp);
    for(i=0;i<count1;i++)
    printf("%.2f ",height2[i]);
    for(j=0;j<count2;j++)
    printf("~%.2lf~",height3[j]);
    printf("%d %d",count1,count2);*/
    for(i=0;i<count1;i++)
    {
        for(j=i;j<count1;j++)
        {
            if(height2[i]<height2[j])
            {
                double m;
                m=height2[j];
                height2[j]=height2[i];
                height2[i]=m;
            }
        }
    }
    for(i=0;i<count2;i++)
    {
        for(j=i;j<count2;j++)
        {
            if(height3[i]>height3[j])
            {
                double m;
                m=height3[j];
                height3[j]=height3[i];
                height3[i]=m;
            }
        }
    }
    for(i=0;i<count2;i++)
    printf("%.2lf ",height3[i]);
    for(i=0;i<count1-1;i++)
    printf("%.2lf ",height2[i]);
    printf("%.2lf",height2[count1-1]);
}


int main()

{

int n,m,o,i,j;

double a[81]={0};
double male[50],female[50];

char b[41][7];

cin>>n;

m=0;
o=0;
for(i=1;i<=n;i++)
{
cin>>b[i];
if(b[i][0]=='m')
{
	m++;
	cin>>male[m];
}
 if(b[i][0]=='f')
{
o++;
cin>>female[o];
}
}

/*double x;
for(i=1;i<=m-1;i++)
{
for(j=m;j>i;j--)
{
if(male[j]<male[j-1])
{
x=male[j];
male[j]=male[j-1];
male[j-1]=x;
}
}
}

for(i=1;i<=o-1;i++)
{
for(j=o;j>i;j--)
{
if(female[j]>female[j-1])
{
x=female[j];
female[j]=female[j-1];
female[j-1]=x;
}
}

}
*/
sort(male+1,male+m+1);
sort(female+1,female+o+1);
for(i=1;i<=m;i++)

{

cout<<fixed;
cout<<setprecision(2)<<male[i]<<" ";

}
for(i=o;i>=2;i--)

{

cout<<fixed;
cout<<setprecision(2)<<female[i]<<" ";

}
if(o>0)
{cout<<fixed;

cout<<setprecision(2)<<female[1]<<endl;
}
return 0;
}


int main()
{
	double  boy[40],girl[40],m;
	int  n,c1=0,c2=0,j,k;
	cin>>n;
	char a[10];

	for (int i=0;i<n;i++)
	{
		cin>>a;
		if (a[0]=='m')
		{
			cin>>boy[c1];
			c1++;
		}
		else if (a[0]=='f')
		{
			cin>>girl[c2];
			c2++;
		}
	}

	for (j=0;j<c1-1;j++)
	{
		for ( k=c1-1;k>j;k--)
		{
			if (boy[k]<boy[k-1])
			{
				m=boy[k];boy[k]=boy[k-1];boy[k-1]=m;
			}
		}
	}

	for (j=0;j<c2-1;j++)
	{
		for ( k=c2-1;k>j;k--)
		{
			if (girl[k]>girl[k-1])
			{
				m=girl[k];girl[k]=girl[k-1];girl[k-1]=m;
			}
		}
	}

	cout<<fixed<<setprecision(2)<<boy[0];
	for (j=1;j<c1;j++)
	{
		cout<<fixed<<setprecision(2)<<" "<<boy[j];
	}
	for (j=0;j<c2;j++)
	{
		cout<<fixed<<setprecision(2)<<" "<<girl[j];
	}
	cout<<endl;
	return 0;
}


int cmp(const void *p1,const void *p2)
{
	if(*(float*)p1<*(float*)p2) return -1;
	else if(*(float*)p1>*(float*)p2) return 1;
	else return 0;
}

void photo(float *a,float *b,int n)
{
	int x=0,y=0,i;
	char s[7];
	for(i=0;i<n;i++)
	{
		scanf("%s",s);
		getchar();
		if(s[4]=='\0')
		{
			scanf("%f",a+x);
			x++;
		}
		else
		{
			scanf("%f",b+y);
			y++;
		}
		getchar();
	}
	qsort(a,x,sizeof(float),cmp);
	qsort(b,y,sizeof(float),cmp);
	for(i=0;i<x;i++) printf("%.2f ",a[i]);
	for(i=y-1;i>0;i--) printf("%.2f ",b[i]);
	printf("%.2f",b[0]);
}

main()
{
	float a[40],b[40];
	int n;
	scanf("%d\n",&n);
	photo(a,b,n);
}


int compare(void const *p,void const *q)
{
     if (*(double*)p>*(double*)q)
     return 1;
     else
     return -1;
}
 main()
{
    int n,i,j,k;
    double a[40];
    double b[40];
    double d[40];
    char c[40][4];
    k=0;
    j=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s %lf",&c[i],&d[i]);
        if(c[i][0]=='m')
        {
        a[j]=d[i];
        j++;
        }
        else
        {
         b[k]=d[i];
         k++;
        }
    }
    qsort(a,j,sizeof(double),compare);
    qsort(b,k,sizeof(double),compare);
    printf("%0.2lf",a[0]);
    for(i=1;i<j;i++)
    {
     printf(" %0.2lf",a[i]);
    }
    for(i=k-1;i>-1;i--)
    {
     printf(" %0.2lf",b[i]);
    }
}


int cprx(const void *e1,const void *e2)
{
    float *a,*b;
    a=(float *)e1;
    b=(float *)e2;
    if (*a-*b<0) return -1;
    else return 1;
}
int cprd(const void *e1,const void *e2)
{
    float *a,*b;
    a=(float *)e1;
    b=(float *)e2;
    if (*a-*b>0) return -1;
    else return 1;
}
int main()
{
   float male[40],female[40],tmph;
   int m=0,f=0,n,i;
   char sex[10];
   scanf("%d",&n);
   for (i=0;i<n;i++)
   {
       scanf("%s %f",sex,&tmph);
       if (sex[0]=='m') male[m++]=tmph;
       else female[f++]=tmph;
   }
   qsort(male,m,sizeof(float),cprx);
   qsort(female,f,sizeof(float),cprd);
   for (i=0;i<m;i++)
     printf("%.2f ",male[i]);
   for (i=0;i<f-1;i++)
     printf("%.2f ",female[i]);
   printf("%.2f",female[i]);
   return 0;
}


int main(){
	int n;
	char zfc[1000][7];
	double sg[100];
	double nsg[100];
	double nvsg[100];
	int nsm=0;
	int nvsm=0;
	int k,i;
	int e=0;
	int s=0;
	double r,t;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s%lf",&zfc[i],&sg[i]);
	}
	for(i=0;i<n;i++){
		if(zfc[i][0]=='m'){
			nsm=nsm+1;
			e=e+1;
			nsg[e-1]=sg[i];
		}else if(zfc[i][0]=='f'){
			nvsm=nvsm+1;
			s=s+1;
			nvsg[s-1]=sg[i];
		}
	}
	for(k=0;k<nsm;k++){
		for(i=0;i<nsm-1-k;i++){
			if(nsg[i]>nsg[i+1]){
					r=nsg[i+1];
					nsg[i+1]=nsg[i];
					nsg[i]=r;
			}
		}
	}
	for(k=0;k<nvsm;k++){
		for(i=0;i<nvsm-1-k;i++){
			if(nvsg[i]<nvsg[i+1]){
					t=nvsg[i+1];
					nvsg[i+1]=nvsg[i];
					nvsg[i]=t;
			}
		}
	}
	for(i=0;i<nsm;i++){
		printf("%.2lf ",nsg[i]);
	}
	for(i=0;i<nvsm-1;i++){
		printf("%.2lf ",nvsg[i]);
	}
	printf("%.2lf",nvsg[nvsm-1]);
	return 0;
}


struct paixu{
       char sex[6];
       float height;
};
typedef struct paixu Paixu;
void bubble1(Paixu*,int);
void bubble2(Paixu*,int,int);
main()
{
   Paixu a[40],b[40];
   int n,i,k=0,m;
   scanf("%d",&n);
   for(i=0;i<=n-1;i++)
   scanf("%s %f",&a[i].sex,&a[i].height);
   for(i=0;i<=n-1;i++)
   if(a[i].sex[0]=='m')
   {
                       b[k]=a[i];
                       k++;
   }
   m=k;
   for(i=0;i<=n-1;i++)
   if(a[i].sex[0]=='f')
   {
                       b[k]=a[i];
                       k++;
   }
   bubble1(b,m);
   bubble2(b,m,n);
   for(i=0;i<=n-1;i++)
   {
                      printf("%.2f",b[i].height);
                      if(i!=n-1)
                      printf(" ");
   }
}
void bubble1(Paixu b[],int m)
{
     int pass,i;
     Paixu hold;
     for(pass=1;pass<=m-1;pass++)
     for(i=0;i<=m-2;i++)
     if(b[i].height>b[i+1].height)
     {
                 hold=b[i];
                 b[i]=b[i+1];
                 b[i+1]=hold;
     }
}
void bubble2(Paixu b[],int m,int n)
{
     int pass,i;
     Paixu hold;
     for(pass=1;pass<=n-m;pass++)
     for(i=m;i<=n-2;i++)
     if(b[i].height<b[i+1].height)
     {
                 hold=b[i];
                 b[i]=b[i+1];
                 b[i+1]=hold;
     }
}


main()
{
      int n,i=0,j=0,h=0,p,q,m;
      scanf("%d",&n);
      char string[]="male";
      char sex[n][6];
      float height[n],male[n],female[n];
      float change;
      while(i<n){
                 scanf("%s %f",&sex[i],&height[i]);
                 i++;
                 }
      for(i=0;i<n;i++){
                       if(strcmp(sex[i],string)==0){
                                                    male[j]=height[i];
                                                    j++;
                                                    }
                       else{
                            female[h]=height[i];
                            h++;
                            }
                       }
      for(p=0;p<=j;p++){
                       m=j-1;
                       while(m>0){
                                  if(male[m]<=male[m-1]){
                                                         change=male[m];
                                                         male[m]=male[m-1];
                                                         male[m-1]=change;
                                                         }
                                   m=m-1;
                                   }
                       }
      for(p=0;p<=h;p++){
                       m=h-1;
                       while(m>0){
                                  if(female[m]<=female[m-1]){
                                                             change=female[m];
                                                             female[m]=female[m-1];
                                                             female[m-1]=change;
                                                             }
                                   m=m-1;
                                   }
                       }
      for(p=0;p<j;p++){
                       printf("%.2f ",male[p]);
                       }
      for(p=h-1;p>0;p--){
                         printf("%.2f ",female[p]);
                         }
      printf("%.2f",female[0]);}


int main()
{
	float temp, male[40], female[40];
	int n, i, j, p, q;
	char sex[8];
	cin >> n;
	for (i = 0, p = 0, q = 0; i < n; i++)
	{
		cin >> sex >> temp;
		if (strcmp(sex, "male") == 0)
		{
			male[p] = temp;
			p++;
		}
		else
		{
			female[q] = temp;
			q++;
		}
	}
	for (i = 0; i < p - 1; i++)
		for (j = 0; j < p - 1 - i; j++)
		{
			if (male[j] > male[j + 1])
			{
				temp = male[j];
				male[j] = male[j + 1];
				male[j + 1] = temp;
			}
		}
	for (i = 0; i < q - 1; i++)
		for (j = 0; j < q - 1 - i; j++)
		{
			if (female[j] < female[j + 1])
			{
					temp = female[j];
					female[j] = female[j + 1];
					female[j + 1] = temp;
			}
		}
	cout << fixed << setprecision(2) << male[0];
	for (i = 1; i < p; i++)
		cout << fixed << setprecision(2) << " " << male[i];
	for (i = 0; i < q; i++)
		cout << fixed << setprecision(2) << " " << female[i];
	return 0;
}


int main()
{
    char sex[10];
    int n=0,count=0,count1=0,count2=0;
    int boy_num=0,girl_num=0;
    double temp,height,boy[40],girl[40];
    scanf("%d",&n);

    for(count=0;count<n;++count)
    {
        scanf("%s%lf",sex,&height);
        if(!strcmp(sex,"male")){
            boy[boy_num]=height;
            boy_num++;
        }else {
            girl[girl_num]=height;
            girl_num++;
        }
    }
    //????  ??
    for(count1=0;count1<boy_num;++count1)
    {
        for(count2=0;count2<boy_num-count1-1;++count2)
        {
            if(boy[count2]>boy[count2+1])
            {
                temp = boy[count2];
                boy[count2]=boy[count2+1];
                boy[count2+1] = temp;
            }
        }
    }
     //????  ??
    for(count1=0;count1<girl_num;++count1)
    {
        for(count2=0;count2<girl_num-count1-1;++count2)
        {
            if(girl[count2]<girl[count2+1])
            {
                temp = girl[count2];
                girl[count2]=girl[count2+1];
                girl[count2+1] = temp;
            }
        }
    }
    for(count=0;count<boy_num;++count)
    {
        printf("%.2f ",boy[count]);
    }
    for(count=0;count<girl_num-1;++count)
    {
        printf("%.2f ",girl[count]);
    }
    printf("%.2f",girl[count]);
}


struct info{
	double height;
	char sex[10];
}p[41];
double pm[41],pf[41];

int comp_m(const void *a,const void *b){
	return (*((double*)a)-*((double*)b))>0?1:(*((double*)a)-*((double*)b)<0?-1:0);
}

int comp_f(const void *a,const void *b){
	return (*((double*)b)-*((double*)a))>0?1:(*((double*)b)-*((double*)a)<0?-1:0);
}

int main(){
	int n;
	int i;
	int index_m,index_f;
	while(cin>>n){
		index_m=0;
		index_f=0;
		for(i=0;i<n;i++){
			cin>>p[i].sex>>p[i].height;
			if(!strcmp(p[i].sex,"male")){
				pm[index_m++]=p[i].height;
			}
			else{
				pf[index_f++]=p[i].height;
			}
		}
		qsort(pm,index_m,sizeof(double),comp_m);
		qsort(pf,index_f,sizeof(double),comp_f);
		for(i=0;i<index_m;i++){
			printf("%.2f ",pm[i]);
		}
		for(i=0;i<index_f-1;i++){
			printf("%.2f ",pf[i]);
		}
		printf("%.2f",pf[i]);
	}
	return 0;
}


int main()
{
	char sex[40][6];
	float height[40], Female[40], Male[40], temp1, temp2;
	int i, p, j = 0, k = 0, n;

	cin >> n;
	for (i = 0; i < n; i ++)
	{
		cin >> sex[i];
		cin >> height[i];
	}

	for (i = 0; i < n; i ++)
	{
		if (sex[i][0] == 'f')
		{
			Female[j] = height[i];
			j ++;
		}
		else if (sex[i][0] == 'm')
		{
			Male[k] = height[i];
			k ++;
		}
	}
	// ??????

	for (i = 0; i < k - 1; i ++)
	{
		for (p = 0; p < k - 1 - i; p ++)
		{
			if (Male[p] > Male[p+1])
			{
				temp1 = Male[p];
				Male[p] = Male[p+1];
				Male[p+1] = temp1;
			}
		}
	}
	for (i = 0; i < j - 1; i ++)
	{
		for (p = 0; p < j - 1 - i; p ++)
		{
			if (Female[p] < Female[p+1])
			{
				temp2 = Female[p];
				Female[p] = Female[p+1];
				Female[p+1] = temp2;
			}
		}
	}
	// ??,?????

	for (i = 0; i < k; i ++)
	{
		cout << fixed << setprecision(2) << Male[i] << " ";
	}
	for (i = 0; i < j; i ++)
	{
		if (i < j - 1)
			cout << fixed << setprecision(2) << Female[i] << " ";
		else
			cout << fixed << setprecision(2) << Female[i];
	}
	// ???????????

	return 0;
}


int main()
{
    int n,i;
    float h;
    char str[10];
    int k=0,j=0;
    float male[40],famale[40];
    male[0]=0;
    famale[0]=0;
    cin >> n;
    int len;
    for (i=1;i<=n;i++)
    {
        cin >> str >> h;
        len=strlen(str);
        if (len==4)
        {
                      k++;
                      male[k]=h;
        }
        else
        {
                      j++;
                      famale[j]=h;
        }
    }
        int p,q;
        float temp;
        for (p=1;p<=k-1;p++)
        {
            for (q=1;q<=k-p;q++)
            {
                if (male[q]>male[q+1])
                {
                                      temp=male[q+1];
                                      male[q+1]=male[q];
                                      male[q]=temp;
                }
            }
        }
        for (p=1;p<=j-1;p++)
        {
            for (q=1;q<=j-p;q++)
            {
                if (famale[q]>famale[q+1])
                {
                                      temp=famale[q+1];
                                      famale[q+1]=famale[q];
                                      famale[q]=temp;
                }
            }
        }
        printf("%.2f",male[1]);
        for (p=2;p<=k;p++)
        {
            cout << " " ;
            printf("%.2f",male[p]);

        }
        for (q=j;q>=1;q--)
        {
            cout << " " ;
            printf("%.2f",famale[q]);
        }

        return 0;
    }


int cmp1(float a,float b)
{
	if(a>b)
		return 1;
	else
		return 0;
}
int cmp2(float a,float b)
{
	if(a<b)
		return 1;
	else
		return 0;
}
float mail[1000];
float femail[1000];
char sex[1000];
int main()
{
	//freopen("D:\\1.txt","r",stdin);
	int N;
	cin>>N;
	int i,j,k;
	j=0;
	k=0;
	float temp;
	for(i=0;i<N;i++)
	{
		cin>>sex;
		cin>>temp;
		if(strcmp(sex,"male")==0)
			mail[j++]=temp;
		else
			if(strcmp(sex,"female")==0)
			femail[k++]=temp;
	}
	sort(mail,mail+j,cmp1);
	sort(femail,femail+k,cmp1);
	for(i=j-1;i>=0;i--)
		printf("%.2f ",mail[i]);
	for(i=0;i<k;i++)
		if(i!=k-1)
		printf("%.2f ",femail[i]);
		else
			printf("%.2f\n",femail[i]);
	return 0;
}


int sf(const void* a, const void* b)
{
	if((*((double*)a)) > (*((double*)b)))
		return 1;
	if((*((double*)a)) < (*((double*)b)))
		return -1;
	return 0;
}

int main()
{
	int i;
	int n;
	double f[40], m[40];
	int fn = 0, mn = 0;
	char str[20];
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		scanf("%s", str);
		if(str[0] == 'f')
			scanf("%lf", &f[fn++]);
		else
			scanf("%lf", &m[mn++]);
	}
	qsort(f, fn, sizeof(double), sf);
	qsort(m, mn, sizeof(double), sf);
	for(i = 0; i < mn; i++)
		printf("%.2lf ", m[i]);
	for(i = fn - 1; i > 0; i--)
		printf("%.2lf ", f[i]);
	if(fn > 0)
		printf("%.2lf", f[0]);
	return 0;
}


int main ()
{
    char flag[10];
    float temp;
    float boy[1000], girl[1000];
    int k, i, j = 0, z = 0, lenb = 0, leng = 0, n;
    cin >> n;
    for (k = 0 ; k < n; k++)
    {
        cin >> flag;
        if (strcmp(flag, "female") == 0)
        {
            leng++;
            cin >> girl[j++];
        }
        else
        {
            lenb++;
            cin >> boy[z++];
        }
    }
    for (i = 0; i < lenb - 1; i++)
        for (j = 0; j < lenb - 1 - i; j++)
        {
            if (boy[j] > boy[j + 1])
            {
                temp = boy[j]; boy[j] = boy[j + 1]; boy[j + 1] = temp;
            }
        }

    for (i = 0; i < leng - 1; i++)
        for (j = 0; j < leng - 1 - i; j++)
        {
            if (girl[j] < girl[j + 1])
            {
                temp = girl[j]; girl[j] = girl[j + 1]; girl[j + 1] = temp;
            }
        }
    cout << fixed;
    for (i = 0; i < lenb; i++)
        cout << setprecision(2) << boy[i] << ' ';
    for (i = 0; i < leng - 1; i++)
        cout << setprecision(2) << girl[i] << ' ';

    cout << setprecision(2) << girl[i];

    return 0;
}


int main(){
	int n,i,k,malenum=0;
	double h0[40],hmale[40],hfe[40],e;
	char stu0[40][10],male[5]="male";
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s%lf",stu0[i],&h0[i]);
		hmale[i]=100;
		hfe[i]=0;
		if(strcmp(stu0[i],male)==0){
			hmale[i]=h0[i];
			malenum++;
		}else{
			hfe[i]=h0[i];
		}
	}
	for(k=1;k<=n;k++){
		for(i=0;i<n-k;i++){
			if(hmale[i]>hmale[i+1]){
				e=hmale[i+1];
				hmale[i+1]=hmale[i];
				hmale[i]=e;
			}
		}
	}
	for(i=0;i<malenum;i++){
		printf("%.2lf ",hmale[i]);
	}
	for(k=1;k<=n;k++){
		for(i=0;i<n-k;i++){
			if(hfe[i]<hfe[i+1]){
				e=hfe[i+1];
				hfe[i+1]=hfe[i];
				hfe[i]=e;
			}
		}
	}
	for(i=0;i<n-malenum-1;i++){
		printf("%.2lf ",hfe[i]);
	}
	printf("%.2lf",hfe[n-malenum-1]);
	return 0;
}


int main()
{
	int n, i, p, j = 0, k = 0;
	double tempHeight;
	cin >> n;
	struct student
	{
		char sex[7];
		double height;
	}student[41];

	int count = 0;
	double maleHeight[41] = {0}, femaleHeight[41] = {0};
	for(i = 0; i < n; i++)
	{
		cin >> student[i].sex >> student[i].height;
		if(student[i].sex[0] == 'm')
			count++;
	}

	for(i = 0; i < n; i++)
	{
		if(student[i].sex[0] == 'm')
			maleHeight[i] = student[i].height;
		if(student[i].sex[0] == 'f')
			femaleHeight[i] = student[i].height;
	}

	for(i = 0; i < n - 1; i++)
	{
		for(p = 0; p < n - 1 - i; p++)
		{
			if(maleHeight[p] > maleHeight[p + 1])
			{
				tempHeight = maleHeight[p];
				maleHeight[p] = maleHeight[p + 1];
				maleHeight[p + 1] = tempHeight;
			}
		}
	}
	for(i = 0; i <= n - 1; i++)
	{
		for(p = 0; p <= n - 1 - i; p++)
		{
			if(femaleHeight[p] < femaleHeight[p + 1])
			{
				tempHeight = femaleHeight[p];
				femaleHeight[p] = femaleHeight[p + 1];
				femaleHeight[p + 1] = tempHeight;
			}
		}
	}

	cout << fixed;
	for(i = 0; i < n; i++)
	{
		if(maleHeight[i] != 0)
		{
			j = i;
			cout << setprecision(2) << maleHeight[j];
			break;
		}
	}
	for(i = j + 1; i < n; i++)
	{
		if(maleHeight[i] != 0)
			cout << setprecision(2) << " " << maleHeight[i];
	}
	for(i = 0; i < n; i++)
	{
		if(femaleHeight[i] != 0)
			cout << setprecision(2) << " " << femaleHeight[i];
	}
	return 0;
}