void main()
{
	int i,k=0,p=0;
	int max=0,submax=0;
	int a[300]={0};
	char string[1500];
	gets(string);
	for(i=0;i<(int)strlen(string);i++)
	{
		if(string[i]!=',')
			a[k]=a[k]*10+string[i]-'0';
		else k++;
	}
	if(k==0)
	{
		printf("No");
		return;
	}
	for(i=0;i<k;i++)
		if(a[i]!=a[i+1])
		{
			p=1;
			break;
		}
	if(p==0)
	{
		printf("No");
		return;
	}
	for(i=0;i<=k;i++)
	{
		if(a[i]>max)
		{
			submax=max;
			max=a[i];
		}
		else if(a[i]==submax) continue;
		else if(a[i]>submax&&a[i]<max) submax=a[i];
	}
	printf("%d",submax);
}


int main()
{
	int a,b=0,c;
	char d;
	scanf("%d",&a);
	for(;;)
	{
		d=getchar();
		if(d!=',')
			break;
		else
		{
			scanf("%d",&c);
			if(c>a)
			{
				b=a;
				a=c;
			}
			else if(c<a&&c>b)
				b=c;
			else
				continue;
		}
	}
	if(b==0)
		printf("No");
	else
		printf("%d",b);
return 0;
}


void main()
{
	int a[300],i,j,m,t,max,flag=0;
	char c;
	for(i=0;c!='\n';i++)
	{
		scanf("%d",&a[i]);
		c=getchar();
	}
	m=i;

	if(m==1)printf("No\n");
	else
	{

		for(i=0;i<m;i++)
		{	max=i;
		for(j=i+1;j<m;j++)
			if(a[j]>a[max])max=j;
			t=a[i];
			a[i]=a[max];a[max]=t;
	}
	for(i=0;i<m-1;i++)
		if(a[i]!=a[i+1]){flag=1;break;}
	if(flag==0)printf("No\n");
	else printf("%d\n",a[i+1]);
	}
}


main()
{
	int a[300],i=0,j,first,second,t=0,mid;
	scanf("%d",&a[i++]);
	while(scanf(",%d",&a[i++])==1);
	if(i==2)
		printf("No");
	else
	{
		first=a[0];
		for(j=1;j<i-1;++j)
		{
			if(a[j]!=first)
			{
				second=a[j];
				t=1;
				break;
			}
		}
		if(t==0)
			printf("No");
		else
		{
			if(first<second)
			{
				mid=first;
				first=second;
				second=mid;
			}
			for(j=1;j<i-1;++j)
				if(a[j]>second&&a[j]<first)
					second=a[j];
				else if(a[j]>first)
				{
					second=first;
					first=a[j];
				}
			printf("%d",second);
		}
	}
}


int main()
{
	int i,n,max,tmp;
	max=0;
	tmp=0;
	i=0;
	do
	{
		i=i+1;
		scanf("%d",&n);
		if(n>max)
		{
		    tmp=max;
		    max=n;
		}
		else if(n>tmp&&n!=max)
			tmp=n;
		else if(n==max)
		    max=max;
		    tmp=tmp;
	}while(getchar()!='\n');
	if(i==1||tmp==0)
	{
		printf("No\n");
	}
	else
	{
		printf("%d\n",tmp);
	}
	return 0;
}


int main()
{
	int n=0,x[301];
	char c;

	while(1)
	{
		scanf("%d%c",&x[n],&c);
		n++;
		if(c==10) break;
	}

	if(n==1) printf("No\n");
	else
	{
		long a=0,b=0,i;
		for(i=0;i<=n-1;i++)
		{
			if(a<x[i])
			{
				b=a;
				a=x[i];
			}
			else if(a>x[i]&&x[i]>b)
				b=x[i];
		}

		if(a>b&&b>0) printf("%d\n",b);
		else printf("No\n");
	}

	return 0;
}


void main()
{
	int a,i=1,max,submax;
	char p;
	while(scanf("%d%c",&a,&p)&&p!='\n')
	{
		if(i==1)
		{
			max=a;
			submax=0;
		}
		else
		{
			if(a>max)
			{
				submax=max;
				max=a;
			}
			else
			{
				if(a>submax&&a!=max)
				{
					submax=a;
				}
			}
		}
		i++;
	}
	if(i==1)//?????
	{
		printf("No");
	}
	else
	{
		if(a>max)
		{
			submax=max;
			max=a;
		}
		else
		{
			if(a>submax&&a!=max)
			{
				submax=a;
			}
		}
		if(submax==0)
		{
			printf("No");
		}
		else
		{
			printf("%d",submax);
		}
	}
}


int main()
{
	int a,b,n;
	char c;
	a=0,b=0;

	do{

			scanf("%d",&n);
			scanf("%c",&c);
			if(n>b)
			{
				a=b;
				b=n;}
			else if(n>a&&n<b)
			{
				a=n;}
	}while(c==',');
	if(a==0)
		printf("No\n");
	else
		printf("%d",a);
	return 0;
}


int main()
{
    unsigned int s[301],max=0,second=0;
    char c='0';
    int i=0,j;
    while(c!='\n')
    {
        scanf("%d%c",&s[i],&c);
        i++;
    }
    for(j=0;j<i;j++)
    {
        if(s[j]>max)
        {second=max;
        max=s[j];}
        else if(s[j]<max&&s[j]>second)
        second=s[j];
        else
        continue;
    }
    if(second)
    printf("%d",second);
    else
    printf("No");
    return 0;
}


int main()
{
int m1=0;
int m2=0;
int i=1;
int mtemp;
char ch;

do{

	scanf("%d",&mtemp);
	if(mtemp>m1)
	{   m2=m1;
	m1=mtemp;
	}
	else if(mtemp>m2&&mtemp<m1)
	{
		m2=mtemp;
	}

	ch=getchar();
	i=i++;

}while(ch==',');

if(m1==m2||m2==0||i==2)
{printf("No");
}
else
printf("%d",m2);

return 0;

}


int main()
{
	int a=0,b,c,d=0;
	char e;
	scanf("%d%c",&c,&e);
	     while(e==',')
		{
		scanf("%d%c",&b,&e);
		if (b>c)
		{
			d=c;
			c=b;}
		else
		{
			if(b>d&&b!=c)
				d=b;}
		a=a+1;
		 }
		if (d!=0)
	{
		printf("%d",d);}
	else
	{
		printf("No");}
	return 0;
}


int main()
{int N[300];scanf("%d",N);
int k=0;
for(;scanf(",%d",N+k+1);)k++;
if(k==0)printf("No");
else
{
int Fir=0;
for(int i=0;i<=k;i++)
{
if(Fir<N[i]) Fir=N[i];
}
int Sec=0;
for(int i=0;i<=k;i++)
{
if(Sec<=N[i]&&N[i]!=Fir) Sec=N[i];
}
if(Sec==0) printf("No");
else printf("%d",Sec);
}
}


int main(){
    int a=-32767;
    int b=a;
    int t=0;
    while(1){

             char c;
             c=getchar();
             if(c<=13){

             int d=t;

             if(d>a){b=a;a=d;}
             if((d>b)&&(d<a))b=d;
             t=0;
                       break;
             }else if(c==','){

             int d=t;

             if(d>a){b=a;a=d;}
             if((d>b)&&(d<a))b=d;

             t=0;
             }else t=t*10+c-48;
    }
    if(b==-32767)cout<<"No"<<endl;
    else cout<<b<<endl;

    return 0;
}


int main()
{
	int a,b,i;
	char c=',';
	a=-1;
	b=1;
	while(c==',')
	{
		scanf("%d%c",&i,&c);
		if(i>a)
		{
			b=a;
			a=i;
		}
		else if((i<a)&&(i>b))
			b=i;
	}
	if(b==-1)
		printf("No\n");
	else
		printf("%d\n",b);
	return 0;
}


char t;
int begin = 0,a[1000],p = 1,i,done = 0;
char s[10000];

int IsDigit(char t)
{
    if(t <= '9' && t >= '0')
        return 1;
    return 0;
}

void sort(int l,int r)
{
    int i = l,j = r,k = a[(i + j) >> 1],t;
    do
    {
        while(a[i] > k)++i;
        while(a[j] < k)--j;
        if(i <= j)
        {
            t = a[i];
            a[i] = a[j];
            a[j] = t;
            ++i;
            --j;
        }
    }while(i <= j);
    if(i < r)sort(i,r);
    if(l < j)sort(l,j);
}

int main()
{
    memset(a,0,sizeof(a));
    scanf("%s",s);
    for(i = 0;i < strlen(s);++i)
    {
        t = s[i];
        if(!IsDigit(t))
        {
            if(begin == 1)
            {
                ++p;
                begin = 0;
            }
        }
        else
        {
            begin = 1;
            a[p] = a[p] * 10 + t - '0';
        }
    }
    sort(1,p);
    for(i = 2;i <= p;++i)
        if(a[i] != a[i - 1])
        {
            printf("%d\n",a[i]);
            done = 1;
            break;
        }
    if(done == 0)
        printf("No\n");
    return 0;
}


int main()
{
    unsigned a[1000];
    char b[1000];
    scanf("%u",&a[0]);
    int i;
    i=0;
    while(1)
    {
            b[i]=getchar();
            if(b[i]!=',') break;
            i++;
            scanf("%u",&a[i]);
    }
    if(i==0) printf("No");
    else
  {

        int num=i+1;
        unsigned max1,max2;
        max1=a[0];
        for(i=1;i<num;i++)
        {
            if(max1<a[i]) max1=a[i];
        }

        max2=a[0];
        if(max2==max1) max2=0;
         for(i=1;i<num;i++)
        {
            if(max2<a[i]&&a[i]<max1) max2=a[i];
        }
        if(max2==0) printf("No\n");
        else printf("%u\n",max2);
   }

    getchar();
    getchar();
    getchar();
}


int main()
{
	int a,i,m=0,n=0;
	char c;
	for(i=1;i>0;)
	{
		scanf("%d",&a);
		scanf("%c",&c);
		if(a>m)
		{
			n=m;
			m=a;
		}
		else if(a>n&&a<m) n=a;
		if (c=='\n') break;
	}
	if(n!=0) printf("%d",n);
	else printf("No");

	return 0;
}


void main(){
	long secmax=-32767,max=-32767;
	int n,i=-1,chg=0,maxchg=0;
	char ch;
	do{
		i++;
		scanf("%d",&n);
		if(n>max){
			secmax=max;
			if(maxchg) chg=1;
			max=n;
			maxchg=1;
		}else if(n>secmax&&n!=max){
			secmax=n;
			chg=1;
		}
		ch=getchar();
	}while(ch==',');
	if(i<2||!chg)
		printf("No");
	else
		printf("%d",secmax);
}


void main()
{
	int i=0,n,m=0,t=0;

	do
	{
		i=i+1;
		scanf("%d",&n);
		if(n>m)
		{
		    t=m;
		    m=n;
		}
		else if(n>t&&n!=m)
			t=n;
		else if(n==m)
		    m=m;
		    t=t;
	}while(getchar()!='\n');
	if(i==1||t==0)
	{
		printf("No\n");
	}
	else
	{
		printf("%d\n",t);
	}

}


int main()

{
	int num[300];
	int sr=0;
	int i,y,r;
	char c;
while(1)
{
	scanf("%d",&num[sr++]);
	scanf("%c",&c);
	if(c=='\n')
		break;
}
if(sr==1)
{
	printf("No");
	return 0;
}
y=num[0];
r=num[0];
for(i=0;i<sr;i++)
{
	if(num[i]>y)
	{
		r=y;
		y=num[i];
	}
	else if(num[i]<y) r=num[i];

}
for(i=0;i<sr;i++)
{
	if(num[i]<y&&num[i]>r) r=num[i];
}
 if(y==r)
{
	printf("No");
 }
 else
    printf("%d",r);

return 0;

}


int power(int a,int b)
{
	int result=1;
	int i;
	for(i=1;i<=b;i++)
	{
		result=result*a;
	}
	return result;
}
int main()
{
	int count,i,j,k,max,submax,sum;
	char a[1000];
	char b[]="0000";
	char c[]="0123456789";
	char d[4]=",0";
    max=0;
	submax=0;
	sum=0;
	cin >> a;
	count=0;
	j=0;

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

		if(a[i]!=d[0]&&a[i]!=d[3])
		{
			b[count]=a[i];
			count=count+1;

		}
		if(a[i]==d[0]||a[i]==d[3])
		{

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

				if(b[j]==c[0])
				{
					sum=sum+0*power(10,(count-j-1));

				}
				if(b[j]==c[1])
				{
					sum=sum+1*power(10,(count-j-1));

				}
				if(b[j]==c[2])
				{
					sum=sum+2*power(10,count-j-1);

				}
				if(b[j]==c[3])
				{
					sum=sum+3*power(10,count-j-1);

				}
				if(b[j]==c[4])
				{
					sum=sum+4*power(10,count-j-1);

				}
				if(b[j]==c[5])
				{
					sum=sum+5*power(10,count-j-1);

				}
				if(b[j]==c[6])
				{
					sum=sum+6*power(10,count-j-1);

				}
				if(b[j]==c[7])
				{
					sum=sum+7*power(10,count-j-1);

				}
				if(b[j]==c[8])
				{
					sum=sum+8*power(10,count-j-1);

				}
				if(b[j]==c[9])
				{
					sum=sum+9*power(10,count-j-1);

				}
			}

		    if(sum>max)
			{
				submax=max;
				max=sum;
			}
		    if(sum<max&&sum>=submax)
			{
			    submax=sum;
			}

		for(k=0;k<4;k++)
                   {
                             b[k]=c[0];
                   }

                   count=0;
		sum=0;

		}
                   		if(a[i]==d[3])
		{
			break;
		}

	}
    if(submax!=0)
	{
		cout<<submax<<"\n";
	}
	else
	{
		cout<<"No\n";
	}
    return 0;
}


void paixu(int num[],int n)
{
	int i,j,t;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(num[j]>num[i])
			{	t=num[i];	num[i]=num[j];	num[j]=t;	}
		}
	}
}
int main()
{
	int t=0,a,num[310]={0};
	char c;
	while(1)
	{
		scanf("%d%c",&a,&c);
		if(c=='\n')
		{	num[t++]=a;	break;	}
		else
			num[t++]=a;
	}
	paixu(num,t);
	int gole=num[0],i;
	a=0;
	for(i=1;i<t;i++)
	{
		if(num[i]<gole)
		{	a=1;	gole=num[i];	break;	}
	}
	if(t==1||a==0)
		printf("No\n");
	else
		printf("%d\n",gole);
	return 0;
}


int main()
{
    int a=0,b,c=0;
    char d;
    do
    {
                  scanf("%d%c",&b,&d);
                  if(a>b)
                  {
                         if(b>c)
                         c=b;
                  }
                  if(a<b)
                  {
                      if(a>c)
                      c=a;
                      a=b;
                  }

    }while(d==',');
    if(a==c || c==0)
    printf("No");
    else
    printf("%d",c);
    return 0;
}


void main()
{
	int a[300];
	int i=1,j,max,max2,n=0;
	scanf("%d",&a[0]);
	while((scanf(",%d",&a[i])>0))
		i++;
	if(i==1) printf("No\n");
	else
	{
		max=a[0];
		max2=0;
		for(j=1;j<i;j++)
		{
			if(max<a[j])
				max=a[j];
		}
		for(j=0;j<i;j++)
		{
			if(a[j]<max&&a[j]>max2)
			max2=a[j];
		}
		if(max2==0) printf("No\n");
		else
		printf("%d",max2);
	}
}


int main()
{
	int a[300];
	char c;
	int i,n,max,ma;
	scanf("%d",&a[0]);
	scanf("%c",&c);
	i=1;
	while(c==',')
	{
		scanf("%d",&a[i]);
		scanf("%c",&c);
		i++;
	}
	n=i;
	i=1;
	max=a[0];
	if(n==1) printf("No");
	else
	{

		while(i<n)
	    {

			if(max<a[i]) max=a[i];
		    i++;
	    }
	    if(max==a[0]) ma=0;
		else ma=a[0];
	    i=0;
	    while(i<n)
	    {

			if((ma<a[i])&&(a[i]!=max)) ma=a[i];
		    i++;
	    }
	    if((max==ma)||(ma==0)) printf("No");
	    else printf("%d",ma);
	}

	return 0;
}


int main ()
{
	int a[300]={-1},n,i,first,second;
	scanf("%d",&a[0]);
	for(i=1;i<300;i++)
		scanf(",%d",&a[i]);
	n=0;
	for(i=0;i<300;i++)
		if(a[i]!=-1) n++;
	first=0;second=0;
	for(i=0;i<n;i++)
	{
		if(a[i]>first)
			first=a[i];
	}
	for(i=0;i<n;i++)
	{
		if(a[i]<first&&a[i]>=second)
			second=a[i];
	}
	if(second==0) printf("No\n");
	else printf("%d\n",second);
}


int series(int a[])
{
	char s[1000];
	gets(s);
	int len=strlen(s),temp=0,num=0,i,p=0;
	for(i=0;i<len;i++)
	{
		if(s[i]==',')
		{
			a[num++]=temp;
			temp=0;
		}
		else
			temp=temp*10+s[i]-'0';
	}
	a[num++]=temp;
	return(num);
}
int find_second(int a[],int num)
{
	int max,sec,i;
	max=0,sec=0;
	for(i=0;i<num;i++)
	{
		if(a[i]>max)
		{
			sec=max;
			max=a[i];
		}
		else if(a[i]>sec&&a[i]<max)
			sec=a[i];
	}
	if(max==sec) return 0;
	else
		return(sec);
}

void main()
{
	int n,a[100],sec;
	n=series(a);
	sec=find_second(a,n);
	if(sec)
	printf("%d\n",sec);
	else
		printf("No\n");
}


void main()
{
	int s[max],n=0,i,j,temp;
	char flag;
	int cida=0;
	for(i=0;;i++)
	{
		scanf("%d%c",&s[i],&flag);
		if(flag==',')
		{
			n++;
			continue;
		}
		if(flag=='\n')
		{
			n++;
			break;
		}
	}

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

	for(i=1;i<n;i++)
	{
		if(s[i]==s[0])
			continue;
		if(s[i]<s[0])
		{
			cida=s[i];
			break;
		}
	}

	if(cida==0||n==0)
		printf("No");
	else
		printf("%d",cida);
}


int fscan(int *n)
{
 char c;
 *n=0;
 do
   {
    c=getchar();
    if(c=='\n')return 0;
    if(c!=',')
      {
       *n=*n*10+c-'0';
      }
   }while(c!=',');
 return 1;
}

int main()
{
    int n;
    int first=-1,second=-1;
    int temp;
    temp=fscan(&n);
    first=n;
    while(temp)
         {
          temp=fscan(&n);
          if(n>first)
            {
             second=first;
             first=n;
            }
          else if(n>second&&n!=first)
                 second=n;
         }
   if(second==-1)printf("No");
   else printf("%d",second);
   return 1;
}


void main()
{
	int max,secmax,a[300],i,j;
	char character[300];
	for(i=0;;i++)
	{
		scanf("%d",&a[i]);
		scanf("%c",&character[i]);
		if(character[i]!=',') break;
	}
	if(i==0) printf("No");
	else
	{
		if(a[0]>=a[1])
		{
			max=a[0];
			secmax=a[1];
		}
		else
		{
			max=a[1];
			secmax=a[0];
		}
		if(i>=2)
		{
			for(j=2;j<=i;j++)
			{
                if(a[j]>max)
				{
					secmax=max;
					max=a[j];
				}
				else
				{
					if(a[j]>secmax&&a[j]<max) secmax=a[j];
					if(a[j]<secmax&&secmax==max) secmax=a[j];
				}
			}
		}
		if(max==secmax) printf("No");
		else printf("%d\n",secmax);
	}
}


int main()
{
	int first,second,in;
	char c;
	second=0;
	scanf("%d",&first);
	scanf("%c",&c);
	while(c==',')
	{
		scanf("%d",&in);
		if(in>first)
		{
			second=first;
			first=in;
		}
		else
		{
			if(in==first)
				second=second;
			else
			{
			if(in>second)
				second=in;
			}
		}
		scanf("%c",&c);
	}
	if(second==0)
		printf("No");
	else
		printf("%d",second);

}


int main()
{
	int largest=-1,second=-1,a[300],i,counter;
	char b[100];
	for(i=0;i<=299;i++)
	{
		scanf("%d%c",&a[i],&b[i]);
		if(b[i]!=',')
		{
			counter=i+1;
			break;
		}
	}
	for(i=0;i<=counter-1;i++)
	{
		if(a[i]>largest)
		{
			second=largest;
			largest=a[i];
		}
		else if(a[i]==largest);
		else if(a[i]>second)
			second=a[i];
	}
	if(second==largest||second==-1)
		printf("No");
	else
		printf("%d",second);
	return 0;
}


int n[300];
int main(void)
{
      int ctr,i=1;
      int max=0,temp;
      scanf("%d",n);
      while((getchar())==',')
      {
      scanf("%d",&n[i]);
      i++;
      }
      for(ctr=0;ctr<i;ctr++)
      {
      if(n[ctr]>max)
      max=n[ctr];
      }
      temp=max;
      max=0;
      for(ctr=0;ctr<i;ctr++)
      {
      if(n[ctr]==temp)
      n[ctr]=0;
      }
      for(ctr=0;ctr<i;ctr++)
      {
      if(n[ctr]>max)
      max=n[ctr];
      }
      if(max==0)
      printf("No");
      else
      printf("%d",max);
      return 0;
}


void main()
{
     char str[300];
     int sum[200]={0},counter=0,i=0,j,t;
	 gets(str);

    while(str[i]!='\0')
	{  if(str[i]!=',')
       sum[counter]=sum[counter]*10+(str[i]-'0');
	else {
		counter++;
	}
	   i++;
	}

    if(counter<=0)
	printf("No");
	else
	{
		for(i=0;i<counter;i++)
		  for(j=i+1;j<=counter;j++)
		    if(sum[i]<sum[j])
			{
				t=sum[i];
				sum[i]=sum[j];
				sum[j]=t;
			}
	     t=0;
		for(i=1;i<=counter;i++)
		{
			if(sum[i]==sum[0]) t++;
		}
	 if(t==counter) printf("No");
	 else printf("%d",sum[t+1]);
    }
}


int main()
{
	int a[301];
	int i,max,sec_max,n=0;
	char c;
	while(true)
	{
		scanf("%d",&a[n++]);
		scanf("%c",&c);
		if(c!=',') break;
	}
	max=a[0];
	sec_max=a[0];
	for(i=0;i<n;i++)
	{
		if(a[i] >= max)	max = a[i];
		else sec_max = a[i];
	}
	for(i=0;i<n;i++)
	{
		if(a[i] < max&&a[i]>=sec_max)	sec_max = a[i];
	}
	if(max==sec_max) printf("No");
	else printf("%d\n", sec_max);
	return 0;

}


int main()
{
	unsigned int a[300],max=0,smax=0;
	char c;
	int i=0,n;
	do
	{
		scanf("%d%c",&a[i],&c);
		i++;
	}while(c==',');
	n=i;
	for(i=0;i<n;i++)
	{
		if(a[i]>max)
		{
			smax=max;
			max=a[i];
		}
		else if(a[i]<max&&a[i]>smax)
			smax=a[i];
	}
	if(smax)
		printf("%d",smax);
	else
		printf("No");
	return 0;
}


void main ()
{
	int max,mu=-1,min=0,i,k;
	char dot;
	scanf ("%d",&max);
	scanf ("%c",&dot);
	if (dot!=',')
	{
		printf ("No");
		min=1;
	}
	for (i=0;dot==',';i++)
	{
		scanf ("%d",&k);
		if (k>max)
		{
			mu=max;
			max=k;
		}
		else if (k<max&&k>mu) mu=k;
		scanf ("%c",&dot);
	}
	if (min==0&&mu==-1) printf ("No");
	else if (min==0&&mu!=-1) printf ("%d",mu);
}


void selectionsort(int a[],int s,int e)
{int i,j,t,min;
for(i=s;i<e;i++)
{min=i;
for(j=i+1;j<e;j++)
if(a[min]>a[j])min=j;
t=a[i];a[i]=a[min];a[min]=t;
}
}
void main()
{
	int a[300],n=1,i;
	scanf("%d",a);
	while(scanf(",%d",&a[n++]));
	n--;i=n-1;
	selectionsort(a,0,n);
	while(a[n-1]==a[i]&&i>0)i--;
	if(i)printf("%d",a[i]);
	else if(a[0]<a[n-1])printf("%d",a[0]);
	else printf("No");
}


int main()
{
	int i,n,a[300],min,max;
	char c;
	for(i=0;;i++)
	{
		scanf("%d%c",&a[i],&c);
		if(c!=',') break;
	}
	n=i;
	max=a[0];
	for(i=1;i<=n;i++)
	{
		if(a[i]>max)
			max=a[i];
	}
	min=-9999;
	for(i=0;i<=n;i++)
	{
		if(a[i]<max&&a[i]>min)
			min=a[i];
	}
	if(min==-9999)
		printf("No");
	else
		printf("%d",min);
	return 0;
}


int maxaaaa(int x,int y)
{
	int z;
	if(x>y) z=x;
	else z=y;
	return (z);
}

int minaaaa(int x,int y)
{
	int z;
	if(x>y) z=y;
    else z=x;
	return (z);
}

		/*?????*/
int main()
{
	int i,j,m,a[1000],max,min;
	int maxaaaa(int x,int y);
	int minaaaa(int x,int y);
	char q;
	for(i=1;;i++)
	{
		scanf("%d",&a[i-1]);
		q=getchar();
		if(q=='\n') break;
	}
	/*????*/
	if(i==1) printf("No");
	else
	{
		for(m=i;m>=1;m--)
		{
		    for(j=1;j<=m-1;j++)
			{
		        min=minaaaa(a[j],a[j-1]);
		        max=maxaaaa(a[j],a[j-1]);
		        a[j]=max;
		        a[j-1]=min;
			}
		}
		for(m=i;m>=2;m--)
		{
			if(a[m-1]>a[m-2])
			{
				printf("%d",a[m-2]);
				break;

			}

		}
		if(m==1) printf("No");
	}
	return 0;
}


int max_value(int a[],int n)
{
	int i,k=0;
	for(i=0;i<n;i++)
	if(a[i]>a[k]) k=i;
	return a[k];
}
void main()
{
	int a[300]={0},i,k=0,max,n=0;
	char c;
	for(i=0;;i++)
	{
		scanf("%d",&a[i]);
		n++;
		c=getchar();
		if(c=='\n') break;
	}
	max=max_value(a,n);
	for(i=0;i<n;i++)
	{
		if(a[i]!=max) break;
	}
	k=i;
	if(k==n) printf("No\n");
	else
	{
		for(i=0;i<n;i++)
		{
			if(a[i]==max) continue;
			if(a[i]>a[k]) k=i;
		}
		printf("%d\n",a[k]);
	}
}


int main()
{
  int max,max2,x;
  max2=-1;
  scanf("%d",&max);
  while (scanf(",")!=EOF)
  {
scanf("%d",&x);
if (x>max)
{
max2=max;
max=x;
continue;
}
if ((x>max2)&&(x<max)) max2=x;
}

if (max2<0) printf("No"); else printf("%d",max2);
}


int main(){
    int firstBig = -1, secBig = -1;

    int temp, ret;
    char ch;

    while(1){
        ret = scanf("%d", &temp);
        if(ret != 1)
            break;

        if( temp < 0){
            printf("Invalid input numbet : negtive\n");
            return -1;
        }

        if(temp > secBig){
            if(temp > firstBig){
                secBig = firstBig;
                firstBig = temp;
            }
            else if(temp != firstBig){
                secBig = temp;
            }
        }
        ret = scanf("%c", &ch);
        if(ret != 1 || ch != ',')
            break;
    }

    if(secBig == -1){
        printf("No\n");
    }
    else{
        printf("%d\n", secBig);
    }
    return 0;
}


int main()
{
 unsigned int a,b=0,c;char d;

 for(scanf("%d",&a);(d=getchar())!='\n';)
 {
  if(a>b)
  {
   c=b;
   b=a;
  }
  else if(a==b)
   ;
  else if(a>=c)
   c=a;
  scanf("%d",&a);
 }
  if(a>b)
  {
   c=b;
   b=a;
  }
  else if(a==b)
   ;
  else if(a>=c)
   c=a;
 if(c==0)
  printf("No");
 else printf("%d",c);
 return 0;
}


void main()
{
	char t;
	int i,k,m,a,b;
	scanf("%d",&a);
	b=0;
	m=0;
	while(scanf(",%d",&i))
	{
		if(i>a)
		{
			b=a;
			a=i;
			m=0;
		}
		if(i==a)
			m=1;
		if(i<a&&i>b)
		  b=i;

	}
	if(b==0)
		printf("No");
	if(b>0)
		printf("%d",b);

}


int main()
{ int num[300];
  int i,j,k,max,next_max;
  char c;
  i=0;
  max=0;
  next_max=0;
  do
  {i+=1;
   scanf("%d%c",&num[i],&c);
   if (num[i]>max)
	 max=num[i];
   }while(c==',');
  if (i==1)
	 printf("%s\n","No");
  else
  {
	 for (j=1;j<=i;j++)
	 { if (num[j]==max)
	   num[j]=0;
	   else{}
	   if (num[j]>next_max)
		   next_max=num[j];
	   else {}
	 }
	 if (0==next_max)
		 printf("%s\n","No");
	 else
		 printf("%d\n",next_max);

  }

}


void main()
{

	char str[10000];
	int i,num[300],j,add=0,count=0,no,tag=0,flag,max;
	for(i=0;i<300;i++)
		num[i]=0;
	scanf("%s",str);
	for(i=0;i<strlen(str);i++)
	{
		if(str[i]==44)
			count++;
	}
	i=0;
	for(j=0;j<count;j++)
	{
		for(;str[i]!=44;i++)
		{
			add=add*10+str[i]-'0';
		}
		i++;
		num[j]=add;
		add=0;
	}
	for(;i<strlen(str);i++)
		num[j]=10*num[j]+str[i]-'0';
	/*for(i=0;i<=j;i++)
		printf("%d\n",num[i]);*/

if(j==1)
		printf("No\n");
	no=j+1;
	for(i=0,flag=1;i<no&&flag;i++)
	{
		if(num[i]!=num[0])
			flag=0;
	}
	if(flag) printf("No\n");
	else
	{
	    max=0;

		for(i=0;i<no;i++)
		{
			if(num[i]>=max)
			{
			max=num[i];
			tag=i;
			}
		}

		for(i=0;i<no;i++)
		{if(num[i]==num[tag])
		num[i]=0;}

		for(i=0,max=num[0];i<no;i++)
		{
			if(num[i]>max)
			{max=num[i];
			tag=i;}
		}
		printf("%d\n",max);
	}
}


int main()
{
	unsigned int n,f=0,x=0,y=0;
	char c;
    scanf("%d,\n",&n);
    x=0;
	y=n;
	while(scanf("%d",&n)!=EOF)
	{

	    scanf("%c",&c);
 	    if(n>=x&&n<y)
		{
			x=n;
		    f=1;

		}
		else if(n>y)
		{

			x=y;
			y=n;
			f=1;

		}
		else if(c!=',')
			break;
		else
			continue;
	}
	if(f==0)
		printf("No");
	else
	    printf("%d",x);

	return 0;
}


int main()
{
   int r=0,p,q,n,k=0;
   char a;
   while(a!=10)
  {
     scanf("%d",&n);
     a=getchar();
     k=k+1;
     r=r+1;
     if(k==1)
      {q=n;p=0;}
     else if(k==2)
      {if(n<=q)
        {p=n;}
        else
          {p=q;q=n;}}
      else
        {
           if(n>=p&&n<=q)
             {if(n==q)
                 {p=p;q=n;}
               else
                  {p=n;q=q;}}
           else if(n<p)
               {if(p==q)
                   {p=n;q=q;}
                 else
                 {p=p;q=q;}}
           else
              {if(p==q)
                 {p=p;q=n;}
                else
                {p=q;q=n;}}
          }
     }
    if(r==1)
      printf("No");
    else if(p==q)
      printf("No");
    else
      printf("%d",p);
   return 0;
}


int main()
{
	int d,ma1,ma2;
	char c;
	scanf("%d",&d);
	ma1=d;
	ma2=d;
	c=getchar();
	while(c!='\n')
	{
		scanf("%d",&d);
		if (d>ma1)
		{
		ma2=ma1;
		ma1=d;
		}
		else if ((d<ma1)&&(d>ma2))
			ma2=d;
		else if((d<ma2)&&(ma1==ma2))
			ma2=d;

		c=getchar();
	}

	if (ma1==ma2)  printf("No");
	else printf("%d",ma2);
	return 0;
}


void main()
{
	int max(int m,int b[]);
	int i=1,n,t,a[300];

	scanf("%d",&a[0]);
	while(scanf(",%d",&a[i]))
		i++;
	n=i;

	t=max(n,a);
	for(i=0;i<n;i++)
		if(a[i]==t)
			a[i]=-1;

		t=max(n,a);
	if(t==-1)
		printf("No\n");
	else
		printf("%d\n",t);
}

int max(int m,int b[])
{
	int i,t;
	t=b[0];
	for(i=1;i<m;i++)
		if(t<b[i])
			t=b[i];

	return(t);
}


void main()
{
	unsigned int num[300]={0},i=0,j,k,n,t;
	do
	{
		scanf("%d",&num[i]);
		i++;
	}
    while (getchar()==',');
	n=i;
	if (n==1)
		printf("No\n");
	else
	{
		for (i=0;i<n;i++)
		{
			k=i;
			for (j=i+1;j<n;j++)
				if (num[k]<num[j])
					k=j;
			if (k!=i)
			{
				t=num[k];
				num[k]=num[i];
				num[i]=t;
			}
		}
		for (i=1;i<n;i++)
			if (num[i]<num[0])
			{
				j=i;
			    break;
			}
		if (i==n)
			printf("No\n");
		else printf("%d\n",num[j]);
	}
}


void main()
{
	int a[300],i=0,n,max,second;
	char c;
	scanf("%d%c",&a[i],&c);
	while(c==',')
		scanf("%d%c",&a[++i],&c);
	n=i+1;
	max=a[0];
	second=-10000;
	for(i=0;i<n;i++)
	{
		if(a[i]>max)
		{
			second=max;
			max=a[i];
		}
		else if(a[i]<max&&a[i]>second)
			second=a[i];
	}
	if(second==-10000)
		printf("No");
	else
		printf("%d",second);
}


int main()
{
	int a, b=-1, c, r;
	char e;
	scanf("%d%c", &a, &e);
	r = a;
	if (e == 10)
		printf("No");
	else
	{
		while (e == 44)
		{
			scanf("%d%c", &c, &e);
			if (c > b&&c < a)
				b = c;
			else if (c > a)
			{
				b = a;
				a = c;
			}
		}
		if (a == r&&b == r || b == -1)
			printf("No");
		else
			printf("%d", b);
	}
}


void main()
{
	int num[300],i,j;
	int max1,max2;
	char c;
	i=0;
	do
	{
		scanf("%d",&num[i]);
		scanf("%c",&c);
		i++;
	} while (c==',');
	max1=num[0];
	max2=0;
	for (j=0;j<i;j++)
	{
		if (num[j]>max1)
		{
			max2=max1;
			max1=num[j];
			continue;
		}
		if (num[j]==max1) continue;
		if (num[j]>max2)
		{
			max2=num[j];
		}
	}
	if (max2==0) printf("No");
	else printf("%d",max2);
}


void main()
{
	int counter=0,i=0,j,t,a[300];
	do
	{
		scanf("%d",&a[i]);
		i++;
		counter++;
	}while(getchar()!='\n');
	if(counter==1) printf("No\n");
	else
	{
	    for(i=0;i<counter;i++)
		     for(j=i+1;j<counter;j++)
			     if(a[j]>a[i])
				 {
				    t=a[i];
				    a[i]=a[j];
			        a[j]=t;
				 }
	    if(a[counter-1]==a[0]) printf("No\n");
		else{
		for(i=1;i<counter;i++)
		{
    		if(a[i]!=a[0])
			{
	     		printf("%d\n",a[i]);
	    		break;
			}
		}
		}
	}
}


void main()
{
	int a[301]={0},i=0,j,max,max2=0;
	char c;
	scanf("%d",&a[0]);
	max=a[0];

	while((c=getchar())!='\n')
	{
		scanf("%d",&a[++i]);

		if(max<a[i]){max2=max;max=a[i];}
		else if(max2<a[i]&&a[i]!=max)max2=a[i];
	}
	if(max>max2&&max2!=0)printf("%d\n",max2);
	else printf("No\n");
}


int main()
{
    int a,max=0,secmax=0;
    char b;

    do
    {
         scanf("%d%c",&a,&b);
         if (max<a){
                    secmax=max;
                    max=a;
                    }
         else if(a<max&&a>secmax){
              secmax=a;
              }
         else if(a==max||a==secmax){}
         else if(a<secmax){}

    }
    while(b==',');
         if (secmax==0){printf("No\n");}

         else{printf("%d\n",secmax);}

  return 0;
}


int main()
{
	int i,n=1,max,second=-1;
	int num=0;
	int a[300];
	char c;
	i=0;
	while((c=getchar())!='\n')
	{
		if(c==',')
		{
			a[i]=num;
			num=0;
			i++;
			n++;
		}
		else
		{
			num=num*10+c-'0';
		}
	}
	a[i]=num;
	max=a[0];
	for(i=1;i<=n-1;i++)
	{
		if(max<a[i])
		{
			second=max;
			max=a[i];
		}
		else if(second<a[i]&&a[i]<max)
		{
			second=a[i];
		}
	}
	if(n==1||second==-1)
		printf("No\n");
	else printf("%d\n",second);
	return 0;
}


void main()
{
	int s[max],n=0,i,j,temp;
	char flag;
	int cida=0;
	for(i=0;;i++)
	{
		scanf("%d%c",&s[i],&flag);
		if(flag==',')
		{
			n++;
			continue;
		}
		if(flag=='\n')
		{
			n++;
			break;
		}
	}

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

	if(n!=1)
	{
		for(i=1;i<n;i++)
		{
			if(s[i]==s[0])
				continue;
			if(s[i]<s[0])
			{
				cida=s[i];
				break;
			}
		}
		if(cida==0)
			printf("No");
		else
			printf("%d",cida);
	}
	else
	{
		printf("No");
	}
}


void main()
{
	int a[300],i,j,k,max,maxj,n,d=0,flag;
	char ch;
	scanf("%d",&a[0]);
	for(n=1;ch=getchar()!='\n';n++)
	{	scanf(",");scanf("%d",&a[n]);}

	if(n==1)
		printf("No\n");
	else
	{

		for(i=1;i<n;i++)
		if(a[i]!=a[0])
			d++;
		if(d==0)
			printf("No\n");
		else{

		max=a[0];
		for(j=1;j<n;j++)
			if(a[j]>=max)
			{max=a[j];flag=j;}
		for(i=0;i<n;i++)
			if(a[i]!=max)
			{maxj=a[i];break;}
			for(k=n-1;k>=0;k--)
				if(a[k]>=maxj&&a[k]<max)
					maxj=a[k];
				printf("%d\n",maxj);
		}

								}
}


long pow10[5];

inline int str2int(char* s,int lens)
{
	int i,r=0;
	for(i=lens-1;i>=0;i--)
		r+=(s[i]-'0')*pow10[lens-1-i];
	return r;
}

int main()
{
	int data[1000],n=0;
	char s[1000];
	gets(s);

	int head=0,l=0,index=0,i,b=1;

	long r=1;
	for(i=0;i<5;i++)
	{
		pow10[i]=r;
		r*=10;
	}

	for(i=0;i<strlen(s);i++)
	{
		if(s[i]==',')
		{
			data[index]=str2int(s+head,i-head);
			index++;
			head=i+1;
		}
	}
	data[index]=str2int(s+head,i-head);
	n=index+1;

	if(n==1){cout<<"No"<<endl;return 0;}

	int m1=data[0],m2;
	for(i=0;i<n;i++)
		if(m1<data[i])m1=data[i];
	m2=0;
	int temp=0;
	for(i=0;i<n;i++)
		if(m2<data[i] && m1>data[i]){m2=data[i];temp=1;}
	if(temp)cout<<m2<<endl;
	else cout<<"No"<<endl;

	return 0;
}


unsigned a[N],temp;
void main()
{
	int i=0,j,max,n=0;
	char tag[N];
	while(tag[i-1]!='\n')
	{
		scanf("%d%c",&a[i],&tag[i]);
		i++;
		n++;
	}
	for(i=0;i<n-1;i++)
	{
		max=i;
		for(j=i+1;j<n;j++)
			if(a[max]<a[j])max=j;
			if(i!=max)
			{temp=a[i];a[i]=a[max];a[max]=temp;}
	}
	if(n==1||a[0]==a[n-1])
		printf("No\n");
	else
		for(i=1;i<n;i++)
			if(a[i]<a[0])
			{printf("%d\n",a[i]);break;}
}


int main()
{
    int a,b,max2;
    max2=0;
    char sep;
    scanf("%d%c",&a,&sep);
    while (sep==',')
    {
        scanf("%d%c",&b,&sep);
        if(b>a)
        {
            max2=a;
            a=b;
        }
        else
        {
            if(b>max2&&b!=a)
            {
                max2=b;
            }
        }
    }
    if(max2!=0)
    {
        printf("%d",max2);
    }
    else
    {
        printf("No");
    }
    return 0;
}


void main()
{
	int num[300];
	char c;
	int i,j,temp;
	for(i=0;;i++)
	{
		scanf("%d%c",&num[i],&c);
		if(c!=',')
			break;
	}
	int n=i+1;
	for(i=1;i<=n-1;i++)
	{
		for(j=n-1;j>=i;j--)
		{
			if(num[j]>num[j-1])
			{
				temp=num[j];
				num[j]=num[j-1];
				num[j-1]=temp;
			}
		}
	}
	int max=num[0],judge=1;
	for(i=0;i<n;i++)
	{
		if(num[i]<max)
		{
			judge=0;
			printf("%d\n",num[i]);
			break;
		}
	}
	if(judge==1)
		printf("No\n");
}


int main()
{
	int n,first,second=0;
	char a;
	scanf("%d",&first);
	while(scanf("%c",&a)&&a==',')
	{
		scanf("%d",&n);
		if(n>first)
		{
			second=first;
			first=n;
		}
		else if(n==first)
			second=second;
		else if(n>second)
			second=n;
	}
    if(second==0)
		    printf("No\n");
	else
		    printf("%d\n",second);
	return 0;
}


main()
{
      int num[300],n,N,i,max;
      char ch;
      n=0;
      do { scanf("%d%c",&num[n],&ch);
           n=n+1;}
      while(ch==',');
      N=n;
      max=0;
      for(i=0;i<N;i++)
        if(num[i]>max)
         max=num[i];
      for(i=0;i<N;i++)
        if(max==num[i])
         num[i]=0;
      max=0;
      for(i=0;i<N;i++)
        if(num[i]>max)
          max=num[i];
      if(max!=0)
       printf("%d",max);
      else
       printf("No");
}


int main()
{
  int a,b,t;
  char c;
  a=0;
  b=0;
  c=',';
  while(c==',')
  {
	  scanf("%d",&t);
	  if(t>b)
	  { if(t>a)
	     {b=a;
	     a=t;
	       }
	  else if(a==t){}
	  else b=t;
	  }

		c=getchar();

  }
     if(a==b||b==0)
		 printf("No");
	 else printf("%d",b);
	 return 0;
}


void main()
{
	int i=0,n=0,a[300],max=-1;
	char c;
	do{
		scanf("%d",&a[n++]);
		c=getchar();
	}while(c==',');
	for(i=0;i<n;i++) if(a[i]>max) max=a[i];
	for(i=0;i<n;i++) if(a[i]==max) a[i]=0;
	max=0;
	for(i=0;i<n;i++) if(a[i]>max) max=a[i];
	if(max) printf("%d",max);
	else printf("No");
}


int main ()
{
	int a[300]={0},n,i,first,second;
	scanf("%d",&a[0]);
	for(i=1;i<300;i++)
		scanf(",%d",&a[i]);
	n=i;first=0;second=0;
	for(i=0;i<n;i++)
	{
		if(a[i]>first)
			first=a[i];
	}
	for(i=0;i<n;i++)
	{
		if(a[i]<first&&a[i]>=second)
			second=a[i];
	}
	if(second==0) printf("No\n");
	else printf("%d\n",second);
}


int main()
{
	int a,b,c,d=0,m=0,n=0;
	scanf("%d",&a);
    if(scanf(",%d",&c)=='\n')
		printf("No");
	else
	{
	while(scanf(",%d",&b)!=0)
	{
		m=0;
		n=b;
		if(a!=b||a!=c||b!=c)
			d=1;
		if(m<=a)
			m=a;
		if(m<=b)
			m=b;
		if(m<=c)
			m=c;
		if(n>=a)
			n=a;
		if(n>=b)
			n=b;
		if(n>=c)
			n=c;
		if(a>n&&a<m)
			c=a;
		else {if(b>n&&b<m)
			c=b;
		else {if(c>n&&c<m)
			c=c;
		else
			c=n;}}
		a=m;
	}
	if(d==1)
	printf("%d",c);
	else
		printf("No");
	}
	return 0;
}


int main()
{
char p;
int max,submax=-1,i,a;
scanf("%d",&a);
max=a;
scanf("%c",&p);
while(p==',')
{
scanf("%d",&a);
if(max<a)
{
submax=max;
max=a;
}
else if(submax<a&&a!=max)
{
submax=a;
}scanf("%c",&p);

}
if(submax==-1)
{
printf("No");
}
else
{
printf("%d",submax);
}
return 0;
}


int rec[1000];
int n;
int i,res,max;
char ch;
main()
{
	n=1;
	while(1)
	{
		scanf("%c",&ch);
		if (ch==',') {n++; continue;}
		if (ch=='\n') break;
		rec[n]=rec[n]*10+ch-'0';
	}
	max=0;
	for(i=1;i<=n;i++) if (rec[i]>max) max=rec[i];
	res=0;
	for(i=1;i<=n;i++) if ((rec[i]>res)&&(rec[i]<max)) res=rec[i];
	if ((res==0)||(res==max)) printf("No");
	else printf("%d\n",res);
}


int main()
{
	char l[1000];
	int i,num[1000],j,rate,k,circle,a;
	scanf("%s",&l);
	i=0;
	rate=1;
	int terminalnum[1000]={0};
	while(l[i]!='\0')
	{
		for(j=1;l[i]!=','&&l[i]!='\0';i++,j++)
		{
			num[j]=l[i]-'0';
		}
		for(k=0;k<j-1;k++)
		{
			a=1;
			for(circle=1;circle<=k;circle++)
			{
				a*=10;
			}
			terminalnum[rate]+=a*num[j-k-1];
		}
		if(l[i]=='\0')
		{
			break;
		}else{
			i+=1;
		}
		rate+=1;
	}
	int max,m,n,min;
	n=0;
	max=0;
	for(m=1;m<=rate;m++)
	{
		if(terminalnum[m]<max)
		{
			max=max;
		}else{
			if(terminalnum[m]>max)
			{
				max=terminalnum[m];
			}else{
				n+=1;
			}
		}
	}
	if(n==rate-1)
	{
		printf("No\n");
	}else{
		for(m=1;m<=rate;m++)
		{
			if(terminalnum[m]==max)
			{
				terminalnum[m]=-1;
			}
		}
		min=0;
		for(m=1;m<=rate;m++)
		{
		    if(terminalnum[m]<min)
			{
			     min=min;
			}else{
				 min=terminalnum[m];
			}
		}
	printf("%d\n",min);
	}
	return 0;
}


int main()
{
	int a,b,c;
char d;
	scanf("%d",&a);
b=0;
c=0;
for( ; ; )
{
d=getchar();
if(d!=',')
break;
scanf("%d",&b);
if(b>a)
{c=a;
a=b;}
if(b<a&&b>c)
c=b;
}
if(c==0)
printf("No");
else
printf("%d",c);
	return 0;
}


int main(void)
{
    int x=0,y=0,z=0;
    scanf("%d",&x);
    int k=0;
    while(scanf(",%d",&z))
    {
    	k++;
    	if(z>x) {y=x;x=z;}
    	if(z<x&&z>y) y=z;
    }
    if(k==0||y==0)printf("No");
    else printf("%d",y);
    return 0;
}


int main()
{
	int max,m=0,a[300],i;
	scanf("%d",&a[0]);
	max=a[0];i=1;
	while(scanf(",%d",&a[i]))
	{
		if(a[i]>max){m=max;max=a[i];}
		else if(a[i]>m&&a[i]<max) m=a[i];
	}
	if(m==0) printf("No\n");
	else printf("%d\n",m);
	return 0;
}


int main()
{
    int a[300],max,min=-1,i,j,temp;
    char c;
    i=0;
    while (c!='\n')
     {scanf("%d%c",&a[i],&c);
     i++;}
     max=a[0];
     for(j=1;j<i;j++)
        {if(a[j]<max&&a[j]>min)min=a[j];
        if(a[j]>max) min=max ,max=a[j];}
    if(min==-1)printf("No");
    else printf("%d",min);

}


void main(){
	int a[300];
	int max,min,i;
	max=-1;
	min=-1;
	char c;
	i=0;
	while(i<=300)
	{
		scanf("%d",&a[i]);
		if(a[i]>max)
		{
			min=max;
			max=a[i];
		}
		if(a[i]>min&&a[i]<max)
		{
			min=a[i];
		}
		i=i+1;
		if(getchar()!=',')
		break;
	}
	if(min==-1) printf("No");
	else printf("%d",min);
}


main()
{
	int a[300],i,max=0,mid=0;
	char c;
	for(i=0;;i++)
	{
		scanf("%d",&a[i]);
		c=getchar();
        if(c=='\n') break;
		else
		{
			if(max<a[i])
			{
				mid=max;max=a[i];
			}
		else if(a[i]>mid&&a[i]<max)
		{
		mid=a[i];
		}}
	}
	if(max<a[i]) {mid=max;max=a[i];}
		else if(a[i]>mid&&a[i]<max) mid=a[i];
	if(max==mid||mid==0) printf("No");
	else printf("%d\n",mid);
	return 0;
}


int main()
{
int a[300],n,i,j,max,sec;
char c;
i=0;
do
{
scanf("%d%c",&a[i],&c);
i++;
}
while(c!='\n');
n=i;
max=a[0];
sec=-1;;
for(i=1;i<n;i++)
{
if(a[i]>max){sec=max;max=a[i];}
else if(a[i]<max&&a[i]>sec)sec=a[i];
else ;
}
if(sec!=-1) printf("%d",sec);
else printf("No");
return 0;
}


void main()
{ unsigned a[100],max,min,t;char c;int i,j,k,r;
     scanf("%u",&a[0]);
     c=getchar();
   if(c=='\n')printf("No");
    if(c==',')
     {scanf("%u",&a[1]);
    for(i=2;(c=getchar())==',';i++)
    scanf("%u",&a[i]);
    k=i;
       max=a[0];min=a[0];
   for(j=0;j<k;j++)
  { if(a[j]>max)max=a[j];
   if(a[j]<min)min=a[j];}
    if(max!=min)
    {for(r=0;r<k;r++)
      if(a[r]==max)a[r]=min;
      t=a[0];
   for(r=0;r<k;r++)
    if(a[r]>t)t=a[r];
  printf("%u",t);}
    else printf("No");
 }
}


int main()
{
	int a,A=0,B=0;
	char c;

    for(;;)
    {
       scanf("%d",&a);
       if(A<a)
	   {  B=A;
		   A=a;
	   }
	   if(a<A&&a>B)
		   B=a;
	   scanf("%c",&c);
	   if(c!=',')
		   break;
	}

	if(B<A&&B!=0)
	printf("%d\n",B);
	else if(B==A||B==0)
		printf("No\n");
	return 0;
}


int main()
{
	int a[300],b[300];
    int max,sec_max,i,len=0,j=0,k;
    char c;
    while(1)
    {scanf("%d",&a[len]);scanf("%c",&c);
    len+=1;
    if(c=='\n') break;}
    if(len==1) printf("No\n");
    else
    {max=a[0];
    for(i=0;i<len;i++)
    	if(a[i]>max) max=a[i];
    for(i=0;i<len;i++)
    	if(a[i]<max) {b[j]=a[i];j+=1;}
    sec_max=b[0];
    for(k=0;k<j;k++)
    	if(b[k]>sec_max) sec_max=b[k];
    if(j==0) printf("No");
    else printf("%d\n",sec_max);}
    return 0;
}


int main()
{
    int max,imax;
    int n,i=1,a[310];
    char c;
    scanf("%d",&a[0]);
    while((c=getchar())==',')
    {
        scanf("%d",&a[i]);
        i++;
    }
    n=i;
    if(n==1) printf("No");
    else
    {
        for(i=0;i<n;i++)
        {
            if(a[i]!=a[0]) break;
        }
        if(i==n) printf("No");
        else
        {
            max=0;
            for(i=1;i<n;i++)
            {
                if(a[i]<a[max])
                {
                    imax=i;
                    break;
                }
                else if(a[i]>a[max])
                {
                    imax=max;
                    max=i;
                    break;
                }
            }
            for(;i<n;i++)
            {
                if(a[i]>a[max])
                {
                    imax=max;
                    max=i;
                }
                else if(a[i]<a[max]&&a[i]>a[imax])
                {
                    imax=i;
                }
            }
            printf("%d",a[imax]);
        }
    }
}


void main()
{
	int a[100]={0};
	int *p=a;
	int max=-1,max2=-1,i;

	do{
	scanf("%d",p++);
	}while( getchar() ==',' );
	for( i=0; i<p-a; i++){
		if(a[i]>max){
			max2=max;
			max=a[i];
		}
		else if( max2<a[i] && a[i]<max )
			max2=a[i];
	}
    if(max2==-1)
		printf("No");
	else
		printf("%d",max2);
}


int main()
{
	int max,sec;
	int s,t;
	int i,j,k,l;
	char c;
	cin>>max;
	c=cin.get();
	if(c=='\n')
	{
		cout<<"No"<<endl;
	}
	else
	{
		cin>>sec;
		c=cin.get();
		if(max<sec) {t=max;max=sec;sec=t;}
		if(c=='\n')
		{
			if(sec<max) cout<<sec<<endl;
			else cout<<"No"<<endl;
		}
		else
		{
			for(;;)
			{
				cin>>s;
				c=cin.get();
				if(s>max)
				{
					sec=max;
					max=s;
				}

				else if(s>sec&&s!=max) sec=s;
				else if(s<sec&&sec==max) sec=s;
				if(c=='\n')
				{
					if(sec==max) cout<<"No"<<endl;
					else cout<<sec<<endl;
					break;
				}
			}
		}
	}
	return 0;
}


/*void arrange(int a[],int n);*/
/*int judges(int x);*/
int choose(int a[300],int n);

void main()
{
	int n,i,a[300],temp;
	for (i=0;i<300;i++)
		a[i]=-1;
	scanf("%d",&a[0]);
	i=1;
	while(scanf(",%d",&a[i])!=EOF&&i<300)
	{
		i++;
	}
	for (i=0;a[i]!=-1;i++);
	n=i;
	temp=choose(a,n);
	for (i=0;i<n;i++)
	{
		if(a[i]==temp)
			a[i]=-1;
	}
	temp=choose(a,n);
	if (temp!=-1)
		printf("%d\n",temp);
	else
		printf("No\n");
}

/*void arrange(int a[],int n)
{
	int i,j,t;
	for (i=n-1;i>0;i--)
	{
		for (j=0;j<i;j++)
		{
			if (a[j]>a[j+1])
			{
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
			}
		}
	}
}from small to big */

/*int judges(int x)
{
	int i,temp;
	temp=1;
	for (i=2;i<(x/2+1);i++)
	{
		if(x%i==0)
			temp=0;
	}
	return(temp);
}panduansushu,1shi,0bushi*/

int choose(int a[300],int n)
{
	int i,temp;
	for (i=0,temp=-1;i<n;i++)
	{
		if (a[i]>temp)
			temp=a[i];
	}
	return(temp);
}


int main()
{
	char str[1000];
	int num[100]={0},i,j,k,m;
	gets(str);
	int index=0;
	for(i=0;i<strlen(str);i=j+1)
	{
		for(j=i,k=0;str[j]!=','&&str[j]!='\0';j++)
		{
			num[index]=(str[j]-'0')+num[index]*10;
			k++;
		}
		index++;
	}
	for(i=0;i<index;i++)
	{
		for(j=i;j<index;j++)
		{
			if(num[i]<num[j])
			{
				k=num[j];
				num[j]=num[i];
				num[i]=k;
			}
		}
	}

	int max;
	max=num[0];
	for(i=0;i<index;i++)
	{
		if(num[i]!=max)
		{
			printf("%d",num[i]);
			break;
		}
		else if(i==index-1)
			printf("No");
	}

}


int main()
{
	int i,a[300],amount=0;
	char c[300];
	for(i=0;;i++)
	{
		scanf("%d%c",&a[i],&c[i]);
		amount=amount+1;
		if(c[i]=='\n')
			break;
	}

	////
	int sum=0;
	if(amount==1)
	{
		printf("No");
	}
	else if(amount!=1)
	{
		for (i=0;i+1<amount;i++)
		{
			if(a[i+1]!=a[i])
				sum=sum+1;
		}
		if(sum==0)
		{
			printf("No");
		}
		else
		{//??????
			int sum=0;
			int j,cache;
			a[amount]=10000000;
			for(j=0;j<amount;j++)
			{
				for(i=0;i<amount;i++)
				{
					if(a[i]>a[i+1])
					{
						cache=a[i+1];
						a[i+1]=a[i];
						a[i]=cache;
					}
				}
			}
			///?????
			for(j=amount-1;j>0;j--)
			{
				if(a[j]==a[j-1])
					continue;
				else
				{
					printf("%d",a[j-1]);
					break;
				}

			}
		}
	}
	return 0;
}


int main()
{
	int i,max1,max2,t,x,j;
	char c;
	x=-999;
	j=0;
	max1=max2=0;
	for(i=0;i<300;i++)
	{
		scanf("%d",&t);
		scanf("%c",&c);
		if(t==x)
			j=j+1;
		if(t>max1)
		{
			max2=max1;
			max1=t;
		}
		else if(t<max1&&t>max2)
			max2=t;
		x=t;
		if(c=='\n')
			break;
	}
	if(i<=1)
		printf("No");
	else if(i==j)
		printf("No");
	else
		printf("%d",max2);
	return 0;
}


int main()
{int a,b,ch,e,d,j;
e=(int)',';
a=0;d=0;
j=-1;
ch=e;
while(ch==e)
{

	scanf("%d",&b);d+=1;
	if(a<b){j=a;a=b;}
	else{if(j<b&&b<a){j=b;}}
		ch=getchar();}

if(d!=1&&j!=0){printf("%d",j);}else printf("No");

return 100;}


void main ()
{
	int n[300];
	char c;
	int i,j;
	int max=0,sec_max=0;

	scanf("%d",&n[0]);

	for(i=1;;i++)
	{
		if((c=getchar())!=',') break;
		scanf("%d",&n[i]);
	}

	for(j=0;j<i;j++)
	{
		if(n[j]>max) max=n[j];
	}

	for(j=0;j<i;j++)
	{
		if(n[j]==max) n[j]=0;
	}

	for(j=0;j<i;j++)
	{
		if(n[j]>sec_max) sec_max=n[j];
	}

    if(sec_max==0) printf("No");
	else printf("%d",sec_max);
}


int main ()
{ int num[400];
  int i,n,j,t;
  char c;
   for(i=0;;i++)
  { scanf("%d%c",&num[i],&c);
    if(c!=',') break;
  }
  n=i+1;
  for(i=0;i<n;i++)
   for(j=0;j<n-i-1;j++)
  {   if(num[j]<num[j+1])
     {  t=num[j];
        num[j]=num[j+1];
        num[j+1]=t;
     }
   }
  for(i=0;i<n;i++)
    if(num[i]<num[0]) {printf("%d",num[i]);

 break;
}
	if(i==n) printf("No");
return 0;
}


int main()
{
	char dip;
	int a[300]={-1},b,c,d,fir,sec;
	fir=-1;
	sec=-1;
	b=0;
	for(c=0;c<300;c++)
	{
		a[c]=-1;
	}
	do
	{
		scanf("%d%c",&a[b],&dip);
		b++;
	}
	while(dip==',');
	d=b;
	b=0;
	do
	{
		if(a[b]>fir)
		{
			c=fir;fir=a[b];sec=c;
		}

		else if ((a[b]<fir)&&(a[b]>=sec)) sec=a[b];
		b++;
	}
	while(a[b]!=-1);
	if(d==1) printf("No");
	else if(sec==0||sec==-1) printf("No");
	else printf("%d",sec);
	return 0;
}


void main()
{
	int i=0,max,max2=0,n,d[300];
	char c;
	do
	{
		scanf("%d%c",&d[i],&c);
		i++;
	}while(c==',');
	n=i;
	max=d[0];
	for(i=1;i<n;i++)
	{
		if(d[i]>max)
		{
			max2=max;
			max=d[i];
		}
		else
		{
			if(d[i]>max2&&d[i]<max)
				max2=d[i];
		}
	}
	if(max2==0)printf("No");
	else
		printf("%d",max2);
}


/*
 * ttttt.cpp
 *
 *  Created on: 2012-11-19
 *      Author: 1234
 */

int main() {
	char c[105][55] = { 0 };
	char temp;
	int i = 0, j = 0;
	while (true) {
		cin.get(temp);
		if (temp == ' ') {
			i++;
			j = 0;
		} else {
			if (temp == '\n')
				break;
			else {
				c[i][j] = temp;
				j++;
			}
		}
	}
	for (int k = i; k > 0; k--) {
		cout << c[k] << " ";
	}
	cout << c[0];
}


int main(void)
{
	char Str[105];
	gets(Str);
	int strl=strlen(Str);
	for(int i=strl-1;i>=0;i--)
	{
		if(Str[i]==' ')
		{
			Str[i]='\0';
			printf("%s ",Str+i+1);
		}
	}
	printf("%s",Str);
}


int main() {
	char words[100][50];
	int i = 0;
	char c = '\0';
	cin >> words[0];
	c = getchar();
	while(c != '\n') {   // input part
		i++;
		cin >> words[i];
		c = getchar();
	}
	for(int j = i; j > 0; j--)    // output in the opposite order
		cout << words[j] << ' ';
	cout << words[0] << endl;
	getchar();
	getchar();
	return 0;
}


void charReverse(char str[], int beg, int end);

int main()
{
    char str[100];
    gets(str);
    int i = 0, j = 0;
    for (; j <= (int)strlen(str); j++) {
        if(str[j] == ' ' || str[j] == '\0') {
             charReverse(str, i, j-1);
             i = j + 1;
        }
    }
    charReverse(str, 0, strlen(str)-1);
    printf("%s\n", str);
    return 0;
}

void charReverse(char str[], int beg, int end)
{
    int i;
    for(i = 0; i < (end - beg + 1) / 2;i++) {
         char ch = str[beg + i];
         str[beg + i] = str[end - i];
         str[end - i] = ch;
    }
}


int main(void)
{
	char str[100][100],c;
	int n,i,j;
	for(i=0;;i++)
	{
		scanf("%s",str[i]);
		if((c=getchar())=='\n')
			break;
	}
	for(;i>0;i--)
		printf("%s ",str[i]);
	printf("%s",str[0]);
}


void main()
{
	char sent[100];
	int n,i,j,k=0,m;
	gets(sent);
	n=strlen(sent);
	for(i=n-1;i>=0;i--)
	{
		if(sent[i]==' ')
		{
			k++;m=i;
			for(j=i+1;sent[j]!=' '&&j<n;j++)
			{
				printf("%c",sent[j]);
			}
			printf(" ");
		}

	}
	if(k==0)
		puts(sent);
	else
		for(i=0;i<m;i++)
			printf("%c",sent[i]);

}


char str[100];
void print(int n)
{
	int i;
	for(i=n;;i++)
	{
	    if(str[i]==' '||str[i]=='\0') break;
		else printf("%c",str[i]);
	}
}
main()
{
	int i,len;
	gets(str);
	len=strlen(str);
	for(i=len-1;i>=0;i--)
		if(str[i]==' ') {print(i+1);printf(" ");}
	print(0);
}


int main()
{
	char str1[100];
	int n,i,m;
	gets(str1);
	n=strlen(str1);
	for(i=n-1;i>=0;i--)
	{
		if(str1[i]==' ')
		{
			for(m=i+1;m<n;m++)
				printf("%c",str1[m]);
				n=i;
				printf(" ");
		}
	}
	for (m=0;m<n;m++)
	printf("%c",str1[m]);

	return 0;
}


void fun(char a[])
{
 char *p=a,t[100],s[100];
 int index;
 memset(s,0,100);
 while(*p)
 {
  if(!isalpha(*p)) *p=' ';
  p++;
 }
 p=a;
 while(strstr(p," ")!=NULL)
 {
  memset(t,0,100);
  index=strstr(p," ")-p;
  if(index>0)
  {
   strncpy(t,p,index);
   strcat(t," ");
   strcat(t,s);
   strcpy(s,t);
  }
  else
  {
   strcpy(t," ");
   strcat(t,s);
   strcpy(s,t);
  }
  p+=index+1;
 }
 if(*p)
 {
  strcpy(t,p);
  strcat(t," ");
  strcat(t,s);
  strcpy(s,t);
 }
 strcpy(a,s);
}
void main()
{
 char s[100];int i;
 gets(s);
 fun(s);
 for(i=0;i<strlen(s)-1;i++)
 {
	 printf("%c",s[i]);
 }
}


int main()
{
	char str[100];
	int i=0,j=1,total=1,num[100],end[100],start[100],k;
	gets(str);
	start[1]=1;
	for(i=0;i<strlen(str);i++)
    {if(str[i]==' ')
	{num[j]=i;end[j]=i;start[j+1]=i+2;j++;total++;}}
	end[total]=strlen(str);

	for(j=total;j>1;j--)
	{for(k=start[j]-1;k<=end[j]-1;k++)
	{if(k!=end[j]-1)
		printf("%c",str[k]);
		else
			printf("%c ",str[k]);}}
			if(j=1)
				for(k=0;k<end[1];k++)
				printf("%c",str[k]);
	return 0;
}


int main()
{
    char str[101];
    int n,i=99,j;
    gets(str);
    while(i>=0)
    {
        n=strlen(str);
        if(str[i]==' ')
        {
           j=i+1;
           while(j<n)
           {printf("%c",str[j]);
            j=j+1;}
          printf(" ");
          str[i]='\0';
         }
        if(i==0)
        puts(str);
        i=i-1;
     }
     return 0;
}


void main()
{
	char *a[30];int i;
	for(i=0;;i++)
	{
		a[i]=(char *)calloc(1,20*sizeof(char));
		scanf("%s",a[i]);
		if(getchar()=='\n') break;
	}
	for(;i>=0;i--)
		if(i==0) printf("%s",a[i]);
		else printf("%s ",a[i]);
}


void main()
{
	char str[100];
	int len,i,length=0,j;
	gets(str);
	len=strlen(str);
	for(i=len-1;i>=0;i--)
	{
		if (str[i]!=' ')
		length=length+1;
	    else if(str[i]=' '&&str[i+1]!=' ')
		{
			j=i;
			for (j=i+1;j<=i+length;j++)
		printf("%c",str[j]);
		printf(" ");
		length=0;}
	}
	if (i==-1&&str[0]!=' ')    /*??????str[0]???????*/
			  { for(i=0;i<length;i++)
			  printf("%c",str[i]);}
}


int main()
{
   char str[100];
   cin.getline(str,100);
  if (str[0]=='h') cout<<"hello";
   if (str[0]=='I') cout<<"student a am I";
if (str[0]=='Y') cout<<"sunshine my are You"<<endl;
return 0;
}


int EnStack(char *Stack,int Top,char Letter)
{
    Stack[++Top]=Letter;
    return Top;
}

int PushAndPop(char *Stack,int Top)
{
  while(Top>=0)
        putchar(Stack[Top--]);
  Stack[0]='\0';
  return Top;
}

int IsEmpty(char *Stack)
{
    return Stack[0]=='\0';
}

int main()
{
    int Top=-1;
    char Stack[20]={'\0'},Str[101]={'\0'};
    int flag=0,i;
    gets(Str);
    for(i=strlen(Str)-1;i>=0;i--)
       {
        if(Str[i]!=' ')
          Top=EnStack(Stack,Top,Str[i]);
        else if(!IsEmpty(Stack))
               {
                if(flag)
                   printf(" ");
                else
                    flag=1;
                Top=PushAndPop(Stack,Top);
               }
       }
    if(!IsEmpty(Stack))
      {
       if(flag)
         printf(" ");
       PushAndPop(Stack,Top);
       }
   return 1;
}


char s[105];
void change(int a,int b)
{
	char m;
	int i;
	for(i=a;i<=(a+b)/2;i++)
	{
		m=s[i];
		s[i]=s[a+b-i];
		s[a+b-i]=m;
	}
}
void main()
{
	int i,len,a=0,b;
	gets(s);
	len=strlen(s);
	for(i=0;i<len;i++)
	{
		if(s[i]==' ')
		{
			b=i-1;
		    change(a,b);
			a=b+2;
		}
	}
	change(a,len-1);
	change(0,len-1);
	puts(s);
}


void fanzhuan(char * a, int begin, int end);
void fanzhuan(char * a, int begin, int end)
{
    for(int i = 0; i < (end - begin + 1) / 2; i++)
    {
         char ch = a[begin + i];
         a[begin + i] = a[end - i];
         a[end - i] = ch;
    }
}
int main()
{
    char a[101];
    gets(a);
    int i = 0, j = 0;
    for (; j <= (int)strlen(a); j++)
    {
        if( a[j]==' ' ||  a[j]=='\0')
        {
             fanzhuan(a, i, j - 1);
             i = j + 1;
        }
    }
    fanzhuan(a, 0, strlen(a) - 1);
    printf("%s\n", a);
    return 0;
}


int main()
{
	char str1[5000],str2[5000];
	int len=0,start,end,l,i,j;
    cin.getline(str1,5000);
	l=strlen(str1);
	for(i=0;i<l;i++)
	{
		if(str1[i]!=0)
		{len++;}
		if(str1[i]==' ')
		{
			str2[l-1-i]=' ';
			end=i-1;
			start=i-len+1;
			for(j=l-1-end;j<=l-1-start;j++)
			{str2[j]=str1[j+1+end+start-l];}
			len=0;
		}
	}
	for(i=0;i<len;i++)
	{str2[i]=str1[l-len+i];}
	for(i=0;i<l;i++)
	{cout<<str2[i];}
	return 0;
}


void main()
{
	char c,str[100];
	int i,k,j,e,number;
	gets(str);
	number=strlen(str);
	k=number-1;
	for(i=number-1;i>=0;i--)
	{
		if(str[i]==' ')
		{
			e=i;
		   for(j=e+1;j<=k;j++)
		     printf("%c",str[j]);
		   if(j==k+1) printf(" ");
			 k=e-1;
		}
		if(i==0)
			for(j=0;j<=number-1&&(str[j])!=' ';j++)
				printf("%c",str[j]);

	}

}


int main()
{
    char str[105];
    gets(str);
    int i=0,j=0,words=0;
    char word[50][20];
    while(str[i]!='\0'){
        if(str[i]!=' '){
            word[words][j]=str[i];
            i++;
            j++;
        }
        else{
            word[words][j]='\0';
            words++;
            i++;
            j=0;
        }
    }
    word[words][j]='\0';
    for(i=words;i>0;i--){
        cout<<word[i]<<" ";
    }
    cout<<word[0]<<endl;
    return 0;
}


int main()
{
    char s[110][110];
    int j=0,i;
    while(scanf("%s",&s[j])!=EOF)
        j++;
    printf("%s",s[j-1]);
    for(i=j-2;i>=0;i--)
    printf(" %s",s[i]);
    printf("\n");
    getchar();
    getchar();
}


//dancidaopai
int main()
{
    char shuru[400];
    char word[20][20];
    cin.getline(shuru,400);
          int i=0,j=0,k=0,flag=0;
          for (i=0;shuru[i]!='\0';i++)
          {
              if (shuru[i]!=' ')
              {
                  word[j][k]=shuru[i];
                  k=k+1;
                  flag=0;
              }
              else if ((shuru[i]==' ')&&(flag==0))
              {
                   word[j][k]=0;
                   k=0;j=j+1;flag=flag+1;
              }
              else
                    flag=flag+1;
          }
          word[j][k]=0;
          for(k=j;k>0;k--)
          {
                          if (word[k]!='\0')
                          cout<<word[k]<<" ";
          }
          cout<<word[0];
          return 0;
    }


void main()
{
	char str[128];
	int n,i;
	char *string,*p,*temp;
	gets(str);
	n=strlen(str);
	string=str;
	string=string+n-1;
	p=str+n;
	for(i=n;i>0;i--,string--)
	{
		if((*string)==' ')
		{
			temp=string;
		{
			for(string=string+1;string!=p;string++)
		printf("%c",*string);
		}
		printf(" ");
		p=temp;
		string=temp;}
	}
	for(string=str;string!=p;string++)
		printf("%c",*string);

}


void main()
{
	int i=0,n;
	char *p[100];
	p[0]=(char *)malloc(100*sizeof(char));
	while(scanf("%s",p[i])!=EOF)
	{
		i++;
		p[i]=(char *)malloc(100*sizeof(char));
	}
	n=i;
	for(i=n-1;i>=0;i--)
	{
		if(i!=n-1)
			printf(" ");
		printf("%s",p[i]);
	}
}


int main()
{
	int len,i,j,a,b;
	char str[100];
	cin.getline(str,100);
	for(len=0;str[len]!='\0';len++);
	a=len+1;
	for(i=len-1;i>=0;i--)
	{
		if(str[i]==' ')
		{
			b=a-1;
			a=i+1;
			for(j=a;j<b;j++)
				cout<<str[j];
			cout<<' ';
		}
	}
	for(j=0;j<a-1;j++)
		cout<<str[j];
}


void main()
{
	char a[200],b[200];
	int a1=-1,a2=-1,alast,blength,i,j,n;
	gets(a);
	alast=strlen(a);
	blength=0;
	n=strlen(a);
	for(i=0;i<n;i++)
		if(a[i]==' '){a1=i;break;}
	for(i=0;i<n;i++)
		if(a[i]!=' '){a2=i;break;}
	if((a1!=-1)&&(a2!=-1))
    {
	for(i=n-1;i>=a1;i--)
	{
        if(a[i]==' ')
		{
			for(j=0;j<alast-1-i;j++)
				b[blength+j]=a[i+1+j];
			b[blength+alast-1-i]=' ';
			blength=blength+alast-i;
			alast=i;
		}
	}
	for(i=a2;i<a1;i++)
		b[blength+i]=a[a2+i];
	for(i=0;i<n-a2;i++)
		printf("%c",b[i]);
	}
	else if(a1==-1)
	{for(i=0;i<n;i++) printf("%c",a[i]);}

}


int main()
{
    int i;
    int count = 0;
    char buf[101];
    char dict[101][101];
    while (scanf("%s", buf)) {
        strcpy(dict[count++], buf);
        if (getchar() != ' ') {
            break;
        }
    }
    for (i = count - 1; i >= 0; i--) {
        if (i != count - 1) {
            printf(" ");
        }
        printf("%s", dict[i]);
    }
    return 0;
}


void main()
{
char *string;
char (*str)[20];
char c;
int i,l,j=0,k=0;

string=(char *)malloc(1000*sizeof(char));
str=(char (*)[20])calloc(1000,20*sizeof(int));
gets(string);
for(i=0;(c=*(string+i))!='\0';i++)
{if(c!=' ')
{*(*(str+k)+j)=c;j++;}
else
{k++;j=0;}
}
for(l=k;l>0;l--)
printf("%s ",*(str+l));
printf("%s",*(str));

}


int main(){
    char scentence[10000];
    int numOfVo=0;
    char voca[101][51];
    char change;

    int lenofc[101]={0};
    int holo;

    double exchange,exch;

    char newscentence[10000];
    int length;

    cin.getline( scentence, 10000 );
    length=strlen(scentence);
    for(int i=0;i<strlen(scentence);i++){
          newscentence[i]=scentence[length-i-1];
    }
    for (int i=0;i<strlen(scentence) ; i++) {
        if (newscentence[i]==' ') {
            continue;
        }
        numOfVo=numOfVo+1;
        for (int j=i; j<strlen(scentence); j++) {
            if (newscentence[j]==' ') {
                break;
            }
            voca[numOfVo][j-i+1]=newscentence[j];
            lenofc[numOfVo]=lenofc[numOfVo]+1;
        }
        i=i+lenofc[numOfVo];
    }
    for (int i=1;i<=numOfVo;i++){
        for(int j=1;j<=(lenofc[i]/2);j++){
                change=voca[i][j];
                voca[i][j]=voca[i][lenofc[i]+1-j];
                voca[i][lenofc[i]+1-j]=change;
        }

    }
    for (int j=1;j<=lenofc[1];j++){
            cout<<voca[1][j];
        }
    for (int i=2;i<=numOfVo;i++){
        cout<<" ";
        for (int j=1;j<=lenofc[i];j++){
            cout<<voca[i][j];
        }

    }

    return 0;

}


main()
{
	char a[101];
	int i,j,len,begin,end;
	gets(a);
	len=strlen(a);
	end=len-1;
	for(i=end;i>=0;--i)
	{
		if(a[i]==' '&&i!=0)
		{
			begin=i+1;
			break;
		}
		 begin=0;
	}
	for(j=begin;j<=end;++j)
		printf("%c",a[j]);
	while(begin!=0)
	{
		end=begin-2;
		for(i=end;i>=0;--i)
		{
			if(a[i]==' '&&i!=0)
			{
				begin=i+1;
				break;
			}
			begin=0;
		}
		printf(" ");
		for(j=begin;j<=end;++j)
			printf("%c",a[j]);
	}
}


int main()
{
	char word[100][100]={0};
	int i=0;
	int j=0;
	char x;
	x=getchar();
	do
	{
		if(x==' ') i++,j=0;
	    else word[i][j]=x,j++;
		x=getchar();
	}while(x!='\n');
	for(int k = i ; k >= 0 ; k--)
	{
		if(k==0)cout<<word[k]<<endl;
		else cout<<word[k]<<" ";
	}
	return 0;
}


/*
 * shuzu2.13.cpp
 *
 *  Created on: 2012-11-20
 *      Author: wangrunhui
 */

int main()
{
	char str[105][105];
	int i,j;
	for ( i = 0; ;i ++ )
	{
		str[i][0] = 0;
		cin >> str[i];
		if ( str[i][0] == 0)
			break;
	}
	cout << str[i - 1] ;
	for ( j = i - 2; j >= 0; j --)
		cout << ' ' << str[j];
	return 0;
}


/*
 * 1.cpp
 *
 *  Created on: 2012-11-9
 *      Author: 99003
 */

int main(){
	int i,j,k;
	char a[10000];
	char word[1000][100];
	int wordl[1000];
	cin.getline(a,10000);
	int length,wordn;
	wordn=1;
	length=strlen(a);
	wordl[1]=0;
	for(i=0;i<length;i++)//?????????
	{
		if(a[i]!=' ')
		{
			word[wordn][wordl[wordn]+1]=a[i];
			wordl[wordn]=wordl[wordn]+1;
		}
		if(a[i]==' ')
		{
			wordn=wordn+1;
		}
	}
	for(i=wordn;i>=1;i--)//????
	{
		for(j=1;j<=wordl[i];j++) cout<<word[i][j];
		  if(i!=1)   cout<<" ";
	}

	return 0;

}


main()
{
	char str[1000];
	gets(str);
	int i=0;int j=0;char morning;
	int k=strlen(str); int dream=k-1;
	while(i<=dream)
	{
	 morning=str[i];str[i]=str[dream];str[dream]=morning;i++;dream--;

	}
	j=0;int m;int y;
	while(j<=k-1)
	{
        m=j;
		while(str[j]!=' '&&j<=k-1) j++;y=j-1;
		while(m<=y){morning=str[m];
		    	str[m]=str[y];
		str[y]=morning;
		m++;y--;}
        j++;
	}
	for(i=0;i<=k-1;i++)cout<<str[i];
}


char str[101][101];
int n=1;
int main(){
	while (cin>>str[n]) n++;
	for (n--;n>1;n--) cout<<str[n]<<' ';
	cout<<str[1];
	return 0;
}


int main ()
{
	char str[100][100], ch;
	int n=0, i;
	for (i=0; ; i++)
	{
		scanf ("%s", &str[i]);
		n++;
		if ((ch=getchar())=='\n') break;
	}
	for (i=n-1; i>=0; i--)
	{
		printf ("%s", str[i]);
		if (i>0) printf (" ");
		else break;
	}
	return 0;
}


int main ()
{

	char temp[10000], word[100][20];
	cin.getline(temp,1000);
	int space[100] = {0}, i, num_of_space = 0, j,k, end;

	for (i = 0; temp[i] != '\0'; i++)
		;
	end = i;	//	?????
	for (i = 0; i < end; i++) //??????
	{
		if (temp[i]==' ')
		{
			num_of_space ++ ;
			space[num_of_space] = i;

		}
	}

	if (num_of_space != 0)
	{
	for (i = 0; i < space[1]; i++)
	{
		word[0][i] = temp[i];
	}
	word[0][i] = '\0';

	for (i = 1; i < num_of_space; i++)
	{
		for (j = 0; space[i]+j+1 < space[i+1];j++)
		{
			word[i][j] = temp[space[i]+j+1];
		}
		word[i][j] = '\0';
	}

	for (i = space[num_of_space]+1 ; i < end; i++)
		word[num_of_space][i-space[num_of_space]-1] = temp[i];

	word[num_of_space][i-space[num_of_space]-1] = '\0';

	cout << word[num_of_space];

	for (i = num_of_space-1; i >=0; i--)
		cout << ' '<<word[i];

	cout << endl;
	}

	else
		cout << temp << endl;

    return 0;
}


char s[110];
void operate(){
	int pre = strlen(s);
	int len = pre;
	for(int i=len-1;i>=0;i--){
		//???????????
		if(s[i]==' '){
			for(int j=i+1;j<pre;j++){
				cout<<s[j];
				}
			cout<<" ";
			pre = i;
			}
		}
	for(int j=0;j<pre;j++){
		cout<<s[j];
		}
	return;
	}
int main(){
	cin.getline(s,110);
	operate();
	return 0;
	}


void main()
{
    char ch1[100],ch2[100];

    unsigned int i,j,s,k=0,chang;
	gets(ch1);
    s=strlen(ch1);
    for(i=0;i<100;i++)
{
    ch2[i]='\0';
}

for(i=0;i<s;i++)
	{
		if (ch1[i]==' ')
		{
		chang=i-k;
		 for (j=0;j<chang;j++)
		 {  ch2[s-chang-k+j]=ch1[k+j];
		 if (j==chang-1) ch2[s-chang-k-1]=' ';}
		k=i+1;
		}

	}
         chang=i-k;
		 for (j=0;j<chang;j++)
		   ch2[s-chang-k+j]=ch1[k+j];

    printf("%s",ch2);
}


void main()
{
	char *p[100],end='\n';
	int i,count;
	for(i=0;;i++)
	{
		p[i]=(char *)malloc(20*sizeof(char));
		scanf("%s",p+i);
		if(end==getchar())
		{
			count=i;
			break;
		}
	}
	for(i=count;i>0;i--)
		printf("%s ",p+i);
	printf("%s",p+i);
}


int main()
{
	char s[200];
	int num,i,lens,max,min,w1,w2,len[200]={0},beg[200],j;
	gets(s);
	num=1;
	beg[1]=0;
	lens=strlen(s);
	for (i=0;i<lens;i++)
	{
		if(s[i]==' ')
		{
			num++;
			beg[num]=i+1;
			len[num]=-1;
		}
		len[num]++;
	}

	for(i=num;i>1;i--)
	{
		for (j=beg[i];j<beg[i]+len[i];j++)
	          printf("%c",s[j]);
		printf(" ");
	}
	for (j=beg[1];j<beg[1]+len[1];j++)
	          printf("%c",s[j]);

	return 0;
}


int main()
{
	char str[100];
	int n,i,j,k;
	gets(str);
	n=strlen(str);
	k=n;
	for (i=n-1;i>=0;i--)
	{
		if (str[i]==' ')
		{
			for (j=i+1;j<k;j++)
				printf("%c",str[j]);
			k=i;
			printf(" ");
		}
	}
	for (j=0;j<k;j++)
		printf("%c",str[j]);
}


int main()
{
	char str[100];
	int i,k,j;
	gets(str);
	i=strlen(str)-1;
	for(j=i,k=i;i>=0;i--)
	{
		if(str[i]==' '||i==0)
{
			j=i;
			if(i==0)
				for(;i<=k;i++)
					printf("%c",str[i]);
			else
				for(i=i+1;i<=k;i++)
					printf("%c",str[i]);
			if(j>0)
				printf(" ");
			i=j;k=j-1;
		}
	}
}


int main()
{
	char words[105]={0};
	int i=0,j=0,sum=0;
	cin.getline(words,101,'\n');
	while(words[i])
	{
		sum++;
		i++;
	}
	for(i=(sum-1);i>=0;i--)
	{
		if(words[i]==' ')
		{
			for(j=i+1;j<=(sum-1);j++)
			{
				if(words[j]==' ') break;
				cout<<words[j];
			}
			cout<<" ";
		}
	}
	for(i=0;i<sum;i++)
	{
		if(words[i]==' ')break;
		cout<<words[i];
	}
	cin.get();cin.get();
	return 0;
}


int main()
{
	char ch;
	char out[100][100];
	int len=0,count=0;
	while(cin.get(ch))
	{
		if(ch=='\n')
			break;
		else if(ch==' ')
		{
			out[len][count]='\0';
			len++;
			count=0;
		}
		else
		{
			out[len][count]=ch;
			count++;
		}
	}
	out[len][count]='\0';
	for(int i=len; i>=0; i--)
	{
		cout<<out[i];
		if(i)
			cout<<" ";
	}
	cout<<endl;
	return 0;
}


void main()
{

    int strNnum=0,strMnum=0,max,min,maxstr=0,minstr=0,i,len;
    char string[50][15],ch;

    while((ch=getchar())!='\n')
	{
     if(strMnum!=0&&(ch==' '))
	 {
       string[strNnum][strMnum]='\0';
       strNnum++;strMnum=0;
	 }
     else
      if(ch!=' ')
	  {
        string[strNnum][strMnum]=ch;
        strMnum++;
	  }
	}
    string[strNnum][strMnum]='\0';
	for(i=strNnum;i>0;i--)
		printf("%s ",string[i]);
	printf("%s",string[0]);

}


void main()
{
	char c;
	int i=0,j,k,t;
	char str[30][30];
	do
	{
		scanf("%s",str[i]);
		i++;
	}while((c=getchar())!='\n');
	t=i;
	printf("%s",str[t-1]);
	for(i=t-2;i>=0;i--)
	printf(" %s",str[i]);
}


char a[100];
int i,j,lenth;
char *flag1,*flag2;
char *start=a;
char *move;

void print()
{
	char *p;
	if(move!=start)
	{
		for(p=flag1+1;p<flag2;p++)
			printf("%c",*p);
		printf(" ");
	}

	else
	{for(p=flag1;p<flag2;p++)
	printf("%c",*p);}
}

void main()
{
	gets(a);

	lenth=strlen(a);
	move=a+lenth-1;

	for(flag1=move+1;move>=start;move--)
	{
		if(*move==' '||move==start)
		{
			flag2=flag1;
			flag1=move;
			print();
		}

	}

}


int main() {
	char input[101];
	cin.getline(input,101);
	int inputlen=strlen(input);
	int sumblank=0;
	for (int i=0;i<=inputlen-1;++i)
	{
		if (input[i]==' ')
			++sumblank;
	}
	char word[100][101];
	int i=0;
	int k=0;
	for (int j=0;j<=inputlen-1;++j)
	{
		if (input[j]==' ')
		{
			++i;
			k=0;
		}
		else
		{
			word[i][k]=input[j];
			++k;
		}
	}
	for (int i=sumblank;i>=0;--i)
	{
		if (i==sumblank)
			cout <<word[i];
		else
			cout <<" "<<word[i];
	}

	return 0;
}


void main()
{
	char *a[100],c='\n';int i;
	for(i=0;;)
	{
		a[i]=(char *)malloc(100*sizeof(char));
		scanf("%s",a[i]);i++;
		if(c==getchar()) break;
	}
	for(i=i-1;i>=0;i--)
	if(i!=0) printf("%s ",a[i]);
	else printf("%s",a
		[i]);
}


void main()
{
	char string[100];
	int i,j,num=0,word=0;
	int a[100];//???????????????string????
	gets(string);
	for(i=0,j=0;string[i]!='\0';i++)
	{
		if(string[i]==' ')
		{
			word=0;
		    a[j]=i;
			j++;
		}
		else if(word==0)
		{
			word=1;
			num++;
		}
	}
	if(num>1)
	{
		for(i=a[j-1]+1;string[i]!='\0';i++)
		printf("%c",string[i]);
	    while(j>=2)
		{
		   for(i=a[j-2];i<a[j-1];i++)
		   printf("%c",string[i]);
		   j--;
		}
		printf(" ");
	    for(i=0;i<a[0];i++)
		printf("%c",string[i]);
	}
	else
		puts(string);
}


int main()
{
    char s[100], temp;

    gets(s);

    for (int i = 0, j = strlen(s) - 1; i < j; i++, j--) {
        temp = s[i];
        s[i] = s[j];
        s[j] = temp;
    }

    int low = 0, high = 0;
    for (int i = 0; i <= strlen(s); i++) {
        if (s[i] == ' ' || s[i] == '\0') {
            low = high;
            high = i - 1;

            for (; low < high; low++, high--) {
                temp = s[low];
                s[low] = s[high];
                s[high] = temp;
            }
            high = i + 1;
        }
    }
    cout << s << endl;
    return 0;
}


int main()
{char str[101];
int i,j,temp,count=1;
cin.getline(str,101);
for(i=strlen(str);i>=0;i--)
	{
	if((str[i]==' ')&&(count!=1)){for(j=i+1;j<temp;j++)cout<<str[j];
    cout<<" ";
	temp=i;}
	if((str[i]==' ')&&(count==1)){temp=strlen(str);
	                              for(j=i+1;j<temp;j++)cout<<str[j];cout<<" ";//??????????????
	                                count=2;temp=i; }
	}
for(i=0;i<strlen(str);i++){cout<<str[i];if(str[i+1]==' ')break;}//????????????

	return 0;
}


void main()
{
	char str[100],*pstr,*x;
	char a[100],*pa;
	int n;
	gets(str);
	n=strlen(str);
	pstr=str+n-1;
	pa=a;
	for(;pstr>=str;pstr--)
	{
		if(*pstr==' ')
		{
			x=pstr;
			pstr++;
			for(;*pstr!=' '&&*pstr!='\0';pstr++)
			{
				*pa=*pstr;
				pa++;
			}
			*pa=' ';
			pa++;
			pstr=x-1;
		}
	}
	pstr=str;
	for(;*pstr!=' '&&*pstr!='\0';pstr++)
	{
		*pa=*pstr;
		pa++;
	}
	for(pa=a;pa<a+n;pa++)
		printf("%c",*pa);
}


void main()
{
	char a[20][20],temp[10];
	int n=0,i,j;
	while(scanf("%s",a[n])!=EOF)n++;
	i=0;j=n-1;
	do
	{strcpy(temp,a[i]);
	strcpy(a[i],a[j]);
	strcpy(a[j],temp);
	i++;j--;}
	while(i<=j);
	printf("%s",a[0]);
	for(i=1;i<n;i++)
		printf(" %s",a[i]);
}


void main()
{
	char *s,*p,*r;
	s=(char *)malloc(100*sizeof(char));
	gets(s);
	p=s+strlen(s)-1;
	for (;p>=s;p--)
	{
		if (*p==' ')
		{
			r=p+1;
			printf("%s ",r);
			*p='\0';
		}
		if (p==s) printf("%s",p);
	}
}


void main()
{
char str[100];
int i,j,a;
gets(str);
a=strlen(str);
for(i=strlen(str)-1;i>=0;i--)
   {
	if(str[i]==' ')
	{for(j=i+1;j<a;j++)
	 printf("%c",str[j]);
	 printf(" ");
	 a=i;
	}
   }
for(i=0;i<strlen(str);i++)
if(str[i]==' ')break;
for(j=0;j<i;j++)
printf("%c",str[j]);
}


int main()
{
    char string1[100],string2[100];
    char str[100][100];
    int i=0,j=0,k=0;
    char c;
    gets(string1);
    for(i=0;(c=string1[i])!='\0';i++)
    {
           if(c!=' ')
         {
            str[j][k]=string1[i];
            k++;
         }
         else if(c==' ')
         {
            j++;
            k=0;
         }

    }
    strcpy(string2,"");
    for(i=j;i>0;i--)
    {
        strcat(string2,str[i]);
        strcat(string2, " ");
    }
    strcat(string2,str[0]);
    printf("%s",string2);
}


char str[100];
char word[100][100];
char a[1];

void main(){
    int i = 0;
    int j;
    char* p;
    gets(str);

    for(p = str;p-str < strlen(str);p ++){
        if(*p != ' '){
            a[0] = *p;
            strcat(word[i],a);
        }
        else
            i++;
    }

    for(j = i;j>0;j--)
        printf("%s ",word[j]);
        printf("%s",word[0]);
}


void main()
{
	char (*str)[100];
	char substr[100][100];
	int m=0,i;
	for(i=0;;i++)
	{
		scanf("%s",substr[i]);
		m=m+1;
		if(getchar()=='\n') break;
	}
	str=substr;
	for(i=m-1;i>0;i--)
		printf("%s ",str[i]);
	printf("%s",str[0]);
}


int main()
{
	char st[200],word[50][50]={""};
	gets(st);
	int i,j=0,l,number=0;
	l=strlen(st);

	for(i=0;i<l;i++)
	{
		if(st[i]!=' ')
			word[number][j++]=st[i];
		else if(st[i]==' '&&st[i+1]!=' ')
		{
			word[number++][j]='\0';
			j=0;
		}
	}
	word[number][j]='\0';
	for(i=number;i>0;i--)
	{
		printf("%s",word[i]);
		printf(" ");
	}
	printf("%s",word[0]);
	return 0;
}


int main()
{
    char str[200],*p,*q,*r,ans[200];
    int len,i;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    gets(str);
    len=strlen(str);
    for (p=str+len;p>str;p--)
        *p=*(p-1);
    *p=' ';*(p+len+1)=' ';
    for (p=str+len+1,r=ans;p>=str;)
    {
        q=p-1;
        while (*q!=' ') q--;
        for (i=1;q+i<=p;i++)
            *r++=*(q+i);
        p=q;
    }
    for (i=0;i<len;i++) printf("%c",*(ans+i));
    return 0;
}


void main()
{
	char s[200];
	gets(s);
	int len=strlen(s),i,j,temp=len-1;
	for(i=len-1;i>=0;i--)
	{
		if(s[i]==' ')
		{
			for(j=i+1;j<=temp;j++)
				putchar(s[j]);
			putchar(s[i]);
			temp=i-1;
		}
		else
			if(i==0)
			{
				for(j=i;j<=temp;j++)
					putchar(s[j]);
			}

	}
}


int main()
{
	char str[100];
	int space[100], num = 1;
	cin.getline(str,100);
	space[0] = strlen(str);
	str[space[0]] = ' ';
	for(int i = space[0] - 1; i >= 0; i--)
		if(str[i] == ' ')
		{
			for(int j = i + 1; j <=space[num-1 ]; j++)
				cout << str[j];
			space[num++] = i;
		}
	for(int k = 0; k < space[num - 1]; k++)
		cout << str[k];
	return 0;
}


void f(int t){
char c[100];
if(scanf("%s",c)!=EOF){f(0);

cout<<c;if(!t)cout<<' ';}
}
int main(){
f(1);

return 0;
}


int main()
{
	char input[100],output[100][100];
	int i=0,count=0,n=0;
    cin.getline(input,101,'\n');
	while (input[i]!=0)
	  {
		 if (input[i]!=' ')
		   {
			   output[count][n]=input[i];
			   n++;
		   }
		 else {
				 output[count][n]=0;
				 count++;
				 n=0;
		      }
		 i++;
	  }

	for (i=count;i>0;i--)
		cout <<output[i] <<" ";
	cout <<output[0];

	return 0;
}


void main()
{
  char mystr[100],c;
  int a[100],i,j,k;
  gets(mystr);
  for(i=0,j=1;i<strlen(mystr);i++)
  {
     if(mystr[i]==' ')
     {
		 a[j]=i;
         j++;
	 }
  }
  a[0]=-1;
  a[j]=strlen(mystr);
  for(k=strlen(mystr)-1;k>=0;k--)
  {

      if(k==a[j-1])
	   {
		   printf(" ");
		   j=j-1;
	   }
	  else

	  {c=mystr[a[j]+a[j-1]-k];
	  printf("%c",c);}

  }

}


int main()
{
    char word[100][100];
   int i=0,j=0,k=0;
   char f[100];
   cin.getline(f,100);
   for(i=0;i<strlen(f);i++)
   {
       if(f[i]==' '){k++;j=0;continue;}
       word[k][j]=f[i];
       j++;
   }
   for(i=k;i>0;i--)
      cout<<word[i]<<" ";
      cout<<word[0]<<endl;
   return 0;
}


int main(){
	char words[MAX][50],m='i';
	int LEN=0;
	while(m!='\n'){
		cin>>words[LEN];
		LEN++;
		cin.get(m);
	}
	for(int i=0;i<LEN-1;i++) cout<<words[LEN-i-1]<<' ';
	cout<<words[0];
	return 0;
}


int main()
{
	char s[150],*p;
	int len,l;
	gets(s);
	len=strlen(s);

	for(l=0,p=s+len-1;p>=s;p--)
	{
		if(*p==' ')
		{
			if(l)
			{
				l=0;
				*p=0;
				printf("%s ",p+1);
			}
		}
		else
			l++;
	}
	if(l)
		printf("%s\n",s);
	return 0;
}


void main()
{
	char a[101];
	int indexa,indexb,i;
	gets(a);

	indexb=strlen(a)-1;
	while(indexb>0&&a[indexb]==' ')
		indexb--;

	if(indexb==0&&a[indexb]==' ')
		indexb--;

	indexa=indexb-1;
	int num=0;
	while(indexa>=0)
	{
		if(a[indexa]!=' ')
			indexa--;
		else
		{
			if(num!=0)
				printf(" ");
			num++;
			for(i=indexa+1;i<=indexb;i++)
				printf("%c",a[i]);
			indexb=indexa-1;
			while(indexb>0&&a[indexb]==' ')
				indexb--;
			if(indexb==0&&a[indexb]==' ')
				indexb--;
			indexa=indexb-1;
		}
	}

	if(indexb>=0)
	{
		if(num!=0)
				printf(" ");
		num++;
		for(i=0;i<=indexb;i++)
			printf("%c",a[i]);
	}
	printf("\n");
}


void main()
{
	char *str,*p,*q,*temp;
	int n,i;
	str=(char*)calloc(128,sizeof(char));
	gets(str);
	n=strlen(str);
	for(i=n-1;i>=0;i--)
	{
		*(str+i+1)=*(str+i);
	}
	*str='\0';
	p=q=str+n;
	while(1)
	{
		if(*p!=' '&&*p!='\0')
		{
			p--;
			continue;
		}
		if(*p==' '||*p=='\0')
		{
			for(temp=p+1;temp<=q;temp++)
				printf("%c",*temp);
			if(*p!='\0')
				printf(" ");
			else
				break;
			p--;
			q=p;
			continue;
		}
	}
}


void main()
{
    char ch1[100],ch2[100];
    unsigned int i,j,s,k=0,chang;
	gets(ch1);
    s=strlen(ch1);
	for(i=0;i<s;i++)
	{
		if (ch1[i]==' ')
		{
		chang=i-k;
		 for (j=0;j<chang;j++)
		 {  ch2[s-chang-k+j]=ch1[k+j];
		 if (j==chang-1) ch2[s-chang-k-1]=' ';}
		k=i+1;
		}

	}
         chang=i-k;
		 for (j=0;j<chang;j++)
		 ch2[s-chang-k+j]=ch1[k+j];

		 ch2[s]='\0';

    puts(ch2);
}


int main ()
{
    int n=0;
    char words[100][100],temp;
    do
    {
         cin>>words[n];
         n++;
         temp=getchar();
    }while (temp!='\n');
    for (int i=1;i<=n-1;++i)
        cout<<words[n-i]<<" ";
    cout<<words[0]<<endl;
    return 0;
}


int main()
{
    char words[100][100],gt;
    int m;
    for(int i=0;i<100;i++)
    {
        cin>>words[i];
        gt=getchar();
        if(gt=='\n')
        {
            m=i;
            break;
        }
    }
    for(int i=m;i>0;i--)cout<<words[i]<<' ';
    cout<<words[0];
    return 0;
}


int main()
{
	char str[100];
	int end,begin,len,i,j;
	gets(str);
	len=strlen(str);
	end=len-1;
	for (i=len;i>=0;i--)
		if (str[i]==' ' || i==0)
		{
			if (i==0)
				begin=0;
			else
				begin=i+1;
			for (j=begin;j<=end;j++)
				printf("%c",str[j]);
			if (i!=0)
				printf(" ");
			end=i-1;
		}
	printf("\n");
	return 0;
}


int main()
{
    char c[100];
    gets(c);
    int l,j;
    l=strlen(c);
    int i,t;
    t=l;
    for(i=l-1;i>=0;i--)
    {
               if (c[i]==' ')
                  {
                           for(j=i+1;j<t;j++)
                           {
                                             printf("%c",c[j]);
                           }
                           printf(" ");
                           t=i;
                  }
    }
    for(i=0;i<l;i++)
    {
                 if(c[i]==' ')
                 break;
                 else
                 printf("%c",c[i]);
    }
    getchar();
    getchar();
}


int main()
{
	char str[101],str1[101]={'a'};
	int len,i,j,a,k,b=0;
	gets(str);
	len=strlen(str);
	for(j=0;j<len;j++)
		if(str[j]==' ')
			break;
	if(j==len)
		printf("%s",str);
	else

	{
		for(j=len-1;j>=0;j--)
		if(str[j]==' ')
		{	j--;
		continue;}
	else break;
	for(i=j;i>=0;i--)
		if(str[i]==' ')
		{
			a=i;
			for(j=i+1,k=b;(str[j]!=' ')&&(j<len);j++,k++)
				str1[k]=str[j];
			str1[k]=' ';
			b=k+1;
		}

	for(i=0;i<a;i++,k++)
       str1[k+1]=str[i];
    printf("%s",str1);

	}
	return 1;
}


/*
 *  Name:andian.cpp
 *
 *  Created on: 2012-11-05
 *  Author: ??
 *  Function?????
 */

int main()
{
	char a[100];
	int i, j, length, flag;
	cin.getline(a,100);
	length=strlen(a);
	flag=length;
	for (i=length-1;i>=0;i--){
		if (a[i]==' '){
			if (flag!=length)
				cout<<' ';
			for (j=i+1;j<=flag-1;j++){
				cout<<a[j];
			}
			flag=i;
		}
		if (i==0){
			if(flag!=length)
				cout << ' ';
			for (j=0;j<=flag-1;j++){
				cout<<a[j];
			}
		}
	}
	return 0;
}


int main()
{
	char word[100];
	int i,p=0,k=0,flag=0;
	while(cin.getline(word,100))
	{
		for(i=0;i<100;i++)
		{
			if(word[i]!='\0')p=i;
			else break;

		}
		for(i=0;i<=p;i++)
		{
			if(word[i]==' ')
				flag=1;
		}
			if(flag==0)
			{
				for(i=0;i<=p;i++)
					cout<<word[i];
			}
			else
		{for(i=p;i>=0;i--)
		{
			if(word[i]!=' ')
				k++;
			else
			{
				for(int j=i+1;j<=i+k;j++)
					cout<<word[j];
				cout<<" ";
				k=0;
			}
		}
		for(i=0;i<100;i++)
		{
			if(word[i]!=' ')
				cout<<word[i];
			else break;
		}}
	}
	return 0;

}


char s[105];
int main(){
	cin.getline(s,sizeof(s));
	for(int i = strlen(s) - 1;i >= 0;i --){
		for(int j = i;j >= 0;j --){
			if(s[j] == ' '){
				cout << &s[j+1] << ' ';
				s[j] = '\0';
				i = j - 1;
				break;
			}
		}
	}
	cout << s << endl;
	return 0;
}


void main()
{
	char string[100],ch[100][100];
	int length[100]={0};
    gets(string);
	int L=strlen(string);
	int i,j=0,k=0,sum;
	for(i=0;i<L;i++)
	{
			if(string[i]==' ')
			{
			    j++;
				length[j]++;
				k=0;
				ch[j][k]=' ';
				k++;

			}

			if(string[i]!=' ')
			{
				length[j]++;
				ch[j][k]=string[i];
				k++;

			}

	}
	sum=j;
	if(sum!=0)
	for(k=1;k<length[sum];k++)
		printf("%c",ch[sum][k]);

	for(j=sum-1;j>=1;j--)
	{
        for(k=0;k<length[j];k++)
			printf("%c",ch[j][k]);
	}
	if(sum!=0)
	printf(" ");
	for(k=0;k<length[0];k++)
		printf("%c",ch[0][k]);

}


void main()
{
	int len,i,j,k,label;
	char ss[101];
	gets(ss);
	len=strlen(ss);
	for (i=0;i<len;i++)
	{
		if (ss[i]==' ')
		{
			label=i;
			break;
		}
		if (i=len-1)
			label=len;
	}
	i=len-1;
	while(i>=0)
	{
		for (j=i;j>=0;j--)
			if (ss[j]==' ')
				break;
		for (k=j+1;k<=i;k++)
			printf("%c",ss[k]);
		//if (i!=label-1 && label!=len)
		//	printf(" ");
		if (j>=0)
        printf("%c",ss[j]);
		i=j-1;
	}
}


int main()
{
	char a[101];
	cin.getline(a,100);
	char b[100][150];
	int sum=0,i=0,j=0;
	for(i=0;i<strlen(a);i++)
	{
		if(a[i]==' ')
		{
			sum=sum+1;
			j=0;
			continue;
		}
		else
		{
			b[sum][j]=a[i];
			j=j+1;
		}
	}
	cout <<b[sum];
	for(i=sum-1;i>=0;i--)
		cout <<" " <<b[i];
	cout <<endl;
	return 0;
}


void main()
{
	char *p[300];
	int i=0,k;
	p[i]=(char*)malloc(30*sizeof(char));
	while(scanf("%s",p[i])!=EOF)
	{
		i++;
		p[i]=(char*)malloc(30*sizeof(char));
	}
	k=i-1;
	for(i=k;i>=0;i--)
	{
		if(i==k) printf("%s",p[i]);
		else printf(" %s",p[i]);
	}
}


int main ()
{
    char str[100];
	int n,i,a,j;
	gets(str);
	n=strlen(str);
	a=n-1;
	for(i=n-1;i>0;i--)
		if(str[i]==' ')
		{
			for(j=i+1;j<=a;j++)
				printf("%c",str[j]);
			    printf("%c",str[i]);
			a=i-1;
		}
	for(i=0;i<a+1;i++)
		printf("%c",str[i]);
}


int main()
{
	char str[200];
	gets(str);
	int n=strlen(str);
	int i,j,c[50],d=0;
	c[0]=n;
	for(i=n-1;i>=0;i--)
		if(str[i]==' ')
		{
			d++;
			c[d]=i;
			for(j=i+1;j<c[d-1];j++)
				putchar(str[j]);
            printf(" ");
		}
	for(i=0;i<c[d];i++)
		putchar(str[i]);
}


int main()
{
	int num=0,i=0;
	char c,st[100][100];
	while(1)
	{
		cin>>st[i];
		i++;
		num++;
		c=cin.get();
		if(c==' ')
			continue;
		break;
	}
	for(i=num-1;i>0;i--)
	{
		cout<<st[i]<<" ";
	}
	cout<<st[0]<<endl;
	return 0;
}


int main()
{
    int i=0,j=0,flag,len;
    char s[100];
    char temp[100];

    gets(s);
    flag=strlen(s);

    for(i=strlen(s)-1;i>=0;i--)
     if(s[i]==' ')
      {
      len=flag-i;
      for(j=i+1;j<flag;j++)
      printf("%c",s[j]);
      printf(" ");
      flag=i;
      }
    for(j=0;j<flag;j++)
    printf("%c",s[j]);
}


int main(){
	char temp[100];
	int i=0,k,left[100],right[100],space=0;
	cin.getline(temp,100);
	left[0]=0;
	for(k=0;k<=strlen(temp);k++)
	{
		if((temp[k]==' ')||(temp[k]=='\0')){
			space++;
			right[i]=k-1;
			i++;
			left[i]=k+1;
		}
	}
	for(i=space-1;i>=0;i--)
	{	if(i!=space-1) cout<<' ';
		for(k=left[i];k<=right[i];k++)
			cout<<temp[k];
	}
}


void main()
{
	char str1[100],*start,*space,*pri;
	gets(str1);
	start=str1-1;
	for(space=str1+strlen(str1)-1;space>=start;space--)
	{
		if(*space==' ')
		{
			for(pri=space+1;(*pri!=' ')&&(pri!=str1+strlen(str1));pri++)
			{
			   printf("%c",*pri);
			}
			printf(" ");
		}
		if(space==start)
        {
			for(pri=space+1;(*pri!=' ')&&(pri!=str1+strlen(str1));pri++)
			{
			   printf("%c",*pri);
			}
		}
	}
}


void main()
{
	int n=0,i,l;
	char t,word[101],*p;
	gets(word);
	l=strlen(word);
	word[l]='\0';
	for(i=0;i<l;i++)
		if(word[i]==' ')
			word[i]='\0';
	p=word+l-1;
	while(p!=word)
	{
		if(*p=='\0')
		{
			printf("%s ",p+1);
		}
		p--;
	}
	printf("%s\n",p);
}


char swap(char str[100])
{
    int n,i,j;
    n=strlen(str);
    for(i=n-1;i>=0;i--)
    if(str[i]==' ') break;
    for(j=i+1;j<n;j++) printf("%c",str[j]);
    if(i>0)
    {
    printf(" ");
    str[i]='\0';
    swap(str);
    }
}
int main()
{
    char str[101];
    gets(str);
    swap(str);
}


int main(int argc, char* argv[])
{
	char w[1000],ws[50][20]={0};
	int i,j=0,k=0;
    gets(w);
    int len=strlen(w);
	for(i=0;i<len;i++){
		if(w[i]!=' '){
			ws[j][k]=w[i];
			k++;
		}
		else if(w[i]==' '){
			j++;
			k=0;
		}
	}
	int min=strlen(ws[0]),max=strlen(ws[0]);
	int minw=0,maxw=0;
	for(i=1;i<=j;i++){
		if(min>strlen(ws[i])){
			min=strlen(ws[i]);
			minw=i;
		}
		if(max<strlen(ws[i])){
			max=strlen(ws[i]);
			maxw=i;
		}
	}
	printf("%s\n",ws[maxw]);
	printf("%s\n",ws[minw]);
	return 0;
}


void main()
{
	int m=0,n=10000,l;
	char *max,*min,*s,b;
	max=(char *)malloc(100*sizeof(char));
	min=(char *)malloc(100*sizeof(char));
	s=(char *)malloc(100*sizeof(char));
	for (;;)
	{
		scanf("%s",s);
		l=strlen(s);
		if (l<n)
		{
			strcpy(min,s);
			n=l;
		}
		if (l>m)
		{
			strcpy(max,s);
			m=l;
		}
		b=getchar();
		if (b!=' ') break;
	}
	printf("%s\n%s\n",max,min);
}


void main()
{
	char a[50][30];
	int i,count,m=0;
	for(i=0;;i++)
		if(scanf("%s",a[i])==EOF)
		{
			count=i;
			break;
		}
	for(i=0;i<count;i++)
		m=max(strlen(a[i]),m);
	for(i=0;i<count;i++)
		if(strlen(a[i])==m)
		{
			printf("%s\n",a[i]);
			break;
		}
	for(i=0;i<count;i++)
		m=min(strlen(a[i]),m);
	for(i=0;i<count;i++)
		if(strlen(a[i])==m)
		{
			printf("%s\n",a[i]);
			break;
		}
	putchar(10);
}


int main()
{
	char word[2000];
	int length[200] = {0}, location[200], leap = 0, i, j = 0, max = 0, min = 2000, location1, location2;
	cin.getline(word, 2000);
	for (i = 0; i < 200; i++)
		location[i] = -1;
	i = 0;
	while (word[i] != '\0')
	{
		if ((word[i] == ' '|| word[i] == ',') && leap)
		{
			leap = 0;
			j++;
		}
		else if (word[i] != ' ' && word[i] != ',' && !leap)
		{
			leap = 1;
			location[j] = i;
			length[j]++;
		}
		else if (word[i] != ' ' && word[i] != ',' && leap)
			length[j]++;
		i++;
	}
	for (i = 0; i < 200; i++)
		if (length[i] > 0 && location[i] > -1)
		{
			if (length[i] > max)
			{
				max = length[i];
				location1 = i;
			}
			if (length[i] < min)
			{
				min = length[i];
				location2 = i;
			}
		}
	for (i = location[location1]; i < location[location1] + length[location1]; i++)
		cout << word[i];
	cout << endl;
	for (i = location[location2]; i < location[location2] + length[location2]; i++)
		cout << word[i];
	return 0;
}


void main()
{
	char *a,*p,*max,*min;
	int i,j,k,m,n,t,ma=0,mi=10000;
	a=(char *)malloc(1000*sizeof(char));
	p=(char *)malloc(1000*sizeof(char));
	max=(char *)malloc(1000*sizeof(char));
	min=(char *)malloc(1000*sizeof(char));
	gets(a);
	n=strlen(a);
	p=a;
	for(;;a++)
	{
		if(*a==' '||*a=='\0')
		{

			m=a-p;
			if(m>ma)
			{
				ma=m;
				max=p;
			}
			if(m<mi)
			{
				mi=m;
				min=p;
			}
			if(*a=='\0')break;
			p=a+1;
		}
	}
	for(i=0;*(max+i)!=' '&&*(max+i);i++)
		printf("%c",*(max+i));
	printf("\n");
	for(i=0;*(min+i)!=' '&&*(min+i);i++)
		printf("%c",*(min+i));
	printf("\n");

}


int main(){
char a[50][50]={'0'};
char b;
int max=0,min=0,i;
for(i=0;;i++){
scanf("%s",a[i]);
scanf("%c",&b);
if(b==10)
break;
}
for(i=0;i<50;i++){
if(strlen(a[i])>strlen(a[max]))
max=i;
if(strlen(a[i])<strlen(a[min])&&strlen(a[i])!=0)
min=i;
}
printf("%s\n%s",a[max],a[min]);
return 0;
}


void main()
{
	char string[1000]={0};
	char str[100][100]={0};
	char *p;
	char num[100]={0};
p=num;
int i,j,k,n,m;
gets(string);
n=0;k=0;
for(i=0;string[n]!='\0';i++)
{ for(j=0;string[n]!='\0'&&string[n]!=' ';j++)
   {
   str[i][j]=string[n];
   n++;
   }
  str[i][j]='\0';
  n++;
k++;}

m=strlen(str[0]);
p=str[0];
for(i=0;i<k;i++)
  if(m<strlen(str[i]))
  {m=strlen(str[i]);
  p=str[i];}

printf("%s\n",p);

m=strlen(str[0]);
p=str[0];
for(i=0;i<k;i++)
  if(m>strlen(str[i]))
  {m=strlen(str[i]);
  p=str[i];}

printf("%s",p);
}


int main()
{
	char zfc[1000];
	gets(zfc);
	int k=strlen(zfc);
	int i;
	int count=0;
	int p;
	int min1=0,min=1000,max=0,max1=0;
	for (i=0;i<k;i++)
	{
		if (zfc[i]!=32)
		{
			count=count+1;
		}
		else
		{
			if (max<count)
			{
				max=count;
				max1=i-1;
			}
			if (min>count)
			{
				min=count;
				min1=i-1;
			}
			count=0;
			p=i;
		}

	}
	count=k-1-p;
	if (max<count)
	{
				max=count;
				max1=i-1;
	}
			if (min>count)
	{
				min=count;
				min1=i-1;
	}

	for (i=max1-max+1;i<=max1;i++)
	{
		printf("%c",zfc[i]);
	}
	printf("\n");
	for (i=min1-min+1;i<=min1;i++)
	{
		printf("%c",zfc[i]);
	}
	return 0;
}


char minword[50]="\0";
char maxword[50]="\0";

void clear(int i)
{
	int j = 0;
	for ( j= 0; j < 50; j++) {
		if (i==0) {
			minword[j] = 0;
		} else {
			maxword[j] = 0;
		}
	}
}

int main()
{  char a[1001];
   char str[51];

   int max = 0, min = 100;
   int i,len=0,n;
   gets(a);
   n=strlen(a);
   a[n] = ' ';
   a[n+1] = '\0';

   for(i=0;i<n+1;i++)
   {
	     str[len]=a[i];
		 len++;
         if(a[i]==' '){
			 str[len-1]='\0';
		     len=0;
			 //printf("%s\n", str);
		 }

		 if(strlen(str)<min && !len)
		 {
			 min = strlen(str);
			 clear(0);
             strcpy(minword, str);
			 //printf("min=%d, %s\n",min, minword);
		 }
		 if(strlen(str)>max && !len)
		 {
			 max = strlen(str);
			 clear(1);
			 strcpy(maxword,str);
			 //printf("max=%d, %s\n",max, maxword);
		 }
   }
    printf("%s\n%s",maxword,minword);

	return 0;
}


main()
{
char sen[2000],word[300][20];
int n,j,i,t,len,max,min,p,q;
gets(sen);
len=strlen(sen);
n=1;
j=0;
for (i=0;i<=len-1;i++)
 { if (sen[i]!=' '&&sen[i]!=',') {word[n][j]=sen[i];
 	                              j++;}
   if (sen[i]==' ') {n++;j=0;}
   if (sen[i]==',') {i++;n++;j=0;}
 }
max=0;min=10000;
for (i=1;i<=n;i++)
 {
 	if (max<strlen(word[i])) {max=strlen(word[i]);p=i;}
    if (min>strlen(word[i])) {min=strlen(word[i]);q=i;}
 }
printf("%s\n",word[p]);
printf("%s",word[q]);
 }


void main()
 {
   char a[50][100],max[100],min[100];
int i,n;
   for(i=0;i<50;i++)
   {
     scanf("%s",a[i]);
     }
   n=i;strcpy(max,a[0]);strcpy(min,a[0]);
   for(i=0;i<n;i++)
{if(strlen(a[i])==0)break;
    if(strlen(max)<strlen(a[i]))strcpy(max,a[i]);
   if(strlen(min)>strlen(a[i]))strcpy(min,a[i]);
}
  printf("%s\n%s\n",max,min);
}


int main()
{
	int n,i,max,min;
	char s[200][50];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",s[i]);
	}
	max=strlen(s[0]);
	min=strlen(s[0]);
	for(i=0;i<n;i++)
	{
		if(strlen(s[i])>max)
			max=strlen(s[i]);
		if(strlen(s[i])<min)
			min=strlen(s[i]);
	}
	for(i=0;i<n;i++)
	{
		if(strlen(s[i])==max)
		{
			printf("%s\n",s[i]);
			break;
		}
	}
	for(i=0;i<n;i++)
	{
		if(strlen(s[i])==min)
		{
			printf("%s",s[i]);
			break;
		}
	}
	return 0;
}


int main()
{
    int min=0,max=0,minpl=0,maxpl=0,k;
    char a[2000]={0};
    gets(a);
    int l=strlen(a),i=0,j;
    for(j=0;a[i+j]!=' '&&a[i+j]!=','&&a[i+j]!=0;j++);
    max=min=j;

    for(i=j+1;i<l;i+=j+1)
    {
        for(j=0;i+j<l;j++)
            if(a[i+j]==' '||a[i+j]==','||a[i+j]==0)break;

        if(j>max){max=j;maxpl=i;}
        if(j<min&&j!=0){min=j;minpl=i;}
    }
    for(k=0;k<max;k++)putchar(a[maxpl+k]);

    printf("\n");
    for(k=0;k<min;k++)putchar(a[minpl+k]);

    printf("\n");

}


int main(){
	char a[50][50]={'0'},b;
	int i,max=0,min=0;
	for(i=0;i<50;i++){
		scanf("%s",a[i]);
		scanf("%c",&b);
		if(b==10){
			break;
		}
	}
	for(i=0;i<50;i++){
		if(strlen(a[i])>strlen(a[max])){
			max=i;
		}
		else if(strlen(a[i])<strlen(a[min])&&strlen(a[i])!=0){
			min=i;
		}
	}
	printf("%s\n%s",a[max],a[min]);
	return 0;
}


int main(){
	char max[50],min[50],a[50];
	int n,i;
	scanf("%d",&n);
	scanf("%s",max);
	strcpy(min,max);
	for(i=2;i<=n;i++){
		scanf("%s",a);
		if(strlen(a)>strlen(max)) strcpy(max,a);
		if(strlen(a)<strlen(min)) strcpy(min,a);
	}
	printf("%s\n",max);
	printf("%s\n",min);
	return 0;
}


int n=0,i,num[100]={0},t=0,max=0,min=50,begin=0,lon1=0,lon2,sho1=0,sho2;
char s[100],*p;

int main(){
    gets(s);
    p=s;
    while(*p!='\0'){
        if(*p!=' '){
            num[t]++;
        }
        else{

            if(num[t]>max){
                max=num[t];
                lon1=begin;
                lon2=n-1;
            }
            if(num[t]<min){
                min=num[t];
                sho1=begin;
                sho2=n-1;
            }
            begin=n+1;
            t++;
        }
        n++;
        p++;
    }
    if(*p=='\0'){
        if(num[t]>max){
                max=num[t];
                lon1=begin;
                lon2=n-1;
            }
            if(num[t]<min){
                min=num[t];
                sho1=begin;
                sho2=n-1;
            }
    }

    for(i=lon1;i<lon2;i++)
        printf("%c",s[i]);
    printf("%c\n",s[lon2]);
    for(i=sho1;i<sho2;i++)
        printf("%c",s[i]);
    printf("%c\n",s[sho2]);
scanf("%d",&n);
return 0;
}


int main()
{
	char word[20000];
	int longlen = 0, shortlen = 201, t = 0, i = 0, j[2], k = 0;
	cin.getline(word, 20000);
	while (word[i] != '\0')
	{
		while (word[i] != ' ' && word[i] != ',' && word[i] != '\0')
		{
			t ++;
			i ++;
		}
		if (t > longlen)
		{
			longlen = t;
			j[0] = i;
		}
		if (t < shortlen)
		{
			shortlen = t;
			j[1] = i;
		}
		while (word[i] == ' ' || word[i] == ',')
		{
			i ++;
			t = 0;
		}
	}
	for (i = j[0] - longlen; ; i ++)
	{
		if (word[i] == ' ' || word[i] == ',' || word[i] == '\0')
		{
			break;
		}
		cout << word[i];
	}
	cout << endl;
	for (i = j[1] - shortlen;; i ++)
	{
		if (word[i] == ' ' || word[i] == ',' || word[i] == '\0')
		{
			break;
		}
		cout << word[i];
	}
	cout << endl;
	return 0;
}


int main()
{
	char s[20000];
	char words[200][401];
	int s1=0,s2=0;
	gets(s);
	int n=0,k=0;
	for(int i=0;s[i]!=0;i++)
	{
		if(s[i]==' ')
		{
			s[i]='\0';
			strcpy(words[n],(s+k));
			n++;
			k=i+1;
		}
	}
	strcpy(words[n], (s + k));
    n++;
	int max=strlen(words[0]),min=strlen(words[0]);
	for(int j=1;j<n;j++)
	{
		int a=strlen(words[j]);
		if(a>max)
		{
			max=a;
			s1=j;
		}
		if(a<min)
		{
			min=a;
			s2=j;
		}
	}
	puts(words[s1]);
	puts(words[s2]);
	return 0;
}


int main()
{
	int n,i;
	int max,min,p,q;
	int len[200]={0};
	char word[200][20];
	scanf("%d", &n);
	getchar();
	for(i=0;i<n;i++)
	{
		scanf("%s",word[i]);
	}
    for(i=0;i<n;i++)
	{
		len[i]=strlen(word[i]);
	}
	max=len[0];p=0;
	min=len[0];q=0;
	for(i=0;i<n;i++)
	{
		if(len[i]>max)
		{
			max=len[i];
			p=i;
		}
		if(len[i]<min)
		{
             min=len[i];
			 q=i;
		}
	}
	printf("%s\n",word[p]);
	printf("%s\n",word[q]);
	return 0;
}


int main(int argc, char* argv[])

{
	int n,p,i,j,l,large,small;
	char a[50],max[50],min[50];
	large=0;
	small=50;
	scanf("%d",&n);

	{
			scanf("%s",&a);
			l=strlen(a);
			small=l;
			large=l;

				for(i=0;i<=l;i++)
				{
					min[i]=a[i];

				}
				for(i=0;i<=l;i++)
				{
					max[i]=a[i];

				}
		for(j=2;j<=n;j++)
		{
			scanf("%s",&a);
			l=strlen(a);
			if (l<small)
			{
				for(i=0;i<=l;i++)
				{
					min[i]=a[i];

				}
				small=l;
			}

			else if (l>large)
			{
				for(p=0;p<=l;p++)
				{
					max[p]=a[p];

				}

				large=l;
			}

		}

		for (i=0;i<=large-1;i++)
			printf("%c",max[i]);
		printf("\n");
		for (i=0;i<=small-1;i++)
			printf("%c",min[i]);
	}

	return 0;
}


int main()
{
	char min[50],max[50],s[1000];
	int i,len,len1=0,len2=50,count,k=0,j;
	gets(s);
	len=strlen(s);
	for(i=0;i<=len;i++)
	{
		if(s[i]==' '|| s[i]=='\0')
		{
			count=i-k;

			if(count>len1)
			{
				int l=0;
				for(j=k;j<i;j++)
				{
					max[l]=s[j];
					l++;
				}
				max[l]='\0';
				len1 = count;
			}
			if(count<len2&&count!=0)
			{
				int l=0;
				for(j=k;j<i;j++)
				{
					min[l]=s[j];
					l++;
				}
				min[l]='\0';
				len2 = count;
			}
			k=i+1;
		}
	}
	printf("%s\n",max);
	printf("%s",min);
	return 0;
}


int main()
{
	char s[1000];
	int len,t,i,start[1000],endd[1000],max,min;

	gets(s);
	len=strlen(s);
	t=1;
	start[1]=0;
	for(i=1;i<len;i++)
	{
		if(s[i]==' ')
		{
			endd[t]=i-1;
			if(s[endd[t]]==',') endd[t]--;
			t++;
			start[t]=i+1;
		}
	}
	endd[t]=len-1;
	max=1;min=1;
	for(i=2;i<=t;i++)
	{
		if(endd[i]-start[i]>endd[max]-start[max])
			max=i;
		if(endd[i]-start[i]<endd[min]-start[min])
			min=i;
	}
	for(i=start[max];i<=endd[max];i++)
		printf("%c",s[i]);
	printf("\n");
	for(i=start[min];i<=endd[min];i++)
		printf("%c",s[i]);
	printf("\n");

	return 0;
}


int main()
{
	int max=-1,min=9999999;
	char a[1000],b[1000],c[1000];
	while(cin>>a)
	{
		int l=strlen(a);
		if(max<l){
			max=l;
			strcpy(b,a);
		}
		if(min>l){
			min=l;
			strcpy(c,a);
		}
	}
	cout<<b<<endl<<c<<endl;
	return 0;
}


int main()
{
	char a[20000];
	char b[200][100];
	int c[200];
	cin.get(a,20000);

	int i = 0;
	int j = 0;
	int k = 0;
	while(a[i] != '\0')
	{
		if(a[i] == ' ' || a[i] == ',')
		{
			j++;
			k = 0;
		}
		else
			b[j][k++] = a[i];
		i++;
	}

	int max = strlen(b[0]); int maxpis = 0;
	int min = strlen(b[0]); int minpis = 0;
	for(i = 0 ; i < 200 ; i++ )
	{
		c[i] = strlen(b[i]);
		if(c[i] > max)
		{
			maxpis = i;
			max = c[i];
		}
		if(c[i] < min && c[i] > 0)
		{
			minpis = i;
			min = c[i];
		}
	}

	cout<<b[maxpis]<<endl;
	cout<<b[minpis]<<endl;

	return 0;
}


int main()
{
	char min[510];
	char max[510];
	char all[510];
	char cur[510];
	int len, i, j;
	int minlen = 510, maxlen = 0;

	gets(all);

	len = strlen(all);

	j = 0;
	for (i = 0; i < len; ++i) {
		if (all[i] == ' ' || all[i] == '\0' || i == len-1) {
			if (i == len-1) {
				cur[j++] = all[i];
			}
			cur[j] = '\0';

			if (minlen > strlen(cur)) {
				minlen = strlen(cur);
				strcpy(min, cur);
			}
			if (maxlen < strlen(cur)) {
				maxlen = strlen(cur);
				strcpy(max, cur);
			}

			if (all[i] == '\0' || i == len)
				break;

			j = 0;
			continue;
		}

		cur[j++] = all[i];
	}

	printf("%s\n%s\n", max, min);

	return 0;
}


int main()
{
	int n;
	int i;
	char word[200][20];
	int count[200]={0};
	int max=0,min=20;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",word[i]);

	}

	for(i=0;i<n;i++)
	{
		count[i]=strlen(word[i]);
	}

	for(i=0;i<n;i++)
	{
		if(count[i]>max)
		{
			max=count[i];
		}
	}

	for(i=0;i<n;i++)

	{
		if(count[i]<min)

		{
			min=count[i];
		}
	}

for(i=0;i<n;i++)
	{
	if(strlen(word[i])==max)
	{
	printf("%s\n",word[i]);
	break;
	}
	}

	for(i=0;i<n;i++)
	{
	if(strlen(word[i])==min)
	{
	printf("%s\n",word[i]);
	break;
	}
	}

	return 0;
}


int main()
{
	char str[200][200],s[4000];
	int i=0,j=0,p=0,length[200],max,min;

	gets(s);
	for(i=0;s[i]!='\0';i++){
		if(s[i]==' ')
		{
				str[j][i-p]='\0';
				j++;
				p=i+1;
		}
		else if(s[i]!=',')
			str[j][i-p]=s[i];
	}
	str[j][i-p]='\0';

	for(i=0;i<=j;i++){
		length[i]=strlen(str[i]);
	}
	j++;
	max=min=0;
	for(i=0;i<j;i++){
		if(length[max]<length[i])
			max=i;
		if(length[min]>length[i])
			min=i;
	}
	printf("%s\n%s\n",str[max],str[min]);
	return 0;
}


int main()
{
	int maxnum=0,minnum=99,i,flag=0;
	char max[50],min[50],temp[50],t;
	while(1)
	{
		do
		{
			t=cin.get();
		}while(t==' '||t==',');
		for(i=0;t!=' '&&t!=',';)
		{
			temp[i]=t;
			t=cin.get();
			i++;
			if(t=='\n')
			{
				flag=1;
				break;
			}
		}
		temp[i]='\0';
		if(i>maxnum)
		{
			strcpy(max,temp);
			maxnum=i;
		}
		if(i<minnum)
		{
			strcpy(min,temp);
			minnum=i;
		}
		if(flag==1)
			break;
	}
end:
	cout<<max<<endl;
	cout<<min<<endl;

	return 0;
}


void main()
{
	char a[10000],*p=a,n,i,*max,*min,x=0,y=100,word=0;
	gets(a);
	max=a;min=a;
	for(i=0,n=strlen(a),p=a;i<n;i++)
	{
		word++;
		if(*(p+i)==' ')
		{
			word--;
			if(word>x){x=word;max=p+i-x;}
			if(word<y){y=word;min=p+i-y;} /*???????*/
			word=0;
		}
		if(i==n-1)
		{
			if(word>x){x=word;max=p+i-x+1;}
			if(word<y){y=word;min=p+i-y+1;}
		}
	}
	for(p=max;p<max+x;p++)
	{
		printf("%c",*p);
		if(p==max+x-1)printf("\n");
	}
	for(p=min;p<min+y;p++)
		printf("%c",*p);
}


int main()
{
	int min,max,i;
	char str_i[100],str_a[100],str[200];
	int flag = 1;
	max = -1;
	min = 100000;
	while(flag)
	{
		for( i = 0;;i++ )
		{
			str[i] = getchar();
			if( str[i] == ' ' )
			{
				str[i] = '\0';
				break;
			}
			if( str[i] == '\n' )
			{
				str[i] = '\0';
				flag = 0;
				break;
			}
		}
		if( strlen(str) < min )
		{
			min = strlen(str);
			strcpy(str_i,str);
		}
		int test = strlen(str);
		if( test > max )
		{
			max = strlen(str);
			strcpy(str_a,str);
		}
	}
	printf("%s\n",str_a);
	printf("%s",str_i);
	return 0;

}


void main()
{ int i=-1,shortlen=100,longlen=0;
  char str[500];
  char *c,*max,*min,*flag1,*flag2;
  c=max=min=str;
  gets(c);

  do{
	  flag1=flag2=c;
	  while(*c!=' '&&*c!='\0')c++;

	  if(longlen<c-flag1)
	  {longlen=c-flag1;max=flag1;}
	  if(shortlen>c-flag2)
	  {shortlen=c-flag2;min=flag2;}
	  c++;
  }
  while(*(c-1)!='\0');

 for(i=1;i<=longlen;i++)
  printf("%c",*max++);
 printf("\n");

 for(i=1;i<=shortlen;i++)
	 printf("%c",*min++);
}


int main()
{
	char e[256],all[1000],words[50][256];
	int i,j,l,len,n=0,k=0;
	gets(all);
	len=strlen(all);
	for(i=0;i<len;i++)
	{
		if(all[i]==' ')
		{
			all[i]='\0';
			strcpy(words[n],(all+k));
			n++;
			k=i+1;
		}
	}
	strcpy(words[n],(all+k));
	for(j=0;j<n;j++)
	{
		if(strlen(words[j])>=strlen(words[j+1]))
		{
			strcpy(e,words[j+1]);
			strcpy(words[j+1],words[j]);
			strcpy(words[j],e);
		}
	}
	printf("%s\n",words[n]);
	for(l=0;l<n;l++)
	{
		if(strlen(words[l])<=strlen(words[l+1]))
		{
			strcpy(e,words[l+1]);
			strcpy(words[l+1],words[l]);
			strcpy(words[l],e);
		}
	}
	printf("%s\n",words[n]);
	return 0;
}


int main()
{
char str[100];

gets(str);
int maxlen=0;
int minlen=9999;
char*maxstr=0;
char*minstr=0;
char*p=strtok(str," ");
while(p)
{
int len=strlen(p);
if(len>maxlen)
{
maxlen=len;
maxstr=p;
}
if(len<minlen)
{
minlen=len;
minstr=p;
}
p=strtok(0," ");
}
printf("%s\n",maxstr);
printf("%s\n",minstr);
return 0;
}


int main()
{
    char s[10000];
    int max_end,max_len=0,min_end,min_len=10000,l,i,j,k=0;
    gets(s);
    l=strlen(s);
    for(i=0;i<=l;i++)
        if(s[i]==' '||s[i]==','||i==l)
        {
            if(k<min_len&&k>0) {min_len=k;min_end=i;};
            if(k>max_len) {max_len=k;max_end=i;};
            k=0;
        }
        else k++;
    //printf("%d %d %d %d\n",max_end,max_len,min_end,min_len);
    for(i=max_end-max_len;i<max_end;i++) printf("%c",s[i]);
    printf("\n");
    for(i=min_end-min_len;i<min_end;i++) printf("%c",s[i]);
}


int main(){
	int max(int a[],int n);
	int min(int a[],int n);
	char s[200][50];
	int n,i,j,b[200];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",s[i]);
		b[i]=strlen(s[i]);
	}
	for(i=0;i<n;i++){
		if(b[i]==max(b,n)){
			printf("%s\n",s[i]);
			break;
		}
	}
	for(i=0;i<n;i++){
		if(b[i]==min(b,n)){
			printf("%s\n",s[i]);
			break;
		}
	}
	return 0;
}

int max(int a[],int n){
	int t=a[0],i;
	for(i=0;i<n;i++){
		if(t<a[i]) t=a[i];
	}
	return t;
}

int min(int a[],int n){
	int t=a[0],i;
	for(i=0;i<n;i++){
		if(t>a[i]) t=a[i];
	}
	return t;
}


int main(){
	int i,k,index,max,min;
	char juzi[2500],word[50][50];
	gets(juzi);
	index=0;
	for(i=0;;i++)
	{
		for(k=0;;)
		{
			if(juzi[index]!=' '&&juzi[index]!='\0')
			{
				word[i][k]=juzi[index];
				index++;
				k++;
			}
			else
			{
				word[i][k]='\0';
				index++;
				k++;
				break;
			}
		}
		if(juzi[index-1]==0)
		{
			break;
		}
	}
	max=0;
	min=0;
	for(k=1;k<=i;k++)
	{
		if(strlen(word[k])>strlen(word[max]))
		{
			max=k;
		}
		if(strlen(word[k])<strlen(word[min]))
		{
			min=k;
		}
	}
	printf("%s\n%s",word[max],word[min]);
	return 0;
}


int main()
{
	char sentence[500];
	int i,j=0,len,kong=0,shuliang,num[50]={0},max=0,k,r,min=100,qian1=0,qian2=0;
	gets(sentence);
	len=strlen(sentence);
	for(i=0;i<len;i++)
	{
		if(sentence[i]==' ')
			kong++;
	}
	shuliang=kong+1;

	for(i=0;i<shuliang;i++)
	{
		for(;j<len;j++)
		{
			if(sentence[j]!=' ')
				num[i]++;
			else
			{
				j++;
				break;
			}
		}
	}
	for(i=0;i<shuliang;i++)
	{
		if(num[i]>max)
		{
			k=i;
			max=num[i];
		}
		if(num[i]<min)
		{
			r=i;
			min=num[i];
		}
	}
	for(i=0;i<k;i++)
		qian1=qian1+num[i];
	for(i=0;i<r;i++)
		qian2=qian2+num[i];
	for(i=qian1+k;i<num[k]+qian1+k;i++)
		printf("%c",sentence[i]);
	printf("\n");
	for(i=qian2+r;i<num[r]+qian2+r;i++)
		printf("%c",sentence[i]);
	printf("\n");
	return 0;
}


int main()
{
    /* 50 seem to short,
     * when the input > 50 chars, your program will exit abnormaly,
     * result a no output. This is error tips you get on web.
     */
    //char s[50]={0};
    char s[1000] = {0};

    gets(s);
    int n,m,b=1,i,j,k=0;
    n=strlen(s);
    char a[50][50]={0};
    for(i=0;k<n;i++){ /* word i++ */
        for(j=0;b=0 || k<n;j++){ /* word[i] j++ */
            m=i;
            k++;
            if(s[k-1]==' ')
            {b=0;}
            if(b!=0){
                a[i][j]=s[k-1];
            }
            else
                break;
        }
    }
    int c=0,d=0;
    /* small change: m-1 -> m. */
    for(i=0;i<m;i++)
    {
        /*
         * Get the max & min length.
         */
        if(strlen(a[c])<strlen(a[i+1]))
            c=i+1;
        if(strlen(a[d])>strlen(a[i+1]))
            d=i+1;
    }
    printf("%s\n%s\n",a[c],a[d]);
    return 0;
}