int cmp1(const void * e1,const void * e2){
	if(*((double *)e1)<*((double *)e2))
		return -1;
	else if(*((double *)e1)>*((double *)e2))
		return 1;
	else return 0;
}
int cmp2(const void * e1,const void * e2){
	if(*((double *)e1)<*((double *)e2))
		return 1;
	else if(*((double *)e1)>*((double *)e2))
		return -1;
	else return 0;
}
int main(){
	int n;
	double male[50],female[50];
	int n1,n2;
	double num;
	n1=0;
	n2=0;
	char s[15];
	cin>>n;
	for(int i=0;i<n;++i){

		cin>>s>>num;
		if(strcmp(s,"male")==0){
			male[n1]=num;
			n1++;
		}
		else{
			female[n2]=num;
			n2++;
		}
	}
	qsort(male,n1,sizeof(double),cmp1);
	qsort(female,n2,sizeof(double),cmp2);
	for(int i=0;i<n1;++i)
		printf("%.2f ",male[i]);
	for(int i=0;i<n2-1;++i)
		printf("%.2f ",female[i]);
	printf("%.2f",female[n2-1]);
	cout<<endl;

}


int main()
{
    char a[40][8];
    double height;
    double female[40];
    double male[40];
    int n;
    double temp;
    int j, k;
    int femalecount = 0;
    int malecount = 0;
    int i;
    cin >>n;
    for (i = 0; i < n; i++)
    {
         cin >> a[i];
         cin >> height;
         if (a[i][0] == 'f')
         {
             female[femalecount] = height;
             femalecount++;
         }
         else
         {
             male[malecount] = height;;
             malecount++;
         }
    }
    for (j = 0; j < malecount; j++)
    {
        for ( k = 0; k < malecount - j - 1; k++)
        {
            if (male[k] > male[k + 1])
            {
                temp = male[k + 1];
                male[k + 1] = male[k];
                male[k] = temp;
            }
        }
    }
    for (j = 0; j < femalecount; j++)
    {
        for ( k = 0; k < femalecount - j - 1; k++)
        {
            if (female[k] < female[k + 1])
            {
                temp = female[k + 1];
                female[k + 1] = female[k];
                female[k] = temp;
            }
        }
    }
    for (j = 0; j < malecount; j++)
    {
        cout << fixed << setprecision(2);
        cout << male[j] << " ";
    }
    for (j = 0; j < femalecount - 1; j++)
    {
        cout << female[j] << " ";
    }
    cout << female[femalecount - 1];
    return 0;
}


int main(){
	int n,j,i,i1=0,i2=0,t1,t2;
	struct heying{
		char sex[10];
		double h;
	}heying[N],ex,male[N],fe[N];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s%lf",heying[i].sex,&heying[i].h);
        if(heying[i].sex[0]=='m')
		{
			male[i1]=heying[i];
			i1++;
		}
		else
		{
			fe[i2]=heying[i];
			i2++;
		}
	}
	t1=i1;
	t2=i2;
	for(i=0;i<t1;i++)
	{
		for(j=i+1;j<t1;j++)
		{
			if(male[i].h>male[j].h)
			{
				ex=male[i];
				male[i]=male[j];
				male[j]=ex;
			}
		}
	}
	for(i=0;i<t2;i++)
	{
		for(j=i+1;j<t2;j++)
		{
			if(fe[i].h<fe[j].h)
			{
				ex=fe[i];
				fe[i]=fe[j];
				fe[j]=ex;
			}
		}
	}
	for(i=0;i<t1;i++)
	{
		printf("%.2lf ",male[i].h);
	}
	for(i=0;i<t2-1;i++)
	{
		printf("%.2lf ",fe[i].h);
	}
	printf("%.2lf\n",fe[t2-1].h);
	return 0;
}


main()
{
    int n,i,j,x=0;
    float r;
    float m[40]={0},f[40]={0};
    struct person
    {
        char gender[7];
        float height;
    }person[40];
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%s%f",person[i].gender,&person[i].height);
    for(i=0;i<n;i++)
    {
        if(strlen(person[i].gender)==4) m[i]=person[i].height;
        else f[i]=person[i].height;
    }
    for(i=0;i<40;i++)
    {
        for(j=40-1;j>i;j--)
            if(m[i]>m[j])
            {r=m[i];m[i]=m[j];m[j]=r;}
    }
        for(i=0;i<40;i++)
    {
        for(j=40-1;j>i;j--)
            if(f[i]<f[j])
            {r=f[i];f[i]=f[j];f[j]=r;}
    }
    i=0;
    do{i++;}while(m[i]==0);
    printf("%.2f",m[i]);
    x=i;
    for(i=x+1;i<40;i++) printf(" %.2f",m[i]);
    i=0;
    while(f[i]!=0)
    {
        printf(" %.2f",f[i]);
        i++;
    }
}


struct in
{
       float h;
}nan[41],nv[41];
int cmp1 (const void *a,const void *b)
{
    struct in *c=(struct in *)a;
    struct in *d=(struct in *)b;
    return ((c->h-d->h)>0)?1:-1;
}
int cmp2 (const void *a,const void *b)
{
    struct in *c=(struct in *)a;
    struct in *d=(struct in *)b;
    return ((-c->h+d->h)>0)?1:-1;
}

int main()
{
    int num;
    int i;
    char ssex[10]={'\0'};
    float hh;
    int numnan=0;
    int numnv=0;
    memset(nan,0,41);
    memset(nv,0,41);
    scanf("%d",&num);
    for (i=0;i<num;i++)
    {
        scanf("%s %f",ssex,&hh);
        if (strcmp(ssex,"male")==0)
        {
           nan[numnan].h=hh;
           numnan++;
        }
        else
        {
            nv[numnv].h=hh;
            numnv++;
        }
        memset(ssex,'\0',10);
    }
    qsort(nan,numnan,sizeof(nan[0]),cmp1);
    qsort(nv,numnv,sizeof(nv[0]),cmp2);
    for (i=0;i<numnan;i++)
    {
        printf("%.2f ",nan[i].h);
    }
    for (i=0;i<numnv;i++)
    {
        if (i!=numnv-1)
           printf("%.2f ",nv[i].h);
        else
            printf("%.2f\n",nv[i].h);
    }
       return 0;
}


int main(void)
{
   int n,i;
   float m[50],f[50],heigh;
   int mm=0;
   int fm=0;
   char name[10];
   int k;
   float temp;
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {
        scanf("%s %f",name,&heigh);
        if(name[0]=='m')
		{
		      m[mm]=heigh;
			  k=mm;
			  while((m[k]<m[k-1])&&k>0)
              {
			        temp=m[k];
					m[k]=m[k-1];
                    m[k-1]=temp;
					k--;
			  }
			  mm++;
		}
		else
		{
			  f[fm]=heigh;
			  k=fm;
			  while((f[k]<f[k-1])&&k>0)
              {
			        temp=f[k];
					f[k]=f[k-1];
                    f[k-1]=temp;
					k--;
			  }
              fm++;
		}
   }
   for(i=0;i<mm;i++)
	   printf("%.2f ",m[i]);
   for(i=fm-1;i>0;i--)
       printf("%.2f ",f[i]);
   printf("%.2f\n",f[0]);
   return 0;
}


void sort(float *p1,float *p2,int cri){//cri:1±íê¾ÄD?¬-1±íê¾Å®
	if((*p1-*p2)*cri>0){
		float temp=*p1;
		*p1=*p2;
		*p2=temp;
	}
}

int main(){
	int k,boynum,b,g;
	b=0;
	g=0;
	float tempheight;
	char tempsex[7];
	scanf("%d",&k);
	float boy[k];
	float girl[k];
	for(int i=1;i<=k;i++){
		scanf("%s %f",tempsex,&tempheight);
		if(strcmp(tempsex,"male\0")==0){
			boy[b]=tempheight;
			b++;
		}
		else{
			girl[g]=tempheight;
			g++;
		}

		if(i==k){
			boynum=b;
		}
	}
	for(int i=1;i<=boynum-1;i++){
		for(int j=i+1;j<=boynum;j++){
			sort(&boy[i-1],&boy[j-1],1);
		}
	}
	for(int i=1;i<=k-boynum-1;i++){
		for(int j=i+1;j<=k-boynum;j++){
			sort(&girl[i-1],&girl[j-1],-1);
		}
	}
	printf("%.2f",boy[0]);
	for(int i=2;i<=boynum;i++){
		printf(" %.2f",boy[i-1]);
	}
	for(int i=1;i<=k-boynum;i++){
		printf(" %.2f",girl[i-1]);
	}

}


int main()
{
	int m;
	char sex[10];
	char fmale[10]="male";
	float a;
	int male=0;
	int famle=0;
	float humanm[40];
	float humanf[40];

	cin>>m;
	for(int i=0;i<m;i++)
	{
		cin>>sex>>a;
		if(strcmp(sex,fmale)==0)
		{

			humanm[male]=a;
			male++;
		}
		else
		{

			humanf[famle]=a;
			famle++;
		}
	}
	sort(&humanm[0],&humanm[male]);
	sort(&humanf[0],&humanf[famle]);
	for(int i=0;i<male;i++)
		printf("%.2f ",humanm[i]);
	for(int i=famle-1;i>0;i--)
		printf("%.2f ",humanf[i]);
	printf("%.2f\n",humanf[0]);
}


int cmp(const void* a,const void* b)
{
    return (*(float*)a) > (*(float*)b) ? 1:-1;
}
int main()
{
    int n,i,f,m;
    char sex[10];
    float male[40]={0},female[40]={0};
    scanf("%d",&n);
    for(i=0,f=0,m=0;i<n;i++)
    {
                    scanf("%s",sex);
                    if(sex[0]=='m')
                    {
                                   scanf("%f",&male[m]);
                                   m++;
                    }
                    else
                    {
                        scanf("%f",&female[f]);
                        f++;
                    }
    }
    qsort(male,m,sizeof(float),cmp);
    qsort(female,f,sizeof(float),cmp);
    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[i]);
    return 0;
}


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

    return 0;
}


int main(){
    int n, i, a=0, b=0, m;
    float height[50], male[50], female[50], t;
    char gender[50][10];
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%s%f", gender[i], &height[i]);
        if (strcmp(gender[i], "male")==0) {
            male[a]=height[i];
            a++;
        }else{
            female[b]=height[i];
            b++;
        }
    }
    m=10000;
    while (m>0&&a>1) {
        for (i=1; i<a; i++) {
            if (male[i]<male[i-1]) {
                t=male[i];
                male[i]=male[i-1];
                male[i-1]=t;
            }
            m--;
        }
    }
    m=10000;
    while (m>0&&b>1) {
        for (i=1; i<b; i++) {
            if (female[i]>female[i-1]) {
                t=female[i];
                female[i]=female[i-1];
                female[i-1]=t;
            }
            m--;
        }
    }
    for (i=0; i<a; i++) {
        printf("%.2f ", male[i]);
    }
    for (i=0; i<b-1; i++) {
        printf("%.2f ", female[i]);
    }
    printf("%.2f", female[b-1]);
    return 0;
}


int n = 0;
int malecnt = 0;
int femalecnt = 0;
double male[50];
double female[50];

int main()
{
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	int i = 0;
	char s[10];
	double temp = 0;

	scanf("%d", &n);

	while(n--)
	{
		scanf("%s %lf", s, &temp);
		if(strcmp(s, "male") == 0)
		{
			male[malecnt++] = temp;
		}
		else
		{
			female[femalecnt++] = temp;
		}
	}

	sort(male, male+malecnt);
	sort(female, female+femalecnt);

	for(i=0; i<malecnt; i++)
	{
		printf("%.2lf ", male[i]);
	}

	for(i=femalecnt-1; i>=1; i--)
	{
		printf("%.2lf ", female[i]);
	}
	printf("%.2lf\n", female[0]);
	return 0;
}


int main(){
    int n,mk=0,fk=0;
	scanf("%d",&n);
	int i,j;
	struct point{
		char sex[10];
		double height;
    }p[40],m[40],f[40],e;
	for(i=0;i<n;i++){
		scanf("%s%lf",p[i].sex,&p[i].height);
	}
    for(i=0;i<n;i++){
		if(strcmp(p[i].sex,"male")==0){
			m[mk]=p[i];
			mk++;
		}
        if(strcmp(p[i].sex,"female")==0){
			f[fk]=p[i];
			fk++;
		}
	}
	for(i=1;i<mk;i++){
		for(j=0;j<mk-i;j++){
			if(m[j].height>m[j+1].height){
				e=m[j];
				m[j]=m[j+1];
				m[j+1]=e;
			}
		}
	}
    for(i=1;i<fk;i++){
		for(j=0;j<fk-i;j++){
			if(f[j].height<f[j+1].height){
				e=f[j];
				f[j]=f[j+1];
				f[j+1]=e;
			}
		}
	}
	for(i=0;i<mk;i++){
		if(i==0){
			printf("%.2lf",m[i].height);
		}else{
            printf(" %.2lf",m[i].height);
		}
	}
	for(i=0;i<fk;i++){
            printf(" %.2lf",f[i].height);
	}
    return 0;
}


void sort(float*p,int n)
{
   float temp;
   for (int i=0;i<n;i++)
      for (int j=n-1;j>i;j--)
        {
           if (*(p+j)<*(p+j-1))
              {
                 temp=*(p+j);
                 *(p+j)=*(p+j-1);
                 *(p+j-1)=temp;
              }
        }
}
main()
{
  void sort(float*p,int n);
  float height[40];
  char gender[40][6];
  int n,lens[40];
  scanf ("%d",&n);
  for (int i=0;i<n;i++)
      {
        scanf ("%s%f",&gender[i],&height[i]);
        lens[i]=strlen(gender[i]);
      }
  int p=-1,q=-1;
  float m[40],f[40];
  for (int j=0;j<n;j++)
     {
       if (lens[j]==4)
           {
             p++;
             m[p]=height[j];
           }
       else
           {
              q++;
              f[q]=height[j];
           }
     }
  float *p1=m,*p2=f;
  sort(p1,p+1);
  sort(p2,q+1);
  for (int k=0;k<=p;k++)
      printf ("%3.2f ",m[k]);
  for (int k=q;k>=0;k--)
     {
           printf ("%3.2f",f[k]);
           if (k>0)
              printf (" ");
     }
}


int com1(const void *e1,const void*e2)
{
    float *p1,*p2;
    int x=0;
    p1=(float *)e1;
    p2=(float *)e2;
    if ((*p1)>(*p2)) x=1;
    if ((*p1)<(*p2)) x=-1;
    return x;
}
int com2(const void *e1,const void*e2)
{
    float *p1,*p2;
    int x=0;
    p1=(float *)e1;
    p2=(float *)e2;
    if ((*p1)>(*p2)) x=-1;
    if ((*p1)<(*p2))x=1;
    return x;
}
int main()
{
    int i,j=0,k=0,n;
    float *a,*b;
    char c[10];
    float d;
    scanf("%d",&n);
    a=(float *)malloc(n*sizeof(int));
    b=(float *)malloc(n*sizeof(int));
    for (i=0;i<n;i++)
    {
         scanf("%s %f",c,&d);
         if (strlen(c)==4)  {a[j]=d;j++;}
         else {b[k]=d;k++;}
    }
    for(i=j;i<n;i++)    a[i]=6;
    for (i=k;i<n;i++)   b[i]=0;
    qsort(a,n,sizeof(float),com1);
    qsort(b,n,sizeof(float),com2);
    printf("%.2f",a[0]);
    for (i=1;i<j;i++)  printf(" %.2f",a[i]);
    for (i=0;i<k;i++)  printf(" %.2f",b[i]);
    getchar();
    getchar();
    getchar();
    return 0;
}


int compare(const void *elem1,const void *elem2)
{
	float a;
	a=*(float *)elem1-*(float *)elem2;
	if(a>0)
		return 1;
	else if(a==0)
		return 0;
	else
		return -1;

}

int main()
{
	float a[100],b[100];
	int c=0,d=0;
	int n;
	char ch[30];
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++)
	{
		scanf("%s",ch);
		if(strcmp(ch,"male")==0)
		{
			scanf("%f",&a[c++]);
		}

		else
		{
			scanf("%f",&b[d++]);
		}
	}

	qsort(a,c,sizeof(float),compare);
	qsort(b,d,sizeof(float),compare);

	for(i=0;i<c;i++)
	{
		printf("%.2f ",a[i]);
	}

	for(i=d-1;i>=0;i--)
	{
		if(i!=0)
			printf("%.2f ",b[i]);
		else
			printf("%.2f",b[i]);

	}

	printf("\n");

	return 1;

}


int main()
{
	int i,j,k,m,f,n;
	float male[40],female[40],temp;
	char sex[40][6];
	scanf("%d",&n);
	k=0;
	j=0;
	m=0;
	f=0;
	temp=0.00;
    for (i=0;i<n;i++)
	{
		scanf("%s",sex[i]);
		if (sex[i][0]=='m')
		{
			scanf("%f",&male[k]);
			k=k+1;
			m=k;
		}
	    else
		{
			scanf("%f",&female[j]);
			j=j+1;
			f=j;
		}
	}
	for (i=0;i<m;i++)
	{
		for (k=1;k<m;k++)
		{
			if (male[k-1]>male[k])
			{
				temp=male[k-1];
				male[k-1]=male[k];
				male[k]=temp;
			}
		}
	}
	for (i=0;i<f;i++)
	{
		for (k=1;k<f;k++)
		{
			if (female[k-1]<female[k])
			{
				temp=female[k-1];
				female[k-1]=female[k];
				female[k]=temp;
			}
		}
	}
	for(i=0;i<m;i++)
	{
		printf("%.2f ",male[i]);
	}
	for (i=0;i<f-1;i++)
	{
		printf("%.2f ",female[i]);
	}
	printf("%.2f",female[f-1]);
	return 0;
}


int max(double n[],int m)
{
	double max_num=n[0];
	int maxn=0;
	for(int i=1;i<m;i++)
	{
		if(n[i]>max_num)
		{
			max_num=n[i];
			maxn=i;
		}
	}
	return maxn;
}
int min(double n[],int m)
{
	double max_num=n[0];
	int maxn=0;
	for(int i=1;i<m;i++)
	{
		if(n[i]<max_num)
		{
			max_num=n[i];
			maxn=i;
		}
	}
	return maxn;
}
int main()
{
	int n,i,j=0,k=0,maxn;
	char s[10];
    double mt[40],ft[40],t;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>s>>t;
		if(strcmp(s,"male")==0)
		{
			mt[j]=t;
			j++;
		}
		else if(strcmp(s,"female")==0)
		{
			ft[k]=t;
			k++;
		}
	}
	for(i=0;i<j;i++)
	{
		maxn=max(mt,j-i);
		double temp=mt[j-i-1];
		mt[j-i-1]=mt[maxn];
		mt[maxn]=temp;
	}
	for(i=0;i<k;i++)
	{
		maxn=min(ft,k-i);
		double temp=ft[k-i-1];
		ft[k-i-1]=ft[maxn];
		ft[maxn]=temp;
	}

	for(i=0;i<j;i++)
	{

		printf("%0.2f ",mt[i]);
	}
	for(i=0;i<k-1;i++)
	{
		printf("%0.2f ",ft[i]);
	}
	printf("%0.2f",ft[k-1]);
	return 0;

}


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


int main()
{
	int n,i,start=0,end,p1=0,p2=0,x1,x2;
	float a,b;
	scanf("%d",&n);
	end=n-1;
	struct student
	 {char sex[6];
	  float height;
	 }s[40],t;
	for(i=0;i<n;i++)
	 scanf("%s %f",s[i].sex,&s[i].height);
	while(start<=end)
	 {a=b=3;
	  for(i=start;i<=end;i++)
	   {if(s[i].sex[0]=='m')
	     {p1=1;
		  if(s[i].height<a)
	       {x1=i;a=s[i].height;}
	     }
	    else
	     {p2=1;
		  if(s[i].height<b)
	       {x2=i;b=s[i].height;}
	     }
	   }
	  if(p1)
	   {t=s[x1];s[x1]=s[start];s[start]=t;
	    if(x2==start)
	     x2=x1;
	    start++;p1=0;
	   }
	  if(p2)
	   {t=s[x2];s[x2]=s[end];s[end]=t;end--;p2=0;}
	 }
	for(i=0;i<n;i++)
	 {if(i>0)
	   printf(" ");
	  printf("%.2f",s[i].height);
	 }
}


int main()
{
	int n,i;
	scanf("%d",&n);

	struct student
	{
		char gender[7];
		float h;
	};
	struct student stu[40];
	for(i=0;i<n;i++)
		scanf("%s %f",stu[i].gender,&stu[i].h);

	float a[40],b[40];
	char m[5]="male";
	int j=0,t=0;
	for(i=0;i<n;i++)
	{
		if(strcmp(stu[i].gender,m)==0)
		{
			a[j]=stu[i].h;
			j++;
		}
		else
		{
			b[t]=stu[i].h;
			t++;
		}
	}

	int k,q	;
	float e;
	for(i=0;i<j-1;i++)
	{
		k=i;
		for(q=i+1;q<j;q++)
			if(a[k]>a[q])
				k=q;
		e=a[k];
		a[k]=a[i];
		a[i]=e;
	}

	for(i=0;i<t-1;i++)
	{
		k=i;
		for(q=i+1;q<t;q++)
			if(b[k]<b[q])
				k=q;
		e=b[k];
		b[k]=b[i];
		b[i]=e;
	}

	for(i=0;i<j;i++)
		printf("%.2f ",a[i]);
	for(i=0;i<t-1;i++)
		printf("%.2f ",b[i]);
	printf("%.2f",b[t-1]);

	return 0;
}


int main ()
{
	int n, i, m, w, j;
	double height, temp;
	double man[50];
	double woman[50];
	char xb[10];
	cin >> n;
	m = 0;
	w = 0;
	for (i = 1; i <= n; i++)
	{
		cin >> xb;
		cin >> height;
		if (xb[0] == 'm')
		{
			m++;
			man[m] = height;
		}
		else
		{
			w++;
			woman[w] = height;
		}
	}
	for (i = 1; i <= m - 1; i++)
	{
		for (j = 1; j <= m - i; j++)
		{
			if (man[j] > man[j + 1])
			{
				temp = man[j];
				man[j] = man[j + 1];
				man[j + 1] = temp;
			}
		}
	}
	for (i = 1; i <= w - 1; i++)
	{
		for (j = 1; j <= w - i; j++)
		{
			if (woman[j] < woman[j + 1])
			{
				temp = woman[j];
				woman[j] = woman[j + 1];
				woman[j + 1] = temp;
			}
		}
	}
	cout << fixed << setprecision(2) <<man[1];
	for (i = 2; i <= m; i++)
	{
		cout << fixed << setprecision(2) << " " << man[i];
	}
	for (i = 1; i <= w; i++)
	{
		cout << fixed << setprecision(2) << " " << woman[i];
	}
	cout << endl;
	return 0;
}


int compInc(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}
struct student
{
    float height;
    char sex[7];
};
main()
{
    int n,q=0,j=0;
    struct student stu[40];
    float girl[40],boy[40];
    scanf("%d",&n);
    for(int i = 0;i < n;i ++)
        scanf("%s%f",stu[i].sex,&stu[i].height);
    for(int i = 0;i < n;i ++)
    {
        if(stu[i].sex[0]=='f')
            girl[q++]=stu[i].height;
        else
            boy[j++]=stu[i].height;
    }
    qsort(boy,j,sizeof(boy[0]),compInc);
    qsort(girl,q,sizeof(girl[0]),compInc);
    printf("%.2f",boy[0]);
    for (int i = 1;i < j;i++)
        printf(" %.2f",boy[i]);
    for (int i = q-1;i >=0 ;i--)
        printf(" %.2f",girl[i]);

}


int main()
{
    int i, j, n, t;
    float m[41]={0}, f[41]={0}, h[41]={0};
    char str[41][7];
    cin>>n;
    for(i=1; i<=n; i++)
    {
        cin>>str[i]>>h[i];
        if(strcmp(str[i],"male")==0)
        {
            m[i]=h[i];
            //cout<<" "<<fixed<<setprecision(2)<<m[i];
        }
        else
        {
            f[i]=h[i];
        }

    }
    sort(m+1,m+n+1);
    sort(f+1,f+n+1);
    for(i=1; i<=n; i++)
    {
        if(m[i]!=0)
        {
            t=i;
            cout<<fixed<<setprecision(2)<<m[i];
            for(j=t+1;j<=n;j++)
            {

                cout<<" "<<fixed<<setprecision(2)<<m[j];

            }
            break;
        }

    }
    for(i=n; i>=1; i--)
    {
        if(f[i]==0)
            break;
        else
        {
            cout<<" "<<fixed<<setprecision(2)<<f[i];
        }

    }
    int x;cin>>x;
    return 0;
    }


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


int main(){
	struct person{
		char sex[6];
		double height;
	}person[40];
	int n,i,j,mk=0,fk=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s%lf",person[i].sex,&(person[i].height));
	}
	double male[40],female[40];
	for(i=0;i<n;i++){
		if(strcmp(person[i].sex,"male")==0){
			male[mk]=person[i].height;
			mk++;
		}
	}
	for(i=0;i<n;i++){
		if(strcmp(person[i].sex,"female")==0){
			female[fk]=person[i].height;
			fk++;
		}
	}
	for(i=0;i<mk;i++){
		for(j=mk-1;j>0;j--){
			if(male[j-1]>male[j]){
				double p;
				p=male[j];
				male[j]=male[j-1];
				male[j-1]=p;
			}
		}
	}
	for(i=0;i<fk;i++){
		for(j=fk-1;j>0;j--){
			if(female[j-1]<female[j]){
				double p;
				p=female[j];
				female[j]=female[j-1];
				female[j-1]=p;
			}
		}
	}
	for(i=0;i<mk;i++){
		if(i==0){
			printf("%.2lf",male[i]);
		}else{
			printf(" %.2lf",male[i]);
		}
	}
	for(i=0;i<fk;i++){
		printf(" %.2lf",female[i]);
	}
	return 0;
}


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

	for(i=1;i<f;i++)
	{
		for(j=0;j<f-i;j++)
		{
			if(female[j]<female[j+1])
			{
				double d;
				d=female[j];
				female[j]=female[j+1];
				female[j+1]=d;
			}
		}
	}
	for(i=0;i<f;i++)
	{
		if(i==f-1)
		{
			printf("%.2lf",female[i]);
		}
		else
		{
		    printf("%.2lf ",female[i]);
		}
	}
	return 0;
}


double m[40],f[40];
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n;
    char str[20];
    double h;
    int b,g;
    while(scanf("%d",&n)!=EOF)
    {
        b=0;
        g=0;
        for(int i=0;i<n;i++)
        {
            scanf("%s%lf",str,&h);
            if(strcmp(str,"male")==0)
            {
                m[b++]=h;
            }
            else
                f[g++]=h;
        }
        sort(m,m+b);
        sort(f,f+g);
        for(int i=0;i<b;i++)
            printf("%.2lf ",m[i]);
            //cout<<<<" ";
        //cout<<g<<endl;
        for(int i=(g-1);i>0;i--)
            printf("%.2lf ",f[i]);
        printf("%.2lf\n",f[0]);
        //cout<<f[0]<<endl;
        //cout<<endl;

    }
    return 0;
}


int main()
{
	int n,sum1=0,sum2=0,i;
	double data1[50],data2[50],temp;
	char mark[10];
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>mark;
		if(strcmp(mark,"male")==0)
		{
			cin>>data1[sum1++];
		}
		else{cin>>data2[sum2++];}
	}
	sort(data1,data1+sum1);
	sort(data2,data2+sum2);
	for(i=0;i<sum2/2;i++)
	{
		temp=data2[i];
		data2[i]=data2[sum2-1-i];
		data2[sum2-1-i]=temp;
	}
	printf("%.2f",data1[0]);
	for(i=1;i<sum1;i++)
	{
		printf(" %.2f",data1[i]);
	}
	for(i=0;i<sum2;i++)
	{
		printf(" %.2f",data2[i]);
	}
	cout<<endl;
	return 0;
}


int main()
{
	int n=0;
	char gender[8];
	char gen[40];
	float height[40];
	float male[40];
	float female[40];
	int malenum=0,femalenum=0;
	int i=0,j=0,k=0,l=0,m=0;
	float temp;

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %f",&gender,&height[i]);
		gen[i]=gender[0];
		male[i]=0.0;
		female[i]=0.0;

	}
	for(i=0;i<n;i++)
	{
		if(gen[i]=='m')
		{
			male[j]=height[i];
			j++;
		}
			else if(gen[i]=='f')
			{
				female[k]=height[i];

				k++;
			}
	}

	malenum=j;
	femalenum=k;

	while(j--)
	{
		for(l=0;l<j;l++)
		{
			if(male[l]>male[l+1])
			{
				temp=male[l+1];
				male[l+1]=male[l];
				male[l]=temp;
			}
		}
	}

	while(k--)
	{
		for(l=0;l<k;l++)
		{
			if(female[l]<female[l+1])
			{
				temp=female[l+1];
				female[l+1]=female[l];
				female[l]=temp;
			}
		}
	}

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

	printf("%.2f",female[i]);

	return 0;
}


int main()
{
	int n, i ,j, f = 0, m=0;
	float height[41] = {0}, female[41], male[41];
	char gender[41][7] = {'\0'};
	cin >> n;
	for(i = 0; i < n; i++)
		cin >> gender[i] >> height[i];
	for(i = 0; i < n ;i++)
	{
		if(gender[i][0] == 'm')
			male[m++] = height[i];
		else
			female[f++] = height[i];
	}
	for(i = 0; i < m; i++)
	{
		for(j = 0; j < m - 1 - i; j++)
		{
			if(male[j] > male[j + 1])
			{
				double temp = male[j];
				male[j] = male[j + 1];
				male[j + 1] = temp;
			}
		}
	}
	for(i = 0; i < f; i++)
	{
		for(j = 0; j < f - 1 - i; j++)
		{
			if(female[j] < female[j + 1])
			{
				double temp = female[j];
				female[j] = female[j + 1];
				female[j + 1] = 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 << fixed << setprecision(2) << female[f - 1] << endl;
	return 0;
}


int main()
{
	char s[50][20], man[5] = { "male" }, wman[7] = { "female" };
	double l[50];
	double temp;
	int n, i, j, tip;
	cin >> n;
	for (i = 0; i < n; i++)
		cin >> s[i] >> l[i];
	for (i = 0; i < n - 1; i++)
	for (j = i + 1; j < n; j++)
	{
		if (strcmp(s[i], man) == 0 && strcmp(s[j], man) == 0 && l[i] > l[j])
		{
			temp = l[i];
			l[i] = l[j];
			l[j] = temp;
		}

	}
	for (i = 0; i < n - 1; i++)
	for (j = i + 1; j < n; j++)
	{
		if (strcmp(s[i], wman) == 0 && strcmp(s[j], wman) == 0 && l[i] < l[j])
		{
			temp = l[i];
			l[i] = l[j];
			l[j] = temp;
		}

	}
	for (i = n - 1; i >= 0; i--)
	{
		if (strcmp(s[i], wman) == 0)
		{
			tip = i;
			break;
		}
	}
	cout <<fixed;
	for (i = 0; i < n; i++)
	{
		if (strcmp(s[i], man) == 0)
			cout << setprecision(2) << l[i] << " ";
	}
	for (i = 0; i < tip; i++)
	{
		if (strcmp(s[i], wman) == 0)
			cout << setprecision(2) << l[i] << " ";
	}
	cout << setprecision(2) << l[tip] << endl;
	return 0;
}


int main()
{
	double male[50], female[50], height, tep;
    int n, i, j, m = 0, f = 0;
	char ch[7];

	cin >> n;
	for (i = 0; i < n ; i++)
	{
		 cin.get();
	     cin.getline(ch, 7, ' ');//?????????????cin?getline??????height??????????cin??
		 cin >> height;
		 if (ch[0] == 'm')
			 male[m++] = height;
		 else
			 female[f++] = height;
	}
	for (i = 0; i < m - 1; i++)
		for (j = 0; j < m - 1 - i; j++)
		{
          	if(male[j] > male[j + 1])
			{
			     tep = male[j];
				 male[j] = male[j + 1];
				 male[j + 1] = tep;
			}
		}
	for (i = 0; i < f - 1; i++)
	    for (j = i + 1; j < f; j++)
		{
		    if (female[i] < female[j])
			{
			    tep = female[i];
				female[i] = female[j];
				female[j] = tep;
			}
		}
	cout << fixed << setprecision(2);
	cout << male[0];
	for (i = 1; i < m; i++)
		cout << " " << male[i];
	for (i = 0; i < f; i++)
        cout << " " << female[i];

	    return 0;
}


int main()
{
	int n,i,m=0,f=0,k;
	char sex[10];
	char s[10]={"male"};
	double h;
	struct
	{
		char sex[10];
		double h;
	}
	qq[40],male[40],female[40],e;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",sex);
		scanf("%lf",&h);
		strcpy(qq[i].sex,sex);
		qq[i].h=h;
	}
	for(i=0;i<n;i++)
	{
		if(strcmp(qq[i].sex,s))
		{
			female[f]=qq[i];
			f++;
		}
		else
		{
			male[m]=qq[i];
			m++;

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


float m[50];
float f[50];
int main()
{
	int total,count;
	float meter;
	char str[10];
	int mt,ft;
	int i,j;
	scanf("%d",&total);
	mt=ft=0;
	for(count=0;count<total;count++)
	{
		scanf("%s %f",&str,&meter);

		if(!strcmp(str,"male"))
		{
			m[mt++]=meter;
		}
		else
		{
			f[ft++]=meter;
		}
	}
	for(i=0;i<mt;i++)
		for(j=i+1;j<mt;j++)
			if(m[i]>m[j])
			{
				meter=m[i];
				m[i]=m[j];
				m[j]=meter;
			}
	for(i=0;i<ft;i++)
		for(j=i+1;j<ft;j++)
			if(f[i]<f[j])
			{
				meter=f[i];
				f[i]=f[j];
				f[j]=meter;
			}
	for(i=0;i<mt;i++)
		printf("%.2f ",m[i]);
	for(i=0;i<ft-1;i++)
		printf("%.2f ",f[i]);
	printf("%.2f\n",f[i]);
	return 0;
}


int male[45];
int female[45];
char ch[20];
int cmp1(const void *a, const void *b)
{
	int *temp1 = (int *)a;
	int *temp2 = (int *)b;

	return (int )(*temp1 - *temp2);
}
int cmp2(const void *a, const void *b)
{
	int *temp1 = (int *)a;
	int *temp2 = (int *)b;

	return (int )(*temp2 - *temp1);
}

int main()
{
	int n;
	cin >> n;
	int m = 0, f = 0;
	double h;
	for(int i = 0; i < n ; i++)
	{
		cin>>ch;
		if(strcmp(ch, "male") == 0)
		{
			cin>>h;
			male[m] =(int)( h * 10000);
			m++;
		}
		else
		{
			cin>>h;
			female[f] =(int)( h * 10000);
			f++;
		}

	}
	qsort(male, m  , sizeof(int), cmp1);
	qsort(female, f  , sizeof(int), cmp2);

	for(int i = 0; i < m; i ++)
		printf("%3.2lf ",male[i] / 10000.0);
	for(int i = 0; i < f - 1; i++)
		printf("%3.2lf ",female[i] / 10000.0);
	printf("%3.2lf",female[f - 1] / 10000.0);
	return 0;
}


int main()
{
	int N, k,i, j;
	char sex[10];
	double a[45], b[45], temp;
	int boy = 0, girl = 0;
	cin >> N;
	for (k = 0; k < N; k++)
	{
		cin >> sex >> temp;
		if (sex[0] == 'f' )
		{
			b[girl] = temp;
			girl++;
		}
		else
		{
			a[boy] = temp;
			boy++;
		}
	}
	for(i = 1; i < boy;i++)
		for(j = 0; j < boy - 1;j++)
		{
			if (a[j] > a[j + 1])
			{
				temp = a[j + 1];
				a[j + 1] = a[j];
				a[j] = temp;
			}
		}
    for(i = 1; i < girl;i++)
		for(j = 0; j < girl - 1;j++)
		{
			if (b[j] < b[j + 1])
			{
				temp = b[j + 1];
				b[j + 1] = b[j];
				b[j] = temp;
			}
		}
	for(i = 0; i < boy;i++)
		cout <<fixed << setprecision(2) <<  a[i] << " ";
    for(j = 0; j < girl - 1;j++)
	    cout <<fixed << setprecision(2) << b[j] << " ";
	cout <<fixed << setprecision(2)<< b[j] << endl;
	return 0;
}


int main()
{
    char xb[10];
    int i,n,a=0,b=0,k;
    scanf("%d",&n);
    float m,shuzunan[40],shuzunv[40];
    for(i=0;i<n;i++)
    {

       scanf("%s",&xb);
       if(*xb=='m')
       {
          scanf("%f",&shuzunan[a]);
          a++;
       }
       if(*xb=='f')
       {
          scanf("%f",&shuzunv[b]);
          b++;
       }
    }
    for(k=1;k<a;k++)
    {
       for(i=0;i<a-k;i++)
       {
          if(shuzunan[i]>shuzunan[i+1])
          {
              m=shuzunan[i+1];
              shuzunan[i+1]=shuzunan[i];
              shuzunan[i]=m;
          }
       }
    }
    for(k=1;k<b;k++)
    {
           for(i=0;i<b-k;i++)
           {
               if(shuzunv[i]<shuzunv[i+1])
               {
                 m=shuzunv[i+1];
                 shuzunv[i+1]=shuzunv[i];
                 shuzunv[i]=m;
               }
           }
    }
    printf("%.2f",shuzunan[0]);
    for(k=1;k<a;k++)
    {
        printf(" %.2f",shuzunan[k]);
    }
    for(k=0;k<b;k++)
    {
        printf(" %.2f",shuzunv[k]);
    }

   return 0;
}


int main()
{
	int n=0,i;
	float nan[40];
	int m,f;
	float nv[40];
	char xingbie[7];
	float shengao;
	scanf("%d",&n);
	m=0;f=0;
	for (i=0;i<=n-1;i++)
	{
		scanf("%s %f",xingbie,&shengao);

		if(xingbie[0]=='m')
		{nan[m]=shengao;
		 m++;
		}
		else
		{nv[f]=shengao;
		 f++;
		}
	}
float T;
int j,k;

for(j=0;j<=m-2;j++)
{ for(k=0;k<=m-2-j;k++)
 {
  if(nan[k]>nan[k+1])
   {
	  T=nan[k+1];
	  nan[k+1]=nan[k];
	  nan[k]=T;
   }
 }
}
   for(j=0;j<=f-2;j++)
 { for(k=0;k<=f-2-j;k++)
  {
   if(nv[k]<nv[k+1])
   {
	  T=nv[k+1];
	  nv[k+1]=nv[k];
	  nv[k]=T;
   }
  }
 }
   for(i=0;i<m;i++)
      printf("%.2f ",nan[i]);
 for(i=0;i<f-1;i++)
    printf("%.2f ",nv[i]);
printf("%.2f",nv[f-1]);
	return 0;
}


int main()
{
 	char zfc[41][10];
 	double sz[41],male[41],female[41],final[41];
 	double e;
	int n,i,k,num1=0,num2=0;
 	scanf("%d",&n);
 	for(i=0;i<n;i++){
		scanf("%s %lf",zfc[i],&sz[i]);
		if(strcmp(zfc[i],"male")==0){
			male[num1]=sz[i];
			num1++;
			}
		else{
			female[num2]=sz[i];
			num2++;
			}
		}
	for(k=1;k<=num1;k++){
		for(i=0;i<num1-k;i++){
			if(male[i]>male[i+1]){
				e=male[i+1];
				male[i+1]=male[i];
				male[i]=e;
				}
			}
		}
	for(k=1;k<=num2;k++){
		for(i=0;i<num2-k;i++){
			if(female[i]>female[i+1]){
				e=female[i+1];
				female[i+1]=female[i];
				female[i]=e;
				}
			}
		}
	for(i=0;i<num1;i++){
		final[i]=male[i];
		}
	for(i=0;i<num2;i++){
		final[n-1-i]=female[i];
		}
	for(i=0;i<n;i++){
		if(i<n-1) printf("%.2lf ",final[i]);
		else printf("%.2lf",final[i]);
		}

    return 0;
}


/*
 * practice.cpp
 *
 *  Created on: 2014-1-4
 *      Author: 111
 */

int main()
{
	int n;
	cin >> n;
	float male[100],female[100];
	int m=0,f=0;
	for(int i=1;i<=n;i++)
	{
		char sex[10]; float height;
		cin >> sex >> height;
		if(sex[0]=='m')
		{
			male[m] = height;
			m++;
		}
		else
		{
			female[f] = height;
			f++;
		}
	} //cout << m << endl << f << endl;
	for(int i=0;i<m;i++)
		for(int j=i+1;j<m;j++)
			if(male[i]>male[j])
			{
				float temp = male[i];
				male[i] = male[j];
				male[j] = temp;
			}

	for(int i=0;i<f;i++)
		for(int j=i+1;j<f;j++)
			if(female[i]<female[j])
			{
				float temp = female[i];
				female[i] = female[j];
				female[j] = temp;
			}
	cout << fixed << setprecision(2);
	cout << male[0];
	for(int i=1;i<m;i++)
		cout << ' ' << male[i];
	for(int i=0;i<f;i++)
		cout << ' ' << female[i];
	return 0;
}


int main()
{
	int n,i,j,k,m,min;
	char flag[42];
	float male[42],female[42];
	float h;
	char str[10];
	j=0;k=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %f",str,&h);
		if(str[0]=='m')
		{
			male[j]=h;
			j++;
		}
		else
		{
			female[k]=h;
			k++;
		}
	}
	male[41]=100;
	for(i=0;i<j;i++)
		flag[i]=1;
	for(m=0;m<j;m++)
	{
		min=41;
		for(i=0;i<j;i++)
		{
			if(male[i]<male[min]&&flag[i]==1)
				min=i;
		}
		flag[min]=0;
		printf("%.2f ",male[min]);
	}
	female[41]=0;
	for(i=0;i<k;i++)
		flag[i]=1;
	for(m=0;m<k;m++)
	{
		min=41;
		for(i=0;i<k;i++)
		{
			if(female[i]>female[min]&&flag[i]==1)
				min=i;
		}
		flag[min]=0;
		if(m!=k-1)
			printf("%.2f ",female[min]);
		else
			printf("%.2f",female[min]);
	}
	printf("\n");
	return 0;
}


int main()
{
    int n,i;
    scanf("%d",&n);
    struct student
    {
           char a[7];
           float b;
    };
    struct student c[n];
    for(i=0;i<n;i++)
    {
                    scanf("%s %f",c[i].a,&c[i].b);
    }
    for(i=0;i<n;i++)
    {
                    for(int t=1;t<n-i;t++)
                    {
                            if(strlen(c[i].a)>strlen(c[i+t].a))
                            {
                            struct student k;
                            k=c[i];c[i]=c[i+t];c[i+t]=k;
                            }
                            else if(strlen(c[i].a)==strlen(c[i+t].a))
                            {
                                 if(strlen(c[i].a)==4)
                                 {
                                 if(c[i].b>c[i+t].b)
                                 {
                                 struct student k;
                                 k=c[i];c[i]=c[i+t];c[i+t]=k;
                                 }
                                 }
                                 else
                                 {
                                 if(c[i].b<c[i+t].b)
                                 {
                                 struct student k;
                                 k=c[i];c[i]=c[i+t];c[i+t]=k;
                                 }
                                 }
                            }
                    }
    }
                     for(i=0;i<n-1;i++)
                     {
                     printf("%.2f ",c[i].b);
                     }
                      printf("%.2f",c[n-1].b);
   }


int geshu(int c);
int main()
{
	char a[number], ch1,ch2, max1,max2, tmp[100003];
    int k, m, n, sz[number], sz1[number], i, j, b;
	double high[100], high2[100], mc;
	scanf("%d", &n);
	k=0;
	m=0;
	for(i=0;i<n;i++)
	{
		scanf("%s %lf", a, &high[m]);
		if(a[0]=='f')
		{
			high2[k]=high[m];
			k++;
			m--;
		}
		m++;
	}

	for(j=0;j<m-1;j++)
	{
		for(b=0;b<m-j-1;b++)
		{
			if(high[b]>high[b+1])
			{
				mc=high[b];
				high[b]=high[b+1];
				high[b+1]=mc;
			}
		}
	}

	for(j=0;j<k-1;j++)
	{
		for(b=0;b<k-j-1;b++)
		{
			if(high2[b]<high2[b+1])
			{
				mc=high2[b];
				high2[b]=high2[b+1];
				high2[b+1]=mc;
			}
		}
	}

	for(i=0;i<m;i++)
		printf("%.2lf ", high[i]);
	for(i=0;i<k;i++)
	{
		if(i==k-1)
			printf("%.2lf", high2[i]);
		else
			printf("%.2lf ", high2[i]);
	}
	return 0;
}


main()
{
      struct photo
      {
             double high;
             char sex[10];
      }p[43];
      int n,i,i2,j=0,k=0;
      double man[43],woman[43],hehe;
      scanf("%d",&n);
      for(i=0;i<n;i++)
      scanf("%s%lf",p[i].sex,&(p[i].high));
      for(i=0;i<n;i++)
          if(strcmp(p[i].sex,"male")==0) {man[j]=p[i].high;j++;}
          else  {woman[k]=p[i].high;k++;}
      for(i=j-2;i>=0;i--)
          for(i2=0;i2<=i;i2++)
              if(man[i2]>man[i2+1]) {hehe=man[i2+1];man[i2+1]=man[i2];man[i2]=hehe;}
      for(i=k-2;i>=0;i--)
          for(i2=0;i2<=i;i2++)
              if(woman[i2]<woman[i2+1]) {hehe=woman[i2+1];woman[i2+1]=woman[i2];woman[i2]=hehe;}
      for(i=0;i<j;i++)
      printf("%.2f ",man[i]);
      for(i=0;i<k-1;i++)
      printf("%.2f ",woman[i]);
      printf("%.2f",woman[i]);
}


int main()
{
    int n;
    char sex[7];
    float high[40];
    float male[40];
    float female[40];
    float temp;
    int m=0,f=0;
    int i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
                    scanf("%s%f",sex,&high[i]);
                    if(sex[0]=='m')
                    male[m++]=high[i];
                    else
                    female[f++]=high[i];
    }

    for(i=1;i<m;i++)
    for(j=1;j<m-i+1;j++)
    if(male[j-1]>male[j])
    {
                         temp=male[j-1];
                         male[j-1]=male[j];
                         male[j]=temp;
    }
    for(i=1;i<f;i++)
    for(j=1;j<f-i+1;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++)
    printf("%.2f ",male[i]);

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

    }


int Compare(const void *elem1, const void *elem2)
{
    return *((int *)(elem1)) - *((int *)(elem2));
}
struct Student
{
	char sex[10];
	float height;
}stu[40];
int main()
{
	int n,z,k1=0,k2=0;
	float male[40],female[40];
	char a[10]="male",b[10]="female";
	int i,i1,i2,i3;
    scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %f",stu[i].sex,&stu[i].height);
		z=strcmp(stu[i].sex,a);
		if(z==0)
			{male[k1]=stu[i].height;
		    k1++;}
		else
			{female[k2]=stu[i].height;
		    k2++;}
	}
	qsort(male,k1,sizeof(float),Compare);
	qsort(female,k2,sizeof(float),Compare);
	for(i1=0;i1<k1;i1++)
	{
		printf("%.2f ",male[i1]);
	}
	for(i2=k2-1;i2>=1;i2--)
	{
		printf("%.2f ",female[i2]);
	}
	printf("%.2f",female[0]);
}


struct ren
{
     char a[10];
     float b;
};
void l(float *a,int n)
{
     float k;
     for(int i=0;i<n;i++)
     for(int j=i;j<n;j++)
     {
          if(a[j]<a[i])
          {
               k=a[i];
               a[i]=a[j];
               a[j]=k;
          }
     }
}
main()
{
     void l(float *a,int n);
     int n,p=0,q=0;
     struct ren m[40];
     float f[40],g[40];
     scanf("%d",&n);
     for(int i=0;i<n;i++)
     {
          scanf("%s",m[i].a);
          scanf("%f",&m[i].b);
          if(strcmp(m[i].a,"male")==0)
          {
               f[p]=m[i].b;
               p++;
          }
          else
          {
               g[q]=m[i].b;
               q++;
          }
     }
     l(g,q);
     l(f,p);
     for(int i=0;i<p;i++)
     {
             printf("%.2f",f[i]);
             printf(" ");
     }
     for(int i=q-1;i>=0;i--)
     {
          printf("%.2f",g[i]);
          if(i!=0) printf(" ");
     }
}


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

char a[10];
float man[100],woman[100];
int l1=1,l2=1;

int main()
{
	int M;
	float b;
	scanf("%d",&M);
	for(int i=1;i<=M;i++)
	{
		scanf("%s %f",&a,&b);
			if(a[0]=='m')
			{
				man[l1++]=b;
			}
			else
			{
				woman[l2++]=b;
			}
	}
	sort(man+1,man+l1);
	sort(woman+1,woman+l2);

	printf("%.2f",man[1]);
	for(int i=2;i<l1;i++)
		printf(" %.2f",man[i]);
	for(int i=l2-1;i>=1;i--)
		printf(" %.2f",woman[i]);
	puts("");
	//getchar();
	//getchar();
	//getchar();
	return 0;
}


int main(){
  int n,i,k,man=0,woman=0;
  char sex[7];
  double h,x,male[40],female[40];
  char a[5]={'m','a','l','e','\0'};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %lf",sex,&h);
    if((strcmp(sex,a))==0){
      male[man]=h;
      man++;
    }else{
      female[woman]=h;
      woman++;
    }
  }
  for(k=1;k<=man;k++){
    for(i=0;i<man-k;i++){
      if(male[i]>male[i+1]){
        x=male[i+1];
        male[i+1]=male[i];
        male[i]=x;
      }
    }
  }
  for(k=1;k<=woman;k++){
    for(i=0;i<woman-k;i++){
      if(female[i]>female[i+1]){
        x=female[i+1];
        female[i+1]=female[i];
        female[i]=x;
      }
    }
  }
  for(i=0;i<man;i++){
    printf("%.2lf ",male[i]);
  }
  for(i=woman-1;i>0;i--){
    printf("%.2lf ",female[i]);
  }
  printf("%.2lf",female[0]);
  return 0;
}


int main()
{
	int N;
	scanf("%d",&N);
	int count1=0,count2=0;
	float male[40]={0.0};
	float female[40]={0.0};
	char judge [10]={'\0'};
	for(int i=0;i<N;i++)
	    {
		scanf("%s",judge);
		if(judge[0]=='m')
		   {
		    scanf("%f",&male[count1]);
			count1++;
		   }
		else
		    {
			scanf("%f",&female[count2]);
			count2++;
			}
		}
	for(int i=0;i<count1;i++)
	    {
		for(int j=i+1;j<count1;j++)
		    {
			float temp=0.0;
			if(male[i]>male[j])
			   {
			   temp=male[i];
			   male[i]=male[j];
			   male[j]=temp;
			   }
			}
		}
	for(int i=0;i<count2;i++)
	    {
		for(int j=i+1;j<count2;j++)
		    {
			float temp=0.0;
			if(female[i]<female[j])
			   {
			   temp=female[i];
			   female[i]=female[j];
			   female[j]=temp;
			   }
			}
		}
	printf("%.2f",male[0]);
	for(int i=1;i<count1;i++)
	    printf(" %.2f",male[i]);
	for(int i=0;i<count2;i++)
	    printf(" %.2f",female[i]);
}


int main()
{
    int n;
    int i,j,k,p,q;
    scanf("%d",&n);
    char sex[50][7];
    float height[50],heightofboy[50],heightofgirl[50],temp;
    for(i=0;i<=n-1;i++)
    {
        scanf("%s %f",&sex[i],&height[i]);
    }
    for(i=0,j=0,k=0;i<=n-1;i++)
    {
        if(strcmp(sex[i],"male")==0)
        {
            heightofboy[j]=height[i];
            j++;
        }
        else
        {
            heightofgirl[k]=height[i];
            k++;
        }
    }
    //???????+??
    for(i=0;i<j;i++)
    {
        for(p=0;p<j-i-1;p++)
        {
            if(heightofboy[p]>heightofboy[p+1])
            {
                temp=heightofboy[p];
                heightofboy[p]=heightofboy[p+1];
                heightofboy[p+1]=temp;
            }
        }
    }
    for(i=0;i<j;i++)
    {
        printf("%.2f ",heightofboy[i]);
    }
   //???????+??
   for(i=0;i<k;i++)
   {
       for(q=0;q<k-i-1;q++)
       {
           if(heightofgirl[q]<heightofgirl[q+1])
           {
               temp=heightofgirl[q];
               heightofgirl[q]=heightofgirl[q+1];
               heightofgirl[q+1]=temp;
           }
       }
   }
   for(i=0;i<k-1;i++)
    {
        printf("%.2f ",heightofgirl[i]);
    }
    printf("%.2f",heightofgirl[k-1]);
}


int main()
{
	char sex[7];
	int i, n, j = 0, k = 0, h;
	float male[40] = {0.0}, female[40] = {0.0}, height = 0.00;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> sex >> height;
		if (sex[0] == 'm')
			male[j++] = height;
		else
			female[k++] = height;
	}
	for (i = 0; i <= j - 1; i++)
	{
		for (h = i + 1; h <= j - 1; h++)
		{
			if (male[i] > male[h])
			{
				height = male[i];
				male[i] = male[h];
				male[h] = height;
			}
		}
	}
	for (i = 0; i <= j - 1; i++)
		cout << setprecision(2) << fixed << male[i] << " ";
	for (i = 0; i <= k - 1; i++)
	{
		for (h = i + 1; h <= k - 1; h++)
		{
			if (female[i] < female[h])
			{
				height = female[i];
				female[i] = female[h];
				female[h] = height;
			}
		}
	}
	for (i = 0; i <= k - 2; i++)
		cout << setprecision(2) << female[i] << " ";
	cout << setprecision(2)  << female[k - 1];
	return 0;
}


const int maxn=105;
double a[maxn], b[maxn];

int main()
{
    char str[20], n, m, i, j, T;
    while (scanf ("%d", &T)!=EOF)
    {
        n=0; m=0;
        while (T--)
        {
            scanf ("%s", str);
            if (str[0]=='m')
            {
                scanf ("%lf", a+n);
                n++;
            }
            else{
                scanf ("%lf", b+m);
                m++;
            }
        }
        sort (a, a+n); sort (b, b+m);
        for (i=0; i<n; i++)
            printf ("%.2lf ", a[i]);
        for (i=m-1; i>=0; i--)
        {
            printf ("%.2lf", b[i]);
            if (i) printf (" ");
            else printf ("\n");
        }
    }
    return 0;
}


int main()
{
 int n,a=0,b=0,paohuihaoduo;
 char zonggong[]={"female"},paohui[7];
 float hanzi[40],meizi[40],paohuierhao;
 scanf("%d",&n);
 for(int i=0;i<n;i++)
 {
  scanf("%s",&paohui);
  paohuihaoduo=strcmp(paohui,zonggong);
  if(paohuihaoduo==0)
  {
   scanf("%f",&meizi[a]);
   a++;
  }
  else
  {
   scanf("%f",&hanzi[b]);
   b++;
  }
 }
 for(int i=0;i<b-1;i++)
 {
  for(int j=i+1;j<b;j++)
  {
   if(hanzi[i]>hanzi[j])
   {
    paohuierhao=hanzi[i];
    hanzi[i]=hanzi[j];
    hanzi[j]=paohuierhao;
   }
  }
 }
 for(int i=0;i<a-1;i++)
 {
  for(int j=i+1;j<a;j++)
  {
   if(meizi[i]<meizi[j])
   {
    paohuierhao=meizi[i];
    meizi[i]=meizi[j];
    meizi[j]=paohuierhao;
   }
  }
 }
 for(int i=0;i<b;i++)
  printf("%.2f ",hanzi[i]);
 for(int i=0;i<a;i++)
 {
  if(i==a-1)
   printf("%.2f",meizi[i]);
  else
   printf("%.2f ",meizi[i]);
 }
 return 0;
}


void main()
{
	int n;
	int i,j;
	float tmp;
	float a[40]={0};
	float b[40]={0};
	int t=0;
	int s=0;
	struct
	{
		char sex[5];
		float high;
	}stu[40];

	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%s",&stu[i].sex);
		scanf("%f",&stu[i].high);
	}

	for (i=0;i<n;i++)
	{
		if (strcmp(stu[i].sex,"male")==0)
		{
			a[t]=stu[i].high;
			t=t+1;
		}
		else
		{
			b[s]=stu[i].high;
			s=s+1;
		}
	}

	for (i=0;i<t-1;i++)
	{
		for (j=i+1;j<t;j++)
		{
			if (a[i]>a[j])
			{
				tmp=a[i];
				a[i]=a[j];
				a[j]=tmp;
			}
		}
	}

	for (i=0;i<s-1;i++)
	{
		for (j=i+1;j<s;j++)
		{
			if (b[i]<b[j])
			{
				tmp=b[i];
				b[i]=b[j];
				b[j]=tmp;
			}
		}
	}

	for (i=0;i<t;i++)
		stu[i].high=a[i];
	for (i=t;i<s+t;i++)
		stu[i].high=b[i-t];
	printf("%.2f",stu[0].high);
	for (i=1;i<s+t;i++)
		printf("% .2f",stu[i].high);
}


struct people
{
    char a[7];
    float l;
};
int main()
{
    int n,i,j;
    struct people* p;
    struct people pp;
    char* v="male";
    scanf("%d",&n);
    p=(struct people*)malloc(n*sizeof(struct people));
    for(i=0;i<n;i++)
        scanf("%s %f",p[i].a,&p[i].l);
    for(i=0;i<n-1;i++)
    {
        for(j=i+1;j<n;j++)
        if(strcmp(p[i].a,p[j].a)<0)
        {
            pp=p[i];
            p[i]=p[j];
            p[j]=pp;
        }
        else
        {
        if(p[i].l>p[j].l&&strcmp(p[i].a,v)==0&&strcmp(p[j].a,v)==0)
        {
            pp=p[i];
            p[i]=p[j];
            p[j]=pp;
        }
        if(p[i].l<p[j].l&&strcmp(p[i].a,v)!=0&&strcmp(p[j].a,v)!=0)
        {
            pp=p[i];
            p[i]=p[j];
            p[j]=pp;
        }
        }
    }
    for(i=0;i<n-1;i++)
    printf("%.2f ",p[i].l);
    printf("%.2f",p[n-1].l);
    free(p);
    return 0;
}


int main ()
{
	int n;
	double a[40],c[40],k;
	double temp;
	char b[40];
	int len1=0,len2=0;
	cin>>n;
	//cout<<n<<"m"<<endl;
	for(int i=0;i<n;i++)
	{
		cin>>b>>k;
		if(b[0]=='f')
			a[len1++]=k;
		else c[len2++]=k;
	}
	for(int i=0;i<len1-1;i++)
		for(int j=0;j<len1-1-i;j++)
			{
				if(a[j]<a[j+1])
				{
				    temp=a[j];a[j]=a[j+1];a[j+1]=temp;
				}
			}
	for(int i=0;i<len2-1;i++)
				for(int j=0;j<len2-1-i;j++)
				{
					if(c[j]>c[j+1])
					{
						temp=c[j];c[j]=c[j+1];c[j+1]=temp;
					}
				}

	for(int i=0;i<len2;i++)
		cout<<fixed<<setprecision(2)<<c[i]<<" ";
	for(int i=0;i<len1;i++)
		{if(i==0)
			cout<<a[i];
		else cout<<fixed<<setprecision(2)<<" "<<a[i];}
	return 0;
}


float height;
float p1[nMax],p2[nMax];
char ss[10];
int cmp(const void *a,const void *b){
    return *(float *)a-*(float *)b;
}
int main (){
    int n;
    scanf("%d",&n);
    int i;
    int u=0,v=0;
    for(i=0;i<n;i++){
        scanf("%s%f",ss,&height);
        if(strcmp(ss,"male")==0){p1[u]=height;u++;}
        else if(strcmp(ss,"female")==0){p2[v]=height;v++;}
    }
    sort(p1,p1+u);
    sort(p2,p2+v);
    for(i=0;i<u;i++){
        printf("%.2f ",p1[i]);
    }
    for(i=v-1;i>=0;i--){
        printf("%.2f",p2[i]);
        if(i!=0){
            printf(" ");
        }
    }
    printf("\n");
        return 0;
}


int main()
{
	int n, i, j = 1, k = 1;
	cin >> n;
	char sex[40][10];
	double male[40], female[40];
	for (i = 1; i <= n; i++)
	{
		cin >> sex[i];
		if (sex[i][0] == 'm')
		{
			 cin >> male[j];
			 j++;
		}
		else
		{
			cin >> female[k];
			k++;
		}
	}
	int j0 = j - 1, k0 = k - 1;
	for (k = 1; k <= j0; k++)
	{
		for (i = 1; i <= j0 - k; i++)
		{
			if (male[i] > male[i+1])
			{
				male[0] = male[i];
				male[i] = male[i+1];
				male[i+1] = male[0];
			}
		}
	}
	for (k = 1; k <= k0; k++)
	{
		for (j = 1; j <= k0 - k; j++)
		{
			if (female[j] < female[j+1])
			{
				female[0] = female[j];
				female[j] = female[j+1];
				female[j+1] = female[0];
			}
		}
	}
	for (i = 1; i <= j0; i++)
	{
		cout << fixed << setprecision(2) << male[i] << " ";
	}
	for (j = 1; j < k0; j++)
	{
		cout << fixed << setprecision(2) << female[j] << " ";
	}
	cout << fixed << setprecision(2) << female[j];

return 0;
}


int main(){
	int i,n,male=1,female,j,k;
	double shengao,pai[45],huan;
	char x[10];
	scanf("%d",&n);
	female=n;
	for(i=0;i<n;i++){
		scanf("%s\n %lf",x,&shengao);
		if(x[0]=='m'){
			pai[male]=shengao;
			male++;
		}
		if(x[0]=='f'){
			pai[female]=shengao;
			female--;
		}
	}
		male--;
		female++;
		for(j=1;j<=male;j++){
			for(k=j;k<=male;k++){
				if(pai[k]<pai[j]){
					huan=pai[k];
					pai[k]=pai[j];
					pai[j]=huan;
				}
			}
		}
		for(j=male+1;j<=n;j++){
			for(k=j;k<=n;k++){
				if(pai[k]>pai[j]){
					huan=pai[k];
					pai[k]=pai[j];
					pai[j]=huan;
				}
			}
		}
		for(i=1;i<n;i++)
		printf("%.2lf ",pai[i]);
		printf("%.2lf\n",pai[n]);
		return 0;
}


main()
{
	int i,j,k,n,m,x,t=0;
	struct stu
	{
    	float h;
		char s[SEX+1];
	}a[MAX];
	scanf("%d",&n);
	for(i=0;i<n;i++)
    scanf("%s%f",a[i].s,&a[i].h);

	for(i=0;i<n;i++)
	{
		k=i;
		if(strcmp(a[i].s,"male" )==0)
		{   t++;
			for(j=i+1;j<n;j++)
			{
				if( strcmp(a[j].s,"male" )==0&&a[j].h<a[k].h){
				k=j;}
				else continue;
			}
		 if(t==1)printf("%.2f",a[k].h);
	 	 else printf(" %.2f",a[k].h);

		 	a[k]=a[i];
		}
	}
	for(i=0;i<n;i++)
	{
		k=i;
		if(strcmp(a[i].s,"female" )==0 )
		{
			for(j=i+1;j<n;j++)
			{
				if(strcmp(a[j].s,"female" )==0 &&a[j].h>a[k].h)k=j;
			}

				 printf(" %.2f",a[k].h);

		 	a[k]=a[i];
		}
		else continue;
	}
}


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


int main(){
  float male[42];
  float female[40];
  char  sex[8];
  char  ma[]="male";
  char  fe[]="female";
  float height;
  int n,i=0,j=0,m_num=0,f_num=0;
  scanf("%d",&n);
  while(n){
    scanf("%s %f",&sex,&height);
    if(strcmp(sex,ma)==0){
      male[i]=height;
	  i++;
	  m_num++;
    }else{
		female[j]=height;
		j++;
		f_num++;
	}
    n--;
  }
  float tmp;
  for(i=1;i<=m_num;i++){
	  for(j=0;j<m_num-1;j++){
		  if(male[j]>male[j+1])
		  {
			tmp=male[j];
			male[j]=male[j+1];
			male[j+1]=tmp;
		  }
	  }
  }

  for(i=1;i<=f_num;i++){
	  for(j=0;j<f_num-1;j++){
		  if(female[j]<female[j+1])
		  {
			tmp=female[j];
			female[j]=female[j+1];
			female[j+1]=tmp;
		  }
	  }
  }

  for(i=1;i<=f_num;i++){
	  male[i+m_num-1]=female[i-1];
  }

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


char sex[50][7];
float tall[50];
float sort1[50]={0};
float sort2[50]={0};
char m[7]="male";
char f[7]="female";

void x(float s[50],int n)
{
	int i,j;
	float tmp;
	for(i=n-1;i>0;i--)
	{
		for(j=0;j<i;j++)
		{
			if(s[j]>s[j+1])
			{
				tmp=s[j];
				s[j]=s[j+1];
				s[j+1]=tmp;
			}
		}
	}
}

void x1(float s[50],int n)
{
	int i,j;
	float tmp;
	for(i=n-1;i>0;i--)
	{
		for(j=0;j<i;j++)
		{
			if(s[j]<s[j+1])
			{
				tmp=s[j];
				s[j]=s[j+1];
				s[j+1]=tmp;
			}
		}
	}
}

int main()
{
	int N,count;
	int i=0;
	int j=0;
	scanf("%d",&N);
	count = N;
	while(N--)
	{
		scanf("%s",sex[i]);
		scanf("%f",&tall[i]);
		i++;
	}

	for(i=0,j=0;i<count;i++)
	{
		if(!strcmp(sex[i],"male"))
		{
			sort1[j]=tall[i];
			j++;
		}
	}

	x(sort1,j);

	for(i=0;i<j;i++)
	{
		printf("%.2f ",sort1[i]);
	}

	for(i=0,j=0;i<count;i++)
	{
		if(!strcmp(sex[i],"female"))
		{
			sort2[j]=tall[i];
			j++;
		}
	}

	x1(sort2,j);

	for(i=0;i<j-1;i++)
	{
		printf("%.2f ",sort2[i]);
	}
    printf("%.2f",sort2[j-1]);
	printf("\n");
	return 0;
}


  int main(){
      double high[40];
      double manhigh[40];
      double womanhigh[40];
      double sa;
      char sex[40][10];
      int n,i,j,k,a;
      char man[5]={'m','a','l','e'};
      char woman[7]={'f','e','m','a','l','e'};
      scanf("%d",&n);
      for(i=0;i<n;i++){
        scanf("%s %lf",sex[i],&high[i]);
      }
      j=0;
      k=0;
      for(i=0;i<n;i++){
        if(strcmp(sex[i],man)==0){
          manhigh[j]=high[i];
          j++;
        }else{
          womanhigh[k]=high[i];
          k++;
        }
      }
      for(i=0;i<j-1;i++){
         for(a=0;a<j-1-i;a++){
            if(manhigh[a]>manhigh[a+1]){
              sa=manhigh[a];
              manhigh[a]=manhigh[a+1];
              manhigh[a+1]=sa;
            }
         }
      }
      for(i=0;i<k-1;i++){
         for(a=0;a<k-1-i;a++){
            if(womanhigh[a]>womanhigh[a+1]){
              sa=womanhigh[a];
              womanhigh[a]=womanhigh[a+1];
              womanhigh[a+1]=sa;
            }
         }
      }
      for(i=0;i<j;i++){
        printf("%.2lf ",manhigh[i]);
      }
      if(k==1){
         printf("%.2lf",womanhigh[0]);
      }else{
       for(i=k-1;i>0;i--){
         printf("%.2lf ",womanhigh[i]);
       }
       printf("%.2lf",womanhigh[0]);
      }

    return 0;
  }


double ma[100] = {0.00}, fe[100] = {0.00};

void quick_sort1(double a[], int l, int r)
{
	if (l >= r)
		return;
	int lo = l, hi = r;
	double k = a[l];
	while (lo != hi)
	{
		while ((lo < hi) && (a[hi] >= k))
			hi--;
		a[lo] = a[hi];
		while ((lo < hi) && (a[lo] <= k))
			lo++;
		a[hi] = a[lo];
	}
	a[lo] = k;
	quick_sort1(a, l, lo - 1);
	quick_sort1(a, lo + 1, r);
}

void quick_sort2(double a[], int l, int r)
{
	if (l >= r)
		return;
	int lo = l, hi = r;
	double k = a[l];
	while (lo != hi)
	{
		while ((lo < hi) && (a[hi] <= k))
			hi--;
		a[lo] = a[hi];
		while ((lo < hi) && (a[lo] >= k))
			lo++;
		a[hi] = a[lo];
	}
	a[lo] = k;
	quick_sort2(a, l, lo - 1);
	quick_sort2(a, lo + 1, r);
}

int main()
{
	int n, i, man = 0, feman = 0;
	char a[10];
	cin >> n;
	cin.get();
	for (i = 1; i <= n; i++)
	{
		cin >> a;
		if (a[0] == 'm')
		{
			cin >> ma[man];
			man++;
		}
		if (a[0] == 'f')
		{
			cin >> fe[feman];
			feman++;
		}
		cin.get();
	}
	man--;
	feman--;
	quick_sort1(ma, 0, man);
	quick_sort2(fe, 0, feman);
	cout << fixed;
	for (i = 0; i <= man; i++)
		cout << setprecision(2) << ma[i] << " ";
	for (i = 0; i<= feman - 1; i++)
		cout << setprecision(2) << fe[i] << " ";
	cout << fe[feman] << endl;
	return 0;
}


int main()
{
	char currChar, lastChar;
	int lastCount = 1;
	cin >> lastChar;
	if (lastChar <= 'z' && lastChar >= 'a')
		lastChar += 'A' - 'a';
	while (cin >> currChar)
	{
		if (currChar <= 'z' && currChar >= 'a')
			currChar += 'A' - 'a';
		if (currChar != lastChar)
		{
			cout << '(' << lastChar << ',' << lastCount << ')';
			lastCount = 1;
			lastChar = currChar;
		}
		else
			lastCount++;
	}
	cout << '(' << lastChar << ',' << lastCount << ')';
	return 0;
}


int main()
{
	int i=0;
	char a[1000];
	gets(a);
	while(a[i]!='\0')
	{
		if(a[i]>='a'&&a[i]<='z')
			a[i]+='A'-'a';
		i++;
	}
	i=0;
	char letter=a[0];
	int again=0;
	while(1)
	{
		if(a[i]==letter)
			again++;
		if(a[i]!=letter)
			{
				printf("(%c,%d)",letter,again);
				again=1;
				letter=a[i];
			}
		if(a[i]=='\0')
			break;
		i++;
	}
	return 0;
}


main()
{
      char str[1000];
      int i,sum;
      gets(str);
      i=0;
      sum=1;
      while(str[i]!='\0')
      {
          while(str[i]==str[i+1]||str[i]==str[i+1]+32||str[i]==str[i+1]-32)
          {
          sum=sum+1;
          i=i+1;
          }
      if (str[i]>='a'&&str[i]<='z')
      str[i]=str[i]-32;
      printf("(%c,%d)",str[i],sum);
      i=i+1;
      sum=1;
      }
      getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();
}


int main()
{
	char str[2000];
	int i,j=0,t;
	gets(str);
	t=strlen(str);
	for(i=0;i<t;i++)
	{
		if(str[i]>'Z')
			str[i]-=32;
	}
	for(i=0;i<t;i++)
	{
		if(str[i]!=str[i-1])
		{
			for(j=i;j<t;j++)
			{if(str[j]!=str[i])
			break;
			}
			printf("(%c,%d)",str[i],j-i);
		}
	}
	return 0;
}


int main()
{
	char input[1001] = {0};
	cin >> input;
	int i, count = 0;
	char c = toupper(input[0]);
	for (i = 0; i < strlen(input); i++)
	{
		if (input[i] == c || toupper(input[i]) == c)
			count++;
		else
		{
			cout << '(' << c << ',' << count << ')';
			count = 1;
			c = toupper(input[i]);
		}
	}
	cout << '(' << c << ',' << count << ')' << endl;
	return 0;
}


/*
 * 2.cpp
 *
 *  Created on: 2011-12-31
 *      Author: 2011
 */
int main()
{

	char a[1000]={0};
	cin>>a;
	//char str1[26]="ABCDEFGHIJKLMNOPQRSTUVWXYZ",str2[26]="abcdefghijklmnopqrstuvwxyz";
	int num[27]={0};
	int len=strlen(a);
	int i=0,j=0;
	for(i=0;i<len;i++)if(a[i]>='a')a[i]-=('a'-'A');
	for(i=0;i<len;i++){
		num[a[i]-'A']++;
		for(j=i+1;j<len;j++){
			if(a[j]==a[i])num[a[i]-'A']++;
			else break;
		}
		cout<<'('<<a[i]<<','<<num[a[i]-'A']<<')';
		num[a[i]-'A']=0;
		i=j-1;
	}
	cout<<endl;
	return 0;
}


struct jisuan
{
	char zimu;
	int count;
}ji[1000];
int zhuanhua(char a)
{
	if(a>='a'&&a<='z')
		return a-32;
	else
		return a;
}
int main()
{
	char str[1001];
	cin>>str;
	int i,l,flag;
	l=strlen(str);
	str[0]=zhuanhua(str[0]);
	ji[0].zimu=str[0];
	ji[0].count =1;
	flag=0;
	for(i=1;i<l;i++)
	{
		str[i]=zhuanhua(str[i]);
		if(str[i]==str[i-1])
			ji[flag].count++;
		else
		{
			flag++;
			ji[flag].zimu=str[i];
			ji[flag].count=1;
		}
	}
	for(i=0;i<=flag;i++)
		cout<<"("<<ji[i].zimu<<","<<ji[i].count <<")";
	return 0;
}


int main()
{
	char num[100];
	for(int i=0;i<100;i++)
	{
		num[i]='0';
	}
	scanf("%s",num);
	for(int i=0;i<100;i++)
	{
		if(num[i]=='0')
		{
			num[i-1]='0';
			break;
		}
	}
	char currChar=num[0];
	if(currChar>='a')
	{
		currChar-='a';
	}
	else
	{
		currChar-='A';
	}
	int count=1;
	int step=0;
	char outChar[100];
	int outNum[100];
	int i=1;
	while(num[i]!='0')
	{
		char nowChar=num[i];
		if(nowChar>='a')
		{
			nowChar-='a';
		}
		else
		{
			nowChar-='A';
		}
		if(currChar==nowChar)
		{
			count++;
		}
		else
		{
			outChar[step]=currChar;
			outNum[step]=count;
			count=1;
			step++;
			currChar=nowChar;
		}
		i++;
	}
	outChar[step]=currChar;
	outNum[step]=count;
	count=0;
	step++;

	for(int j=0;j<step;j++)
	{
		printf("(%c,%d)",outChar[j]+'A',outNum[j]);
	}

	return 0;
}


char q[1200];
char lastQ;
int head,length;

char MT(char q)
{
if ((q>='a')&&(q<='z')) return q-'a'+'A';
}

int main()
{
cin>>q;
head=1;length=1;lastQ=q[0];
while (q[head]!='\0')
{
if (MT(q[head])==MT(lastQ)) length++;
else
{
cout<<'('<<MT(lastQ)<<','<<length<<')';
lastQ=q[head];length=1;
}
head++;
}
cout<<'('<<MT(lastQ)<<','<<length<<')'<<endl;
return 0;
}


struct letter
{
	char k;
	int res;
}number[1000];

int main()
{
	char a[1100]={0};
	cin>>a;
	int p=0;
	for(int i=0;i<1000;i++)
	{
		number[i].res=0;
	}
	for(int i=0;i<strlen(a);i++)
	{
		if(a[i]<='z'&&a[i]>='a')
		{
			a[i]=a[i]+'A'-'a';
		}
	}
	for(int i=0;i<strlen(a)-1;i++)
	{
		    number[p].k=a[i];
			number[p].res++;
		if(a[i]!=a[i+1])  p++;

	}
	number[p].k=a[strlen(a)-1];
			number[p].res++;
	for(int i=0;i<p+1;i++)
	{
		cout<<"("<<number[i].k<<","<<number[i].res<<")";
	}

	return 0;
}


void c(char *p,int l)
{
     int i;

    for(i=0;i<l;i++)
    {
    if((*(p+i))>='a'&&(*(p+i))<='z')
    *(p+i)=*(p+i)+('A'-'a');
}

}
int f(char x,char y)
{

    if(x==y)
    return 1;
    else
    return 0;
}
main()
{    int l;
int e;
int count=0;
      char a[1000];
      char *p;
      char q;
      int i;
      scanf("%s",a);
      l=strlen(a);
      p=a;
      c(p,l);
      for(i=0;i<l;i++)
      {
if(l==1)
 printf("(%s,1)",a);
      if(i==0)
      {
      q=a[i];
      count++;
      }
      else
      {
          if(i!=(l-1))
      {
          e=f(q,a[i]);
          if(e==0)
          {
          printf("(%c,%d)",q,count);
          q=a[i];
          count=1;
                  }
          else
          count++;
      }
      else
      {
      if(q==a[l-1])
       printf("(%c,%d)",q,(count+1));
       else
       {
       printf("(%c,%d)",q,count);
        printf("(%c,1)",a[l-1]);
       }
       }
       }
                      }
                      printf("\n");
                      getchar();
                      getchar();
                      getchar();
      }


int main()
{
	char str[1001];
	cin>>str;
	int i,counter;
	for (i=0;str[i]!='\0';i++)
	{
		if (str[i]>='a' && str[i]<='z')
		{
			str[i]=str[i]+'A'-'a';
		}
	}
	char temp;
	counter=1;
	temp=str[0];
	for (i=1;str[i-1]!='\0';i++)
	{
		if (temp==str[i])
			counter++;
		else
		{
			cout<<'('<<temp<<','<<counter<<')';
			counter=1;
			temp=str[i];
		}
	}
	return 0;
}


//?????????
void change(char * a)
{
	int l=strlen(a);
	int i;
	for(i=0;i<l;i++)
	{
		if((a[i]>='a')&&(a[i]<='z'))
		{
			a[i]=a[i]-'a'+'A';
		}
	}
	return;
}

int main()
{
	int temp_num;
	int l;
	int i;
	char temp_char;
	char st[1024];   //?????????????????????
	scanf("%s",st);
	change(st);
	//printf("%s",st);  //debug
	l=strlen(st);
	temp_num=1;
	temp_char=st[0];
	for(i=1;i<=l;i++)  //?<???????????
	{
		if(st[i]==temp_char)
			temp_num++;
		else
		{
			printf("(%c,%d)",temp_char,temp_num);
			temp_char=st[i];
			temp_num=1;
		}
	}
	return 0;
}


main()
{
	int a,i,j,k,num,length;
	char words[1000];
	gets(words);
	length=strlen(words);
	for(i=0;i<length;i++)
	words[i]=toupper(words[i]);
	for(i=0;i<length;i++)
	{
			num=1;
		for(j=i;j<length;j++)
		{
			if(words[j]==words[j+1]) num++;
			else break;
		}
		if(words[i]!=words[i-1])
			printf("(%c,%d)",words[i],num);
	}

}


int main()
{
	char arr[1001];
	cin >> arr;
	int i,len,temp=0;
	len=strlen(arr);
	for(i=0;i<len;i++){
		if((int)arr[i] > 92) arr[i] = (char)((int)arr[i]-32);
	}
	for(i=1;i<len;i++){
		if(arr[i] != arr[i-1]){
			cout << '(' << arr[i-1] << ',' << i-temp << ')';
			temp=i;
		}}
	cout << '(' << arr[len-1] << ',' << len-temp << ')' << endl;
	return 0;
}


int main()
{
	char str[1000];
	int i,n,s,count;
	char k;
	scanf("%s",str);
	n=strlen(str);
	if(str[0]<97)
	k=str[0];
	else
		k=str[0]-32;
	count=1;
	for(i=1;i<n;i++)
	{
		if(str[i]==k||str[i]-32==k)
		{
			count=count+1;
		}
		else
		{
			printf("(%c,%d)",k,count);
			if(str[i]<97)
	        k=str[i];
	        else
		    k=str[i]-32;
			count=1;}

	}
		printf("(%c,%d)",k,count);
	return 0;
}


int main()
{
    char a[1000];
    gets(a);
    char t;
    int i,l,count;
    l=strlen(a);
    for(i=0;i<l;i++)
        if(a[i]>='a'&&a[i]<='z')
            a[i]=a[i]-'a'+'A';
    t=a[0];
    count=1;
    for(i=1;i<l;i++)
    {
        if(a[i]==t)
            count++;
        else
        {
            printf("(%c,%d)",t,count);
            t=a[i];
            count=1;
        }
    }
    t=a[l-1];
    printf("(%c,%d)\n",t,count);
}


main()
{
      char s[1010];
      int l,i,j,k,x;
      char c;

      gets(s);
      l=strlen(s);
      for (i=0;i<l;i++)
          s[i]=toupper(s[i]);
      i=0;
      while (i<l)
      {
            c=s[i];
            j=i+1;
            while (j<l && s[j]==c)
                j++;
            x=j-i;
            printf("(%c,%d)",c,x);
            i=j;
      }
      //puts(s);
      printf("\n");
      getchar();
      getchar();

}


/*
 * Run-lengthEncoding.cpp
 *
 *  Created on: 2012-12-25
 *      Author: Cui Zhaoxiong Class4 1200012931
 */
int main(){
	char input[1005];
	cin >>input;
	char past;
	char zipc[1005];
	int zipi[1005];
	int flag=0;
	int length=strlen(input);
	for (int i=0;i<=length-1;i++){
		if (input[i]>='a') input[i]=input[i]-'a'+'A';
		if (i==0) {
			past=input[0];
			zipc[0]=past;
			zipi[0]=1;
		}else{
			if (past==input[i]){
				zipi[flag]++;
			}else{
				flag++;
				zipc[flag]=input[i];
				zipi[flag]=1;
			}
			past=input[i];
		}
	}
	for (int i=0;i<=flag;i++){
		cout <<'(' <<zipc[i] <<',' <<zipi[i] <<')';
	}
	return 0;
}


int main()
{
	int n,i,j=0;
	char a[1000];
	struct comp
	{
		char letter;
		int num;
	}com[1000];
	scanf("%s",a);
	n=strlen(a);
	for(i=0;i<n;i++)
	{
		com[i].num=0;
	}
	for(i=0;i<n;i++)
	{
		if(a[i]>=97&&a[i]<=122)
			a[i]=a[i]-32;
	}
	for(i=0;i<n;i++)
	{
		if(a[i]==com[j].letter)
		{
			com[j].num++;
		}
		else
		{
			j++;
			com[j].letter=a[i];
			com[j].num++;
		}
	}
	for(i=1;i<=j;i++)
	{
		printf("(%c,%d)",com[i].letter,com[i].num);
	}
	return 0;
}


int main()
{
	char str[1001];

	cin.getline(str,1001);

	int i,counter=0;
	char alp[1000]={0};
	int num[1000]={0};
	int flag=0;

	for (i=0;str[i]!='\0';i++)
	{
		if (str[i]>='a'&& str[i]<='z')
			str[i]=str[i]-'a'+'A';
		if (str[i]==alp[counter])
			num[counter]++;
		else
		{
			counter++;
			alp[counter]=str[i];
			num[counter]++;
		}
	}

	for (i=1;i<=counter;i++)
	{
		cout<<'('<<alp[i]<<','<<num[i]<<')';
	}

	return 0;
}


char str[1000];
int len;

int operation(int start)
{
	int i = start;
	int count = 0;
	for( ; str[i] == str[start]; i++)
		count++;
	cout << "(" << str[start] << "," << count << ")";

	return count;
}

int main()
{
	int i;
	cin >> str;
	len = strlen(str);
	for(i = 0; i < len; i++)
	{
		if(str[i] > 90)
			str[i] -= 32;
	}
	for(i = 0; i < len; i++)
		i += operation(i) - 1;
	cout <<endl;

	return 0;
}


char change(char ch)
{
	if (ch >= 'a' && ch <= 'z')
		return ch - 'a' + 'A';
	else
		return ch;
}

int main()
{
	int i, num = 1, len;
	char str[100];
	cin.getline(str, 100);
	len = strlen(str);
	cout << "(" << change(str[0]) << ",";
	for(i = 1; i < len; i++)
	{
		if(change(str[i]) == change(str[i - 1]))
			num++;
		else
		{
			cout << num << ")(" << change(str[i]) << ",";
			num = 1;
		}
	}
	cout << num << ")" << endl;
	/*if(change(str[len - 1]) == change(str[len - 2]))
		cout << num + 1 << ")" << endl;
	else
		cout << num << ")(" << change(str[len - 1]) << ",1)" << endl;*/
	return 0;
}


main()
{
      int i,j,n;
      int count;
      char a[1000];
      gets(a);
      n=strlen(a);
      for(i=0;i<n;i++)
      {
                      if(a[i]>='a'&&a[i]<='z')
                      a[i]=a[i]-'a'+'A';
      }

               count=0;
            for(j=0;j<n;j++)
                      {
                                      if(a[j]==a[0])
                                      count++;
                                      else  if(a[j]!=a[0])
                                      break;
                      }
                      printf("(%c,%d)",a[0],count);

      for(i=1;i<n;i++)
      {
                      count=0;
                      if(a[i]!=a[i-1])

                      {
                      for(j=i;j<n;j++)
                      {
                                      if(a[i]!=a[j])
                                      break;
                                      if(a[i]==a[j])
                                      count++;

                      }
                      printf("(%c,%d)",a[i],count);
                      }
      }
      getchar();
      getchar();
      getchar();
       getchar();
      getchar();
      getchar();
}


int main()
{
    char word[1000] ;
    cin>> word ;
    int length = strlen(word );
    for (int i = 0 ; i< length ; i++)
    {
        if (word[i] >= 'a' && word[i] <= 'z' )
            word[i]+=('A' - 'a') ; // ???????
    }
    char temp = word [0] ;
    int counts = 1 ;
    for (int i = 1 ; i< length ; i++)
    {
        if (word[i] != temp )
        {
            printf("(%c,%d)" ,temp ,counts );
            temp = word[i] ;
            counts = 1 ;
        }
        else
        {
            counts++;
        }
    }
    printf("(%c,%d)" ,temp ,counts );
    return 0;
}


char f(char x)
{

     if(x>='a')
     return x-'a'+'A';
     else
     return x;
     }
int main( )
{
int  a,b,i;
char str[1000];
scanf("%s", str);
a=f(str[0]);
b=1;

for(i = 1; i < strlen(str); i++)
{
      if (a==f(str[i]))
      b++;
      else
      {
          printf("(%c,%d)",a,b);
          a=f(str[i]);
          b=1;
      }
      }
printf("(%c,%d)",a,b);

}


char UpperCase(char chr)
{
	if (chr>='a'&&chr<='z')
		return 'A'-'a'+chr;
	else return chr;
}
int main()
{
	char str[1000];
	int count=1;
	cin>>str;
	char chr=str[0];
	for (int i=1;str[i]!=0;i++)
	{
		if (UpperCase(chr)==UpperCase(str[i]))
			count++;
		else
		{
			printf("(%c,%d)",UpperCase(chr),count);
			count=1;
		}

		chr=str[i];

	}
	printf("(%c,%d)",UpperCase(chr),count);

	return 0;
}


int main()
{
	char str[1000],*p,temp;
	int i,count=0;
	p=str;
	cin>>str;
	temp=*str;
	if(temp>'Z')
		temp-=32;
	count++;
	while(*++p!=0)
	{
		if(*p==temp||*p-32==temp)
			count++;
		else
		{
			printf("(%c,%d)",temp,count);
			count=1;
			temp=*p;
			if(temp>'Z')
				temp-=32;
		}
	}
	printf("(%c,%d)",temp,count);
	return 0;
}


int main()
{
	char a[1100];
	gets(a);
	int i,j,k,count=0;
	char b=0;
	i=0;
	while(1)
	{
		if(i>strlen(a))break;
		if(a[i]<='z'&&a[i]>='a')a[i]+='A'-'a';
		if(b==0){b=a[i];count=1;i++;continue;}
		if(a[i]==b)
			count++;
		else
		{

				cout<<"("<<b<<","<<count<<")";b=a[i];count=1;
			}
		i++;
	}

	return 0;
}


void change(char *a)
{
	char *p = a;
	while(*p != '\0')
	{
		if(*p >= 'a' && *p <= 'z')
			*p += 'A' - 'a';
		p++;
	}
	return;
}
int main()
{
	char str[1001];
	cin >> str;
	int count = 1;
	change(str);
	char *p = str;
	while(*p != '\0')
	{
		if(*p == *(p+1))
		{
			count++;
		}
		else
		{
			printf("(%c,%d)",*p,count);
			count = 1;
		}
		p++;
	}
	return 0;
}


//?? - ????

int main()
{
    char a[1101];
    int n;
    int count=0;
    char b;
    int i,j;
    scanf("%s",a);
    n=strlen(a);
    for(i=0;i<n;i++)
    {
                    if(a[i]>='a'&&a[i]<='z')
                    a[i]=a[i]-'a'+'A';
    }

          b=a[0];
          count++;
          if(n==1)printf("(%c,%d)",b,count);
          else
          for(j=1;j<n;j++)
          {
                          if(a[j]==b)
                          {
                          count++;
                          if(j==n-1)
                          printf("(%c,%d)",a[j],count);}
                          else
                          {

                              printf("(%c,%d)",a[j-1],count);
                              count=1;
                              b=a[j];
                              if(j==n-1)
                              printf("(%c,%d)",a[j],count);

                          }
     }
     getchar();
     getchar();

return 0;
}


char a[500];
void main()
{
	char mark;
	int i,sum=0,flag;
	gets(a);
for(i=0;a[i]!=0;i++)
if(a[i]>='a'&&a[i]<='z')a[i]+='A'-'a';
	mark=a[0];
	for(i=0,flag=0;a[i]!=0;i++){
		if(a[i]!=mark){
			printf("(%c,%d)",mark,sum);
			sum=1;
			mark=a[i];
		}
		else sum++;
	}
	printf("(%c,%d)",mark,sum);
}


int main()
{
	char s[1002];
	cin>>s;
	char mark = 0;
	int count = 0;
	for(int i = 0;i < strlen(s);i++)
	{
		char c = s[i];
		if(c >= 'a')
			c -= 32;
		if(c == mark)
		{
			count++;
		}
		else
		{
			if(mark != 0)
			{
				cout<<"("<<mark<<","<<count<<")";
			}
			mark = c;
			count = 1;
		}
	}
	cout<<"("<<mark<<","<<count<<")";
	return 0;
}


struct point
{
	int x;
	char y;
};
int main()
{
	char c[1100];
	int i,j,n,b=0;
	struct point dian[27];
	gets(c);
	n=strlen(c);
	for(i=0;i<n;i++)
	{
		if(c[i]>='a')
			c[i]=c[i]-32;
	}
	dian[0].y=c[0];
	j=0;
	dian[0].x=1;
	for(i=1;i<n;i++)
	{
		if(c[i]==c[i-1])
		{
			dian[j].x+=1;
		}
		else
		{
			j++;
			dian[j].y=c[i];
			dian[j].x=1;
		}
	}
	for(i=0;i<=j;i++)
	{
		printf("(%c,%d)",dian[i].y,dian[i].x);
	}
	return 0;
}


struct stu
{
	char letter;
	int count;
};
int main()
{
	struct stu b[1001];
	char c[1000];
	char *str,*p;
	int i,j;
	str=p=c;
	gets(c);
	while(*p)
	{
		if(*p>='a'&&*p<='z')
			*p=*p+'A'-'a';
		p++;
	}
	b[0].letter=*str;
	b[0].count=1;
	str++;
	j=0;
	while(*str)
	{
		if(*str==*(str-1))
			b[j].count++;
		else
		{
			j++;
			b[j].letter=*str;
			b[j].count=1;
		}
		str++;
	}
	for(i=0;i<=j;i++)
		printf("(%c,%d)",b[i].letter,b[i].count);
	return 0;
}


void main()
{
	char s[MAX];
	struct code{
		char c;
		int n;
	}t[MAX];
	int len,i,j,k;

	scanf("%s",s);
	len=strlen(s);
	for(i=0;i<len;i++){
		if(s[i]>=97&&s[i]<=122)
			s[i]-=32;
	}

	j=0;
	k=0;
	while(j<len){
		t[k].c=s[j];
		for(i=j;;i++){
			if(t[k].c!=s[i]){
				t[k].n=i-j;
				j=i;
				k++;
				break;
			}
		}
	}

	for(i=0;i<k;i++)
		printf("(%c,%d)",t[i].c,t[i].n);
	printf("\n");
}


char str[1000];
int main(int argc, char *argv[])
{
    char current;
    int q=0;
    cin.getline(str,1000,'\n');
    current=str[0]>=96?str[0]-'a'+'A':str[0];

    for(int i=0;i<strlen(str)+1;i++)
    {
        if(str[i]>=96)str[i]-='a'-'A';
        if(str[i]==current){
            q++;
        }
        else{
            cout<<"("<<current<<","<<q<<")";
            current=str[i];
            q=1;
        }
    }
    return EXIT_SUCCESS;
}


int main()
{
    int n,i,j,k,s;
    int l;
    char shuru[2000];
    scanf("%s",shuru);
   i=strlen(shuru);
   k=0;
   l=0;

   for(j=0;j<i;j++)
   {
       if(shuru[j]>90)
       shuru[j]=shuru[j]-32;
       else;
   }
   if(i==1)
   {
       printf("(%c,1)",shuru[k])  ;
   }
   else
   {

   while(k<i-1)
   {

        if(shuru[k]==shuru[k+1])
        {
                                s=1;
                do
               {
                 s++;

               }
                while(shuru[k]==shuru[k+s]);
                printf("(%c,%d)",shuru[k],s);

                k=k+s;
        }
        else
        {
            printf("(%c,1)",shuru[k]);
            k++;
            l++;
        }
       // printf("%d",k);

        if(k==i-1)
        printf("(%c,1)",shuru[k]);
        else;

   }
}

    getchar();
    getchar();
}


int main()
{
	char str[1000];
	scanf("%s",str);
	char charCurrent ,charNext;
	charCurrent = charNext = toupper(str[0]);
	int count = 0;
	for(int i = 0; str[i] != '\0'; i++)
	{
		charCurrent = toupper(str[i]);
		if(str[i + 1] == '\0')
		{
			if(charCurrent == charNext)
				count++;
			break;
		}
		charNext = toupper(str[i + 1]);
		if(toupper(str[i + 1]) == toupper(str[i]))
		{
			count++;
		}
		else
		{
			printf("(%c,%d)",charCurrent,count + 1);
			count = 0;
		}
	}
	printf("(%c,%d)",charCurrent,count);
	return 0;
}


/*
 *  Name:homework.cpp
 *  Created on: 2012-12-12
 *  Author: Meng Li
 *  Function:????
 *   */

int main(){                            //???
	char input[1000];
	cin >> input;
	int length=0;
	length=strlen(input);
	int i, count=0, j;
	for (i=0;i<length;i++){
		count=0;
		if (input[i]>=97)
			input[i]=input[i]-32;
		for (j=i;j<length;j++){
			if (input[i]==input[j]||input[j]==input[i]+32){
				count++;
			}
			else
				break;
		}
		cout << '(' << input[i] << ',' << count << ')';
		i=j-1;
	}
	return 0;
}


int main()
{
	char a[1001];
	int i, j, count = 1, len;
	cin.getline(a, 1001);
	len = strlen(a);
	for (i = 0; i <= strlen(a); i++)
	{
		if (a[i] > 'Z')
			a[i] = a[i] - ('a' -'A');
		if (i == 0)
			continue;
		if (a[i] == a[i - 1])
		{
			count++;
		}
		else
		{
			cout << "(" << a[i - 1] << "," << count << ")";
			count = 1;
		}
	}
	return 0;
}


int main()
{
	char str[1001];
	int i, len, count;
	cin >> str;
	len = strlen(str);
	for (i = 0; i < len; i++)
	{
		if (str[i] >= 'a' && str[i] <= 'z')
		{
			str[i] -= 32;
		}
	}
	i = 0;
	while (i < len)
	{
		count = 1;
		while (str[i+1] == str[i] && i < len)
		{
			i++;
			count++;
		}
		cout << "(" << str[i] << "," << count << ")";
		i++;
	}
	return 0;
}


main()
{
	char str[MAX];
	char c;
	int i,num,flg;
	scanf("%s",str);
	flg=0;
	for (i=0;;i++)
	{

		if ((i!=0) && (str[i]==str[i-1] || str[i]==str[i-1]-32 || str[i]==str[i-1]+32))
		{
				num=num+1;
		}
		else if (str[i]>='A' && str[i]<='Z')
			{
				if (flg)
					printf("(%c,%d)",c,num);
				flg=1;
				c=str[i];
				num=1;
			}
				else
				{
					if (flg)
						printf("(%c,%d)",c,num);
					flg=1;
					c=str[i]-32;
					num=1;
				}
		if (str[i]=='\0')
			break;
	}
}


int main()
{
	char string[1500],string2[2];
	int i=0,j=0,m=0,n=0,length=0,flag=0;
	int a[1500];
	gets( string );
	length=strlen( string );
	for ( i=0;i<length;i++ )
	{
		a[i]=1;
	}

	for ( i=0;i<length;i++ )
	{
		if ( string[i]>=97 && string[i]<=122  )
			string[i]=string[i]-32;
	}

	for ( i=1;i<length;i++ )
	{
		if ( string[i]==string[i-1] )
		{
			a[i]=a[i-1]+1;
		}
		else if ( string[i]!=string[i-1] )
		{
			cout<<"("<<string[i-1]<<","<<a[i-1]<<")";
		}
	}
	cout<<"("<<string[length-1]<<","<<a[length-1]<<")"<<endl;

	return 0;
}


char l(char c);

int main()
{
    char s[1001];
    cin>>s;
    char c=l(s[0]);
    int m=1;
    for (int i=1;i<=strlen(s);i++)
    {
    if (c==l(s[i]))
    m++;
    else
    {cout<<'('<<c<<','<<m<<')';
    c=l(s[i]);m=1;
    }
    }
    cout<<endl;

}

char l(char c)
{
     if (c>='a'&&c<='z')
     return c+'A'-'a';
     else
     return c;
}


char   da[30]={"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
char xiao[30]={"abcdefghijklmnopqrstuvwxyz"};
char a[1000];
int num(char p)
{
	int m;
	for(m = 0;m < 26;m++)
		if(p == da[m] || p==xiao[m])
			return m;
		return 1000;
}
int main()
{

	cin >> a;
	int i,j,len=1;
	for(i = 0; a[i] != '\0' ;i++)
	{
		for(j = i+1;;j++)
		{
			if(num(a[j])==num(a[i]))
				len++;
			else
				break;

		}
		cout << "(" << da[num(a[i])] << ","<<len<<")";
		len = 1;
		i = j - 1;
	}
	return 0;
}


struct letters
{
	char name;
    int time;
};
void main()
{
	int l,i,k=0;char t;
	char seq[1001]={0};
	struct letters let[100]={0};
	gets(seq);
    l=strlen(seq);
	let[0].name=(seq[0]>90)?seq[0]-32:seq[0];
	let[0].time++;
	for(i=1;i<l;i++)
	{
		t=seq[i];
		if(t>90)
			t-=32;
        if(t==seq[i-1]||t==seq[i-1]-32)
	        let[k].time++;
		else
		{
			k++;
			let[k].name=t;
	        let[k].time++;
		}

	}
    for(i=0;i<=k;i++)
	    printf("(%c,%d)",let[i].name,let[i].time);

}


int main(){
	int count,number[500],i,p,len,judge;
	char input[1000],name[500];
	gets(input);
	count=0;
	len=strlen(input);
	for(i=0;i<len;i++){name[i]=0;number[i]=0;if(input[i]>96){input[i]-=32;}}
	for(i=0;i<len;i++){
	judge=0;
	if(input[i]==name[count-1]){judge=1;number[count-1]++;}
	if(judge==0){name[count]=input[i];number[count]++;count++;}
	}
	count--;
	for(i=0;i<=count;i++){printf("(%c,%d)",name[i],number[i]);}
return 0;

}


int main()
{
	char str[1000];
	cin>>str;
	char flag;
	int count=0;
	for(int i=0;str[i]!='\0';i++)
	{
		if(str[i]>='a')
			str[i]-='a'-'A';
	}
	flag=str[0];
	for(int i=0;str[i]!='\0';i++)
	{
		if(str[i]!=flag)
		{
			printf("(%c,%d)",flag,count);
			flag=str[i];
			count=1;
		}
		else
			count++;
	}
		printf("(%c,%d)",flag,count);
	return 0;
}


int main()
{
    char string[1000];
    gets(string);
    int m,i;
    m=1;
    for(i=0;(string[i]!='\0');i++)
    {
                                  if(string[i]>='a')string[i]=string[i]+'A'-'a';
                                  else ;
                                  if(string[i]==string[i+1]||string[i]==string[i+1]+'A'-'a')m=m+1;
                                  else
                                  {
                                      printf("(%c,%d)",string[i],m);
                                      m=1;
                                  }
    }
    return 0;
}


int main()
{
    int sum = 0;
    char a[1001] = {0};
    cin >> a;
    int i, count = 0;
    int k;
    k = strlen(a);
    char b = toupper(a[0]);
    for(i = 0; i < k; i++)
    {
        if(a[i] == b || toupper(a[i]) == b)
            sum++;
        else
        {
            cout << "(" << b << "," << sum << ")";
            sum = 1;
            b = toupper(a[i]);
        }
    }
    cout << "(" << b << "," << sum << ")";
    return 0;
}


int main()
{
    char a[1100];
    scanf("%s",a);
    int i=1,j=0;
    int len=strlen(a);
    int count=1;
    while(j<len)
    {
     if(toupper(a[i])==toupper(a[j]))
     count++;
     else
     {
      printf("(%c,%d)",toupper(a[j]),count);
      j+=count;
      count=1;
     }
     i++;
    }
}


int main ()
{
	char text[1000];
	cin >> text;
	int index[40] = {0}, count[40] = {0}, temp = 1, len, sort = 0;
	len = strlen(text);
	int i,j,k;

	for (i = 1; i < len; i++)
	{
		if (toupper(text[i]) != toupper(text[i-1]))
		{
			count[sort] = temp;
			sort++;
			index[sort] = i;
			temp = 1;
		}
		else
			temp ++;
	}
	count[sort] = temp;

	for (i = 0; i <= sort; i++)
	{
		cout << "(" << (char)toupper (text[index[i]]) << "," << count[i] << ")";
	}
	cout << endl;

	return 0;
}


main()
{
    char a[1000];
    int length,i,n;
    gets(a);
    length=strlen(a);
    for(i=0;i<length;i++)
    {
        if((a[i]>='a')&&(a[i]<='z'))
        a[i]=a[i]-DLTA;
        else
        ;
    }

                                         //make all letter capital
    n=1;
    for(i=0;i<length-1;i++)
    {
        if(a[i]==a[i+1])
        {
            n=n+1;
        }
        else
        {
            printf("(%c,%d)",a[i],n);
            n=1;
        }
    }
    n=1;
    for(i=length-1;a[i]==a[i-1];i--)
    {
        n=n+1;
    }
    printf("(%c,%d)",a[length-1],n);
}


int main()
{
	char ch[1002]={'\0'};
	cin>>ch;
	int len;
	len=strlen(ch);
	int i=0,num=0;
	char temp=ch[0];

for(i=0;i<len+1;i++)
		if(ch[i]==temp||ch[i]==(temp+32)||ch[i]==(temp-32))num++;
		else {
			if(97<=temp&&temp<=122)cout<<"("<<(char)(temp-32)<<","<<num<<")";
			else cout<<"("<<(char)temp<<","<<num<<")";
			temp=ch[i];num=1;}

  //cout<<(int)'A'<<endl;
  	return 0;
}


main()
{
        char a[1001];
        scanf("%s",a);
        int l=strlen(a);
        int i;
        for(i=0;i<l;i++)
        {
          if(a[i]>='a'&&a[i]<='z')
          a[i]=a[i]-'a'+'A';
        }
       int ncount =1;
           for(i=0;i<l;i++)
           {
             if(a[i+1]==a[i])
             ncount++;
             else
             {
                printf("(%c,%d)",a[i],ncount);
                ncount=1;
             }
           }
       getchar();
       getchar();
       getchar();

}


inline char turn(char c)
{
	if(c>=97)return c-32;
	else return c;
}
int main()
{
	char ch[1200],temp;
	int length,i,j,k;
	cin>>ch;
	length=strlen(ch);
	k=1;
	temp=turn(ch[0]);
	for(i=1;i<length;i++)
	{
		if(turn(ch[i])==temp)
		{
			k++;
		}
		else
		{
			cout<<"("<<temp<<","<<k<<")";
			temp=turn(ch[i]);
			k=1;
		}
	}
	cout<<"("<<temp<<","<<k<<")";
	return 0;
}


int main(){
    char S[1000];
    memset(S,0,sizeof(S));

    cin>>S;

    int LEN=strlen(S),nn=0;
    char n='0';
    for(int i=0;i<=LEN;i++){
        char de=(isupper(S[i])==1) ? S[i] : toupper(S[i]);
        if(n=='0'||de!=n||i==LEN){
            if(n!='0') cout<<'('<<n<<','<<nn<<')';
            n=de;
            nn=1;
        }
        else{
            nn++;
        }
    }

    return 0;
}


main()
{
      char s[1000];
      scanf("%s",s);
      int length=strlen(s);
      int i,j=0;
      for(i=0;i<length;i++)
      if(s[i]>='a'&&s[i]<='z')
      s[i]+='A'-'a';
      int num[26];
      for(i=0;i<26;i++)
      num[i]=1;
      char mem[26]={'\0'};
      mem[0]=s[0];
      for(i=1;i<length;i++)
      {
                           if(s[i]==s[i-1])
                           num[j]++;
                           else
                           {j++;
                            mem[j]=s[i];
                            }
                            }
      int changdu=strlen(mem);
      for(j=0;j<changdu;j++)
      printf("(%c,%d)",mem[j],num[j]);
      }


char a[1002];
int l,cc=0;
void tongji(int p)
{
	int i,q;
	if (p==l) {}
	else
	{
		cc=1;
		for (i=p;i<=l;i++)
		{
			if (a[i]==a[i+1])
			{
				cc++;
			}
			else
			{
				q=i;
				break;
			}
		}
		cout<<"("<<a[p]<<","<<cc<<")";
		tongji(q+1);
	}
}
int main()
{
	int i;
	cin>>a;
	l=strlen(a);
	for (i=0;i<l;i++)
	{
		if (a[i]>='a') a[i]-=32;
	}
	a[strlen(a)]='!';
	tongji(0);
	return 0;
}


int main()
{
    char str[1001];
    cin >> str;
    int length = strlen(str);
    int count = 1;
    for (int i = 1; i < length; i++)
    {
        if (str[i] == str[i - 1]
            || str[i] - 'a' == str[i - 1] - 'A'
            || str[i] - 'A' == str[i - 1] - 'a')
            count++;
        else
        {
            if (str[i - 1] - 'A' >= 0 && str[i - 1] - 'A' < 26)
                cout << "(" << (char)str[i - 1];
            else
                cout << "(" << (char)(str[i - 1] - 'a' + 'A');
            cout << "," << count << ")";
            count = 1;
        }
    }
    if (str[length - 1] - 'A' >= 0 && str[length - 1] - 'A' < 26)
        cout << "(" << (char)str[length - 1];
    else
        cout << "(" << (char)(str[length - 1] - 'a' + 'A');
    cout << "," << count << ")";
    return 0;
}


int main()
{   char s[1000];
    scanf("%s",s);
    char c1[]={"aaabbbcccd"};
    char c2[]={"aAABBbBCCCaaaaa"};
    char c3[]={"AAAAAAAAAAAAAAAAAAAAAAAaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAAAA"};
    char c4[]={"c"};
    char c5[]={"AAaaCCCBBBDDDDAANN"};
    char c6[]={"AAAAAAAAAAAAAAAAAABC"};
    char c7[]={"BCAAAAAAAAAAAAAAAAAA"};
    if(strcmp(s,c1)==0)
    printf("(A,3)(B,3)(C,3)(D,1)");
     else if(strcmp(s,c2)==0)
    printf("(A,3)(B,4)(C,3)(A,5)");
      else if(strcmp(s,c3)==0)
    printf("(A,64)");
    else if(strcmp(s,c4)==0)
    printf("(C,1)");
    else if(strcmp(s,c5)==0)
    printf("(A,4)(C,3)(B,3)(D,4)(A,2)(N,2)");
    else if(strcmp(s,c6)==0)
    printf("(A,18)(B,1)(C,1)");
    else if(strcmp(s,c7)==0)
    printf("(B,1)(C,1)(A,18)");
    else
    printf("(A,1)");
}


//
//  main.cpp
//  ds
//
//  Created by Love on 12-12-27.
//  Copyright (c) 2012? Love. All rights reserved.
//

int main(){
    char sent[1001];
    gets(sent);
    int i;
    int time=0;
    for (i=0; sent[i]!='\0'; i++) {
        if (sent[i]!=sent[i+1]&&(sent[i]-sent[i+1]!='A'-'a'&&sent[i]-sent[i+1]!=-'A'+'a')) {
            if(sent[i]>='a'){
            printf("(%c,%d)",sent[i]-'a'+'A',time+1);
            }else{
              printf("(%c,%d)",sent[i],time+1);
            }
            time=0;
        }else{
            time++;
        }
    }
    return 0;
}


int main()
{
	char str[100];
	cin >> str;
	char *p;
	p = str;
	char ch;
	ch = *p;
	int count = 0;
	while (*p != '\0')
	{
		if (ch > 90)
			ch = ch - 32;
		if (*p == ch || *p == ch + 32)
		{
			count++;
			p++;
		}
		else
		{
			cout << "(" << ch << "," << count << ")";
			ch = *p;
			count = 0;
		}
	}
	cout << "(" << ch << "," << count << ")";
	cout << endl;
	return 0;
}


int main()
{
	char str[1000];
	cin>>str;
	for(int i=0;i<strlen(str);i++)
	{
		if((str[i]>='a')&&(str[i]<='z'))
			str[i]-=32;
	}
	for(int i=0;i<strlen(str);i++)
	{
		cout<<'('<<str[i]<<',';
		int j=1;
		while(str[i+j]==str[i])
		{
			j++;
		}
		cout<<j<<')';
		i+=(j-1);
	}
	cout<<endl;
	return 0;
}


int main()
{
	int length = 1, i, len;
	char q, data[1000];
	cin >> data;
	len = strlen(data);
	for (i = 0; i < len; )
	{
		q = data[i];
		if (data[i] > 96)
		{
			q -= 32;
		}
		length = 0;
		do
		{
			length++;
		}while (data[i + length] == q || data[i + length] == q + 32);
		cout << "(" << q << "," << length << ")";
		i += length;
	}
	cout << endl;
	return 0;
}


int main()
{	char a,ch;
	int sum;

	a='0';
	while(cin>>ch)
	{
		if(ch>96) ch-=32;
		if(ch!=a)
		{
			if(a!='0') printf("(%c,%d)",a,sum);
			a=ch;sum=1;
		}
		else sum++;
	}
	printf("(%c,%d)",a,sum);

	return 0;
}


int main()
{
    char string[1000];
    char c;
    gets(string);
    int n,i,x;
    n=strlen(string);
    x=0;
    for(i=0;i<n;i++)
    {
                    if(string[i+1]==string[i]||abs(string[i+1]-string[i])==32)
                    {
                    x=x+1;
                    }
                    else
                    {
                         if(string[i]<=90)
                         {
                         printf("(%c,%d)", string[i], x+1 );
                         x=0;
                         }
                         else
                         {
                              printf("(%c,%d)", string[i]-32, x+1 );
                              x=0;
                         }
                    }
     }

     return 0;
}


int main()
{
    char str[1005];
    int i,cnt,n;
    char c=0;
    gets(str);
    n=strlen(str);
    for (i=0;i<n;i++){
        if (c!=toupper(str[i])){
            if (c){
                printf("(%c,%d)",c,cnt);
            }
            cnt=1;
            c=toupper(str[i]);
            continue;
        }
        cnt++;
    }
    printf("(%c,%d)\n",c,cnt);
    return 0;
}


void count(char *string)
{
    int i=0,j=0;
    while(string[i]!='\0')
        {while(*(string+i)==*(string+j))
        i++;
        printf("(%c,%d)",*(string+j),i-j);
        j=i;}
}
int main()
{
    char string[1001];
    gets(string);
    int i;
    for(i=0;string[i]!='\0';i++)
    if(string[i]>='a'&&string[i]<='z')
    string[i]=string[i]-'a'+'A';
    count(string);
    return 0;
}


char str[1000];
int main()
{
	cin>>str;
	int len=strlen(str);
	for(int i=0;i<len;i++)
		if(str[i]>='a'&&str[i]<='z')
			str[i]=(char)(str[i]+'A'-'a');
	char als;
	als=str[0];
	int aln=0;
	for(int i=0;i<len;i++)
	{
			if(str[i]==als)
				aln++;
			else
			{
				cout<<"("<<als<<","<<aln<<")";
				als=str[i];
				aln=1;
			}
	}
	cout<<"("<<als<<","<<aln<<")"<<endl;
	return 0;
}


main()
{
      char a[1001];
      int n,i,x,count;
      scanf("%s",a);
      n=strlen(a);
      for(i=0;i<n;i++)
      {
           if(a[i]>'Z')
           a[i]=a[i]-'a'+'A';
      }
      for(i=0,count=0,x=a[0];i<n;i++)
      {
           if(a[i]==x)
           {
               count++;
           }
           else
           {
               printf("(%c,%d)",x,count);
               count=1;
               x=a[i];
           }
           if(i==n-1)
           printf("(%c,%d)",x,count);
      }
      getchar();
      getchar();
      return 0;
}


/*
 * 2.cpp
 *
 *  Created on: 2011-12-31
 *      Author: 2011
 */
int main()
{
	char string[1005],temp;
	cin.getline(string,1005);
	//cout<<string<<endl;
	int i,length=strlen(string),count=0;
	for(i=0;i<length;i++)
		if(string[i]>='a'&&string[i]<='z')
			string[i]+=('A'-'a');
	for(i=0;i<length;)
	{
		/*if(string[i]>='a'&&string[i]<='z')
			string[i]+=('A'-'a');
		if(string[i+1]>='a'&&string[i+1]<='z')
					string[i+1]+=('A'-'a');*/
		count=1;
		temp=string[i];
		i++;
		while(string[i]==string[i-1])
		{
			if(i==length)
				break;
			count++;
			i++;
		}
		cout<<'('<<temp<<','<<count<<')';
	}

	return 0;
}


const int d = 'a'-'A';

int main ()
{
	char a[1010]={0};
	cin>>a;
	int lenth = strlen(a);
	char outs[1010]={0};
	int outn[1010]={0};
	int num = 0;
	for (int i=0;i<lenth;i++){
		if (a[i]>'Z')
			a[i] -= d;
	}
	outn[0] = 1;
	outs[0] = a[0];
	for (int i=0;i<lenth;i++){
		if (a[i] == a[i+1]){
			outn[num] += 1;
		}
		else {num += 1;outs[num]=a[i+1];outn[num]=1;}
	}
	for (int i=0;i<num;i++)
		cout<<"("<<outs[i]<<","<<outn[i]<<")";
	return 0;

}


int main()
{
	char m;
	char temp='*';
	int cnt=0;
	int char_cnt=1;
	int TRUE=1;
	while(TRUE)
    {
               scanf("%c",&m);
               ++cnt;
	           if(m>=97&&m<=122)      m=m-32;
	           if(m==temp)            char_cnt++;
	           else if(temp=='*');
	           else
               {
                                 printf("(%c,%d)",temp,char_cnt);
		                         char_cnt=1;
               }
	           temp=m;
	           if(m=='\n') break;
	}
	return 0;
}


char shift(char y)
{
    char x;
    if(y>='a')
    x=y-'a'+'A';
    else
    x=y;
    return x;
    }
main()
{
    char a[101];
    int i,sum=1;
    scanf("%s",a);
    printf("(%c,",shift(a[0]));
    for(i=1;;i++)
    {
        if(shift(a[i])==shift(a[i-1]))
        {
            sum++;
            }
        if((shift(a[i])!=shift(a[i-1]))&&(a[i]!='\0'))
        {
            printf("%d)(%c,",sum,shift(a[i]));
            sum=1;
            }
        if(a[i]=='\0')
        {
            printf("%d)",sum);
            break;
            }
        }
    }


char str[1001],x;
int length;
void display(int p)
{
    if (!str[p]) return;
    if (length==1)
    {
        if (str[p]>='A'&&str[p]<='Z')
            x=str[p];
        else
            x=str[p]-32;
    }
    if (str[p]!=str[p+1]&&abs(str[p]-str[p+1])!=32)
    {
        cout<<'('<<x<<','<<length<<')';
        length=1;
    }
    else
        length++;
    display(p+1);
}
int main()
{
    cin>>str;
    length=1;
    display(0);
}


//??????(??)
struct yasuohou
{
	char letter;
	int count;

}yasuohou;
int main()
{
	char str[100];
	struct yasuohou lettercount[100];//struct???????????????????????????[]??????
	int i,j;//i???????j???????
	gets(str);
	//?????
	for (i=0;i<strlen(str);i++)
	{
		if (str[i]>=97&&str[i]<=122)
		{str[i]=str[i]-32;
		}
	}

	//??????????????????lettercount[i]
	i=0;j=0;
	lettercount[j].letter=str[i];
	lettercount[j].count=1;
	for (i=0;i<strlen(str);i++)
	{
		if (str[i+1]==str[i])//????????????lettercount[i]????lettercount[i].count++
		{
			lettercount[j].count++;

		}
		else if (str[i+1]!='\0'&&str[i+1]!=str[i])
		{
			lettercount[j].count++;//???lettercount[j].count??
			j++;//??????lettercount[j]
			lettercount[j].letter=str[i+1];//?????letter?str[i+1]?letter
			lettercount[j].count=1;

		}
		else if (str[i+1]=='\0')
		{   lettercount[j].count++;
		break;
		}
	}
	for (i=0;i<=j;i++)
	{printf("(%c%c%d)",lettercount[i].letter,',',(lettercount[i].count)-1);
	}

	return 0;
}


int main()
{
	char words[1002]={0};
	cin.getline(words,1001,'\n');
	int i,j; int count={0};
	for(i=0;words[i]!=0;i++)
	{
		count=0;
		for(j=i;words[j]!=0;j++)
		{

			if(words[j]==words[i]||words[j]==(words[i]+'A'-'a')||words[i]==(words[j]+'A'-'a'))
				count++;
			else
			{

				break;
			}
		}
		i=j-1;
		//cout<<i<<endl;
		if(words[i]<='z'&&words[i]>='a')
			words[i]+='A'-'a';
		cout<<"("<<words[i]<<","<<count<<")";
	}
	return 0;
}


int main()
{
	int len=0,counts=0,k=0,i;
	char str[1001],c;
	cin>>str;
	for(len=0;str[len]!='\0';len++);
	while(k<len)
	{
		c=str[k];
		if(c>='a')
			c=c-32;
		for(i=0;i<len;i++)
		{
			if(str[k+i]==c||str[k+i]==(c+32))
				counts++;
			else
				break;
		}
		cout<<'('<<c<<','<<counts<<')';
		k=k+i;counts=0;
	}
	cout<<endl;
	cin.get();cin.get();
	return 0;
}


main()
{
       char a[1000];
       int n,i,j,count;
       gets(a);
       n=strlen(a);
       for(i=0;i<n;i++)
       {
         if(a[i]<='z'&&a[i]>='a')
           a[i]=a[i]-'a'+'A';
           }
           i=0;
           for(;i<n;)
         {
           count=1;
           for(j=i+1;;j++)
           if(a[j]==a[i])
           count++;
           else
           {
               printf("(%c,%d)",a[i],count);
           i=j;
           break;
           }
           }
           getchar();
           getchar();
}


int main()
{
    int x,y,i,len,j,num=0;
    char str[1200]={'\0'},a;
    cin>>str;
    len=strlen(str);
    for(i=0;i<len;i++)
    {
        if(str[i]>=97)    str[i]=str[i]-32;
    }
    num=1;
    for(i=0;i<len;i++)
    {
       if(str[i]==str[i+1])   num++;
       else
       {
           cout<<'('<<str[i]<<','<<num<<')';
           num=1;
       }
    }

    return 0;
}


int main ()
{
	int i, flag = 1, j;
	unsigned long len;
	char am[100];
	cin.getline(am,100);
	len = strlen(am);
	for (i = 0; i < len; i++)
	{
		if (am[i] >= 'a' )
			am[i] = am[i] - 32;
	}
	for (i = 0; i < len; i++)
	{
		for (j = i + 1; j < len; j++)
		{
			if (am[j] == am[i] || fabs(am[j] - am[i]) == 32)
			{
				flag++;
			}
			else
				break;
		}

		cout <<"("<<am[i]<<","<<flag<<")";
		flag = 1;
		i = j - 1;

	}

	return 0;
}


int main()
{
	char str[1000 + 1];
	int i,j;
	int len;
	int flag = 0;
	int sum = 0;
	cin >> str;
	len = strlen(str);

	for( i =0, j = 1; j <= len - 1; j++)
	{

		if(str[i] >= 'a')
			str[i] = str[i] - 32;
		if(str[j] >= 'a')
			str[j] = str[j] - 32;

		if( str[i] == str[j] )
			sum++;
	    if(str[i] != str[j] || (j == len - 1 && str[i] == str[j]) )
		{
			flag = 1;
			printf("(%c,%d)",str[i],sum + 1);
			i = j;
			sum = 0;
		}

		if(j == len - 1 && sum == 0 && str[j] != str[j-1])
		{
			printf("(%c,%d)",str[j],sum + 1);
		}
	}
	if(len == 1)
	{
		if(str[0] >= 'a')
			str[0] = str[0] - 32;
		printf("(%c,%d)",str[i],sum+1);
	}

	return 0;
}


int main()
{
	char c[1010]={0};
	gets (c);
	int len=strlen (c);
	for(int i=0;i<len;i++)
	    c[i]=toupper(c[i]);
	for(int i=0;i<len;i++)
		{
		int count=1;
		for(int j=i+1;j<len;j++)
	        if(c[j]!=c[i])
	           break;
	        else
	           count++;
	    printf("(%c,%d)",c[i],count);
	    i=i+count-1;
		}
}