int PrimeQ(int n);

int main()
{
	int i, j, min, max, temp, count, flag=0, num[15], result[100];
	scanf("%d %d", &min, &max);
	for(i=min; i<=max; i++)
	{
		if(PrimeQ(i)==1)
		{
			temp=i;
			for(j=0; temp!=0; j++)
			{
				num[j]=temp-temp/10*10;
				temp/=10;
			}
			temp=j-1;
			count=0;
			for(j=0; j<(temp+1)/2; j++)
			{
				if(num[j]!=num[temp-j])
				{
					count=1;
					break;
				}
			}
			if(count==0)
			{
				result[flag]=i;
				flag++;
			}
		}
	}
	if(flag==0) printf("no\n");
	else for(i=0; i<flag; i++)
	{
		printf("%d", result[i]);
		if(i!=flag-1) printf(",");
		else printf("\n");
	}
	return 0;
}

int PrimeQ(int n)
{
	int i;
	for(i=2; i<=(double)sqrt(n); i++)
	{
		if(n%i==0) return 0;
	}
	if(i!=n+1) return 1;
	return 0;
}


int isprime(int n)
{
    int i;
    for (i = 2; i < n; i++)
    {
        if (n % i == 0)
            return 0;
    }
    return 1;
}

int ishuiwen(int n)
{
    int i, len;
    char a[11];
    sprintf(a, "%d", n);
    len = strlen(a);
    for (i = 0; i < len/2; i++)
    {
        if (a[i] != a[len-i-1])
            return 0;
    }
    return 1;
}

int main()
{
    int ishuiwen(int);
    int isprime(int);
    int count = 0, i, m, n;
    scanf("%d%d", &m, &n);
    for (i=m; i<=n; i++)
    {
        if (isprime(i) && ishuiwen(i))
        {
            count++;
            if (count == 1)
                printf("%d", i);
            else
                printf(",%d",i);
        }
    }
    if (count == 0)
        printf("no");
    return 0;
}


int sushu(int n)
{
	int i;
	for(i=2;i<n/2;i++)
	{
		if(n%i==0)
		{
			return 1;
			break;
		}
	}
	return 0;
}
int reverse(int n)
{
	int i,j;
	int a[10];
	int flag=0;
	int temp;
	temp=n;
	if(n/10==0)
	{
		return 0;
	}
	else if(n/100==0)
	{
		if(n%10==n/10)
		return 0;
		else
		return 1;
	}
	else
	{
	for(i=0;(n/10!=0||n%10!=0);i++)
	{
		a[i]=n%10;
		n=n/10;
	}
	for(j=i-1;j>=0;j--)
	{
		if(a[j]!=a[i-1-j])
		{
			flag=1;
			return 1;
		}
	}
	if(flag==0)
	{
		return 0;
	}
	}
}
void main()
{
	int m,n;
	int i,j;
	int flag=0;
	int flag1=0;
	scanf("%d %d",&m,&n);
	for(i=m;i<=n;i++)
	{
		if(sushu(i)==0)
		{
			if(reverse(i)==0)
			{
				flag1=1;
				if(flag==0)
				{
					flag=1;
					printf("%d",i);
				}
				else
				{
					printf(",%d",i);
				}
			}
		}
	}
	if(flag1==0)
	{
		printf("no");
	}
}


int main()
{
	int flag=0;
	int sushu(int);
	int huiwen(int);
	int m,n,i;
	scanf("%d %d",&m,&n);
	for(i=m;i<=n;i++)
	{
		if(sushu(i)&&huiwen(i))
		{
		if(flag!=0)printf(",%d",i);
		else {printf("%d",i);flag=1;}
		}

	}
	if(flag==0) printf("no");
	return 0;
	}
int sushu(int n)
{
	if(n==2) return 1;
	int j,k=sqrt(n);
	for(j=2;j<k+1;j++)
	{
		if(n%j==0) break;
	}
	if(j==k+1) return 1;
	else return 0;
}
int huiwen(int n)
{
     int j;
     if(n<10)
       return 1;
       int i=0,a[15];
          while(n)
        {a[i]=n%10;
     i++;
        n/=10;}
         i--;
       for(j=0;j<i;j++,i--)
       if(a[j]!=a[i])
      return 0;
         return 1;
}


int huiwen(int);

int zhishu(int);

int main(int argc, char* argv[])
{
	int m,n;
	scanf("%d%d",&m,&n);
	int i,first=1,flag=1;
	for(i=m;i<=n;i++)
	{
		if(huiwen(i)&&zhishu(i))
		{
			if(first)
			{
				printf("%d",i);
				first=0;
			}
			else
			{
				printf(",%d",i);
			}
			flag=0;
		}
	}
	if(flag)
	{
		printf("no");
	}

	return 0;
}

int zhishu(int n)
{
	int c;
	for(c=2;c<n;c++)
	{
		if(n%c==0)
		{
			return 0;
		}
	}
	return 1;
	}

int huiwen(int n)
{
	int s=n,j=0;
	while(s>0)
	{
		j=j*10+s%10;
		s/=10;
	}
	if(n==j)
	{
		return 1;
	}
	return 0;
}


int huiwen(int a)
{
	int i,j=0,flag=1,b[10];
	while(a!=0)
	{
		b[j]=a%10;
		a=a/10;
		j++;//??
	}
	for(i=0;i<j-i;i++)
	{
		if(b[i]!=b[j-i-1])
		{
			flag=0;
			break;
		}
	}

	return flag;
}
int sushu(int n)
{
	int i,flag=1;

		for (i=2;i<n;i++)
		{
			if(n%i==0)
			{
				flag=0;
				break;
			}
		}

	return flag;
}
int main()
{
	int m,n,i,a[100],t=0;
	scanf("%d%d",&m,&n);
	for(i=m;i<=n;i++)
	{
		if(huiwen(i)==1&&sushu(i)==1)
		{a[t]=i;t++;}
	}
    if(t==0)
		printf("no");
	else
	{
		printf("%d",a[0]);
		for(i=1;i<t;i++)
		printf(",%d",a[i]);
	}

	return 0;
}


int sushu(int a)
{   int i,k,t;
    k=(int)sqrt(a);
    for(i=3;i<=k;i=i+2)
  { if(a%i!=0&&a%2!=0)
    t=1;
    else
    {t=0;break;
}
         }
    return t;
}
int check(int a)
{     int t,b[100],k;
      int i;
      for(i=1;a!=0;i++)
      {b[i]=a%10;
        a=a/10;
        k=i;
                   }
    for(i=1;i<=k/2;i++)
    if(b[i]==b[k-i+1])
      t=1;
    else
    {t=0;break;}
    return t;
}
main()
{   int n,m;
    scanf("%d%d",&n,&m);
    int i,con=0;
    for(i=n;i<=m;i++)
    {if(check(i)==1&&sushu(i)==1&&con!=0)
      {   printf(",%d",i);
         con++;            }
    if(check(i)==1&&sushu(i)==1&&con==0)
     {printf("%d",i);
      con++;
     }
}
   if(con==0)
   printf("no");
     }


int f(int a)
{
	int i;
	for(i=3;i<=sqrt(a);i+=2)
	{
		if(a%i==0)
		{
			return(0);
			break;
		}
	}
	return(1);
}

int g(int b)
{
	int n=0,i;
	int c;
	c=b;
	while(c>0)
	{
		n=n*10+c%10;
		c=c/10;
	}
	if(n==b)
		return(1);
	else
		return(0);

}

main()
{
	int m,n;
	scanf("%d %d",&m,&n);
	if(m<=2)
		printf("2,");
	int j;
	int flag=0;
	if(m%2==0)
		m=m+1;
	for(j=m;j<=n;j+=2)
	{
		if(g(j)&&f(j))
		{
			flag=1;
			printf("%d",j);
			break;
		}
	}
	if(flag==0)
		printf("no");
	for(j=j+2;j<=n;j+=2)
	{
		if(f(j)&&g(j))
		{
			flag=1;
			printf(",%d",j);
		}
	}
}


void main()
{
	int ishw(long n);
	int isprime(long n);
	long m,n,first,flag=0,i;
	scanf("%ld%ld",&m,&n);
	for(i=m;i<=n;i++)
		if(isprime(i)&&ishw(i))
		{
			printf("%d",i);
			first=i;
			flag=1;
			break;
		}
	for(i=first+1;i<=n;i++)
		if(isprime(i)&&ishw(i))
		{
			printf(",%d",i);
		}

	if(flag==0)
			printf("no\n");
}
int isprime(long n)
{
	long i,k;
	k=n/2;
	for(i=2;i<=k;i++)
		if(n%i==0)
		{
			return(0);
			break;
		}
	if(i>k)
		return(1);
	else return(0);
}
int ishw(long n)
{
	long i,j,k,place=0;
    char s[9];
	for(i=0;n!=0;i++)
	{
		s[i]=n%10;
		n/=10;
		place=i+1;
	}
		//ltoa(n,s,10);/*?????????????*/
		k=place;
		j=-1;
		do
		j++;
		while(s[j]==s[k-j-1]&&j+1<=k/2);
		if(j+1>k/2)
			return(1);
		else return(0);
}


int huiwen(int a,int n)
{
if(a/10==0) return(n*10+a);
else return(huiwen(a/10,n*10+a%10));
}

main()
{
int a,b,j,flag1,flag2=0,i,k,h;
scanf("%d%d",&a,&b);
  for(i=a;i<=b;i++)
  {
	  flag1=1;
      k=sqrt(i);
    for(j=2;j<=k;j++)
	{
		if(i%j==0) flag1=0;
	}
    if(flag1)
	{
		h=huiwen(i,0);
		if(h==i)
		{
			if(flag2!=0) printf(",");
			printf("%d",i);

			flag2=1;
		}
	}
  }
  if(flag2==0) printf("no");
}


void main()
{int m,n,a,b,c,i;
int sushu(int x);
int huiwen(int y);
scanf("%d%d",&m,&n);
for(i=m;i<=n;i++)
{
	a=sushu(i);
	if(a==1)
	{
		b=huiwen(i);
		if(b==1)
		{
			m=i;
			printf("%d",i);
			c=1;
			break;
		}
		else
			c=0;
	}
}
if(c==0)
printf("no");
else
{
	for(i=m+1;i<=n;i++)
	{
		a=sushu(i);
		if(a==1)
		{
			b=huiwen(i);
			if(b==1)
				printf(",%d",i);
		}
	}
}
}
int sushu(int x)
{
	int j,u;
	for(j=2;j<=x/2;j++)
	{
		if(x%j==0)
		{	u=0;
		break;}
		else
			u=1;

	}
	return(u);
}
int huiwen(int y)
{
	int p=y;
	int q=0;
	while(p>0)
	{
		int r=p%10;
		q=q*10+r;
		p=p/10;
	}
	if(q==y)
		return(1);
	else
	    return(0);
}


int prime(int x)
{
  int i,m;
  double k;
  k=sqrt(x);
  for(i=2;i<=k;i++)
  {if(x%i==0)
  break;}
  if(i>k) m=1;
  else m=0;
  return m;
}
int round(int y)
{
  int a[10000],j,n,l,sum=0,c;
  for(j=0;y!=0;j++)
  {a[j]=y%10;
  y=y/10;}
  for(l=0;l<j;l++)
  {if(a[l]!=a[j-1-l])
   break;}
   if(l==j) n=1;
  else n=0;
  return n;
}
main()
{ int p,q,s,count=0;
  scanf("%d %d",&p,&q);
  for(s=p;s<=q;s++)
  {if(prime(s)==1&&round(s)==1)
   {count++;
   if(count==1)
   printf("%d",s);
   else if(count!=1)
   printf(",%d",s);}
  }
  if(count==0)
  printf("no\n");
  getchar();
  getchar();
  getchar();
}


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

	scanf("%d %d",&m,&n );
	for(i=m;i<=n;i++)
	{
	for(j=2;j<i;j++)
	{
	if(i%j==0)
	break;
	if(j>=i-1)
	if (hw(i))
	{

	  t=t+1;
	  if(t==1)
		  printf("%d",i);
	  else
		  printf(",%d",i);
	}

	}

	}

	if(t==0)
		printf("no");
}

int hw(int(c))
{
	int x,y;
	x=0;
	y=c;
	do
	{x=10*x+y%10;
	y=y/10;
	}
	while(y>0);
	if (x==c)
		return(1);
	else
		return(0);
}


int f1(int x);
int f2(int x);
void main()
{
	int m,n,i,t=0,a[100],j;
	scanf("%d%d",&m,&n);
	for(i=m;i<=n;i++)
		if(f1(i)&&f2(i))
		{
			a[t]=i;
			t++;
		}
	if(t==0)
		printf("no");
	else

		for(j=0;j<t;j++)
		{
			printf("%d",a[j]);
			if(j<t-1)
				printf(",");
		}
}
int f1(int x)
{
	int n=0,y;
	y=x;
	while(y>0)
	{
		n=n*10+y%10;
		y=y/10;
	}
	if(x==n)
		return 1;
	else return 0;
}
int f2(int x)
{
	int i=2;
	while(x%i!=0&&i<=sqrt(x))
		i++;
	if(i>sqrt(x))
		return 1;
	else return 0;
}


int su(int i)
{
	if (i==1) return(0);
	else
	{
	    int j,k,flag=1;
	    k=sqrt(i);
	    for (j=2;j<=k;j++)
		{
		    if (i%j==0)
			{
			    flag=0;
			    break;
			}
		}
	return(flag);
	}
}

int huiwen(int i)
{
	int k=0,x;
	x=i;
	while (i>0)
	{
		k=10*k+i%10;
		i=i/10;
	}
	if (x==k)
		return(1);
	else
		return(0);
}

void main()
{
	int i,m,n,a[100],k=0;
	scanf("%d%d",&m,&n);
	for (i=m;i<=n;i++)
		if (su(i)&&huiwen(i))
		{
			a[k]=i;
			k++;
		}
	if (k==0) printf("no");
	else
	{
		for (i=0;i<k-1;i++)
		printf("%d,",a[i]);
	    printf("%d",a[k-1]);
	}
}


int huiwen(long n)
{
	long m=0,t=n;
	while(n>=1)
	{m=10*m+n%10;
	n=n/10;}

	if(m==t)
		return 1;
	else return 0;

}
int su(long n)
{
	long m,i,k;
	if(n==2)
		return 1;
	else if(n%2==0)
		return 0;
	else for(i=3;i<n/2;i++)
		if(n%i==0)
			return 0;
		return 1;
}

void main()
{
	long m,n,i,k,b[300];
	scanf("%ld%ld",&m,&n);
	for(i=m,k=0;i<=n;i++)

		if(su(i)*huiwen(i)==1)
		{b[k]=i;
		k++;}
		if(k==0)
			printf("no");
		else
		{
			printf("%ld",b[0]);
			if(k>1)
				for(i=1;i<k;i++)
					printf(",%d",b[i]);
		}
}


void main()
{
	int prime(int n);
	int palin(int n);
	int m,n,i=0;
	scanf("%d%d",&m,&n);
	for(;m<=n;m=m+1)
	{
		if(palin(m)==1 && prime(m)==1)
		{
			if(i==0)
				printf("%d",m);
			else
				printf(",%d",m);
			i=i+1;
		}
	}
	if(i==0)
		printf("no");
}

int prime(int n)
{
	int k=1,i;
	for(i=2;i<=sqrt(n);i=i+1)
	{
		if(n%i==0)
		{
			k=0;
			break;
		}
		else
			continue;
	}
	return(k);
}

int palin(int n)
{
	int a[5];
	int i,c,flag=1;
	c=log10(n);
	for(i=0;i<=c;i=i+1)
	{
		a[i]=n/pow(10,c-i);
		n=n-a[i]*pow(10,c-i);
	}
	for(i=0;i<=c;i=i+1)
	{
		if(a[i]==a[c-i])
			continue;
		else
		{
			flag=0;
			break;
		}
	}
	return(flag);
}


int reverse(long x)
{
	long t=x,r=0;
	while(t!=0)
	{
		r=10*r+t%10;
		t/=10;
	}
	if(r==x) return(1);
	else return(0);
}
int prime(long x)
{
	long i;
	for(i=2;i<=sqrt(x);i++)
		if(x%i==0)
			break;
	if(i>sqrt(x)) return(1);
	else return(0);
}
void main()
{
	long m,n,i,j=0;
	scanf("%ld%ld",&m,&n);
	for(i=m;i<=n;i++)
		if(reverse(i)&&prime(i))
		{
			j++;
			printf((j==1)?"%ld":",%ld",i);
		}
		if(j==0)
			printf("no");
}


int huiwen(long n)
{
	int a[11],i=0;
	while(n!=0)
	{
		a[i]=n%10;
		i++;
		n=n/10;
	}
	int j;
	for(j=0;j<i/2;j++)
		if(a[j]!=a[i-1-j])
			return 0;
	return 1;
}
int sushu(long n)
{
	long i;
	for(i=2;i<=(long)sqrt(n);i++)
		if(n%i==0)
			return 0;
		return 1;
}
void main()
{
	int i,count=0;
	long m,n,temp;
	scanf("%ld%ld",&m,&n);
	if(m>n)
	{
		temp=m;
		m=n;
		n=temp;
	}
	for(i=m;i<=n;i++)
	{
		if(huiwen(i)&&sushu(i))
		{
			printf("%ld",i);
			count++;
			break;
		}
	}
	if(count==0)
		printf("no");
	else
		for(i++;i<=n;i++)
		{
			if(huiwen(i)&&sushu(i))
				printf(",%ld",i);
		}
}


int main()
{
	int time1[1000];
	int time2[1000];
	int people=0;
	int num_of_time[1000]={0};
	char nouse;

	while(cin>>time1[people])
	{
		people++;
		if(cin.peek()=='\n')
			break;
		cin.ignore();
	}
	for(int k=0;k!=people-1;k++)
		cin>>time2[k]>>nouse;
	cin>>time2[people-1];

	for(int k=0;k!=people;k++)
	{
		for(int time=time1[k];time!=time2[k];time++)
		{
			num_of_time[time]++;
		}
	}
	int max=0;
	for(int k=0;k!=1000;k++)
		if(num_of_time[k]>max)
			max=num_of_time[k];

	cout<<people<<" "<<max<<endl;
	return 0;
}


int Convert(int *n,char *s);

int main()
{
 int x[2000]={0},y[2000]={0};
 char s1[4000],s2[4000];
 int t,i,num,count=0,max=0;

 gets(s1);
 gets(s2);

 num=Convert(x,s1);
 Convert(y,s2);
 printf("%d",num);

 for(t=0;t<1000;t++)
    {
      for(i=0,count=0;i<num;i++)
         {
           if(t>=x[i]&&t<y[i])
             count++;
         }
      if(count>max)
         max=count;
    }

 printf(" %d",max);
 return 1;
}

int Convert(int *n,char *s)
{
 int lenth,i,j;
 lenth=strlen(s);
 for(i=0,j=0;i<lenth;i++)
    {
     if(s[i]!=',')
        n[j]+=n[j]*10+s[i]-'0';
     else
          j++;
    }
 return j+1;
}


int fa=0,fb=0;
int getnuma(char data[],int start)
{int i,j,k,l,n,m,tp=0;
 tp=data[start]-'0';start++;
 if ((data[start]==',')||(data[start]==0)) {fa=start+1;return tp;}
 else {tp=tp*10+data[start]-'0';start++;
		if ((data[start]==',')||(data[start]==0)) {fa=start+1;return tp;}
		else{tp=tp*10+data[start]-'0';start++;
				if ((data[start]==',')||(data[start]==0)) {fa=start+1;return tp;}
			}
		}

}
int getnumb(char data[],int start)
{int i,j,k,l,n,m,tp=0;
 tp=data[start]-'0';start++;
 if ((data[start]==',')||(data[start]==0)) {fb=start+1;return tp;}
 else {tp=tp*10+data[start]-'0';start++;
		if ((data[start]==',')||(data[start]==0)) {fb=start+1;return tp;}
		else{tp=tp*10+data[start]-'0';start++;
				if ((data[start]==',')||(data[start]==0)) {fb=start+1;return tp;}
			}
		}

}
int main()
{int i,j,k,l,n,m,people=1;
 char in[9000]={' '},out[9000]={' '};
 int time[2800]={0},max=0;
 scanf("%s%s",in,out);
 l=strlen(in);
 for (i=0;i<l;i++) if (in[i]==',') people++;
 for (i=0;i<people;i++)
 {m=getnuma(in,fa);n=getnumb(out,fb);
  for (j=m;j<n;j++)
	  time[j]++;
 }
 for (i=1;i<1800;i++)
	 if (time[i]>max) max=time[i];
 printf("%d %d",people,max);
 return 7;
}


int main()
{
    char a[10000],b[10000];
    memset(a,0,sizeof a);
    memset(b,0,sizeof b);
    cin.getline(a,10000);
    cin.getline(b,10000);
    double aa[10000],bb[10000];
    memset(aa,0,sizeof aa);
    memset(bb,0,sizeof bb);
    int sum1=1,sum2=1,i,j;
    double min=0,max=0;
    aa[1]=atof(a);
    bb[1]=atof(b);
    for(i=1;;i++)
    {
        if(a[i]!=','&&a[i]!=0&&a[i-1]==',')
        {
            sum1++;
            aa[sum1]=atof(&a[i]);
            if(aa[sum1]>max) max=aa[sum1];
            if(aa[sum1]<min) min=aa[sum1];
        }
        if(a[i]==0) break;
    }

    for(i=1;;i++)
    {
        if(b[i]!=','&&b[i]!=0&&b[i-1]==',')
        {
            sum2++;
            bb[sum2]=atof(&b[i]);
            if(bb[sum2]>max) max=bb[sum2];
            if(bb[sum2]<min) min=bb[sum2];
        }
        if(b[i]==0) break;
    }

    cout<<sum1<<" ";
    int people[10000];
    memset(people,0,sizeof people);
    min=(int) min;
    max=(int) max;

    for(i=min;i<=max;i++)
    {
        for(j=1;j<=sum1;j++)
        {
            if(i>=aa[j]&&i<bb[j]) people[i]++;

        }
    }
    int Max=0;
    for(i=min;i<=max;i++)
    {
        if(people[i]>Max) Max=people[i];

    }
    cout<<Max;

    return 0;
}


int main()
{
	int arr[1001];
	int left[1001];
	int cnt;
	int i,j,k;
	while(scanf("%d",&arr[0])!=EOF)
	{
		cnt=1;
		char ch;
		while(scanf("%c",&ch)!=EOF&&ch==',')
		{
			scanf("%d",&arr[cnt]);
			cnt++;
		}
		for(i=0;i<cnt-1;i++)
			scanf("%d,",&left[i]);
		scanf("%d",&left[cnt-1]);
		int min=arr[0];
		int max=left[0];
		for(i=0;i<cnt;i++)
		{
			if(arr[i]<min)
				min=arr[i];
			if(left[i]>max)
				max=left[i];
		}
		int count=0;
		int mcnt=0;
		for(i=min;i<=max;i++)
		{
			count=0;
			for(j=0;j<cnt;j++)
			{
				if(arr[j]<=i&&left[j]>i)
					count++;
			}
			if(count>mcnt)
				mcnt=count;
		}
		printf("%d %d\n",cnt,mcnt);
	}
}


int main(){
int a[1000],b[1000];
char c;
int i=0;
int max=0;

while(true){
	cin>>a[i];
	if((c=cin.get())=='\n')
		break;
	else i++;
}

int sum=i+1;
i=0;
while(true){
	cin>>b[i];
	if((c=cin.get())=='\n')
		break;
	else i++;
}

for(i=0;i<sum;i++)
	if(max<b[i])
		max=b[i];

int time[max];

for(i=0;i<max;i++)
	time[i]=0;

for(i=0;i<sum;i++)
	for(int j=a[i];j<b[i];j++)
		time[j]++;
int num=0;

for(i=0;i<max;i++)
	if(num<time[i])
		num=time[i];

cout<<sum<<' '<<num<<endl;

return 0;
}


int convert(char s[],int result[])
{
	int value,len,num=0,k=0;
	len=strlen(s);
	s[len]='\0';
	while(k<len)
	{
		value=0;
		while((s[k]!=',')&&(s[k]!='\0'))
			value=value*10+s[k++]-'0';
		result[num++]=value;
		k=k+1;
	}
	return(num);
}
void f(int x[],int y[],int num[],int total)
{
	int i,j;
	for(i=0;i<total;i++)
	{
		for(j=x[i];j<y[i];j++)
		{
			num[j]=num[j]+1;
		}
	}
}
void main()
{
	int num[1000]={0};
	int x[1000],y[1000];
	char s1[10000],s2[10000];
	gets(s1);
	gets(s2);
	int total;
	total=convert(s1,x);
	total=convert(s2,y);
	f(x,y,num,total);
	int max=num[0],i;
	for(i=0;i<1000;i++)
	{
		if(num[i]>max)
			max=num[i];
	}
	printf("%d %d",total,max);
}


int main()
{
	int i,num1[1000],num2[1000],len,count1=0,min=0,max=2000,maxnum=0,j;
	char ch;
	for(i=0;;i++)
	{
		cin>>num1[i];
		if(num1[i]<min)
			min=num1[i];
		ch=getchar();
		if(ch=='\n')
		{
			len=i+1;
			break;
		}
	}
	for(i=0;i<len;i++)
	{
		cin>>num2[i];
		if(num2[i]>max)
			max=num2[i];
		ch=getchar();
	}
	for(i=min;i<=max;i++)
	{
		count1=0;
		for(j=0;j<len;j++)
		{
			if(i>=num1[j]&&i<num2[j])
				count1++;
		}
		if(count1>maxnum)
			maxnum=count1;
	}
	cout<<len<<" "<<maxnum<<endl;
	return 0;
}


int main()
{int x[1000],y[1000],people[1001]={0};
 int i=0,length=0;
 do
   cin>>x[i++];
 while(cin.get()==',');
 length=i;i=0;
 do
   cin>>y[i++];
 while(cin.get()==',');
 for(i=0;i<length;i++)
  for(int j=x[i];j<y[i];j++)
     people[j]++;
 int max=0;
 for(i=0;i<=1000;i++)
  if(people[i]>max)
    max=people[i];
 cout<<length<<' '<<max;
 return 0;
}


int main()
{
	int begin[1000],end[1000],i=0,j=0,sum=0,max=0,k;
	char dot=',';
	while (dot==',')
	{
		cin >> begin[i];
		i++;
		dot=cin.get();
	}
	while (cin>>end[j])
	{
		j++;
		dot=cin.get();
		if(dot!=',')
			break;
	}
	for(k=0;k<1000;k++)
	{
		for(i=0;i<j;i++)
		{
			sum+=(begin[i]==k)-(end[i]==k);
		}
		if(sum>max)
			max=sum;
	}

	cout << i <<" "<<max<<endl;
	return 0;
}


//?????
int main()
{
	int start[1001],end[1001], max=0,num[1001],sum = 1,i=1,j=1,a;
	char x;
	memset(num,0,sizeof(num));
	memset(start,0,sizeof(start));
	memset(end,0,sizeof(end));
	cin >> start[0];
	while(cin >>  x)
	{
		if (x != ',')	break;
		cin >> start[i];
		i++;
		sum++;
	}
	end[0] = x-'0';
	while(cin >> x)
	{
	  if(x==',') break;
	  end[0] = 10*end[0]+(x-'0');
	}
	while(cin >> end[j])
	{
		j++;
		if (j == sum)	break;
		cin >> x;
	}
	for(i=0; i<sum;i++)
	{
		for (a=start[i];a<end[i];a++)
		{
			num[a]++;
		}
	}
	for (i = 0;i<=1000;i++)
	{
		if (max<num[i])	max= num[i];
	}
	cout << sum <<  " " <<max;

return 0;
}


int main()
{
	char string1[100000], string2[100000];
	int x[1001], y[1001];
	memset(x, 0 ,sizeof(x));
	memset(y, 0 ,sizeof(y));
	int i, j, n, k = 0, q, p = 0;
	int power[3] = {1, 10, 100}, num[1001];
	int maxpeople = 0, time;
	memset(num, 0 ,sizeof(num));
	cin >> string1;
	for (i = 0; i <= strlen(string1) - 1; i++)
	{
		if (string1[i] == ',')
			k = k + 1;
	}
	n = k + 1;
	q = n;
	for (i = strlen(string1) - 1; i >= 0; i--)
	{
		if(string1[i] != ',')
		{
			x[q] = x[q] + (int)(string1[i] - 48) * power[p];
			p = p + 1;
		}
		else
		{
			q = q - 1;
			p = 0;
		}
	}
	cin >> string2;
	q = n;
	p = 0;
	for (i = strlen(string2) - 1; i >= 0; i--)
	{
		if(string2[i] != ',')
		{
			y[q] = y[q] + (int)(string2[i] - 48) * power[p];
			p = p + 1;
		}
		else
		{
			q = q - 1;
			p = 0;
		}
	}
	for (i = 1; i <= 1000; i++)
	{

		for(j = 1; j <= n; j++)
		{
			if (x[j] <= i && y[j] >= i + 1)
				num[i]++;
		}
		if (num[i] > maxpeople)
		{
			maxpeople = num[i];
			time = i;
		}
	}
	cout << n << " " <<  maxpeople << endl;
	return 0;
}


int main()
{
	char p;
	int time1[1000];
	int time2[1000];
	int min=1000;
	int max=0;
	int i,j;
	i=0;
	j=0;
	int n=0;
	while(cin>>time1[i])
	{
		p=cin.get();
		if(p==',')
		{
			i++;
			continue;
		}
		else
		{
			break;
		}
	}
	n=i+1;
	i=0;
	while(cin>>time2[i])
	{
		p=cin.get();
		if(p==',')
		{
			i++;
			continue;
		}
		else
		{
			break;
		}
	}
	for(i=0;i<n;i++)
	{
		if(time1[i]<min)
		{
			min=time1[i];
		}
		if(time2[i]>max)
		{
			max=time2[i];
		}
	}
	int count[1000]={0};
	int maxtime=0;
	for(i=min;i<=max;i++)
	{
		for(j=0;j<n;j++)
		{
			if(time1[j]<=i && time2[j]>i)
			{
				count[i]++;
			}
		}
		if(count[i]>maxtime)
		{
			maxtime=count[i];
		}
	}
	cout<<n<<' '<<maxtime<<endl;
	return 0;
}


int main()
{
    int arr[1020], lea[1020];
	int num = 0;
	int i, j, k;
	for(i = 1; ;i++)
	{
		cin >> arr[i];
		num ++;
		k =cin.get() ;
		if(k == 10)
			break;
	}
	for(i = 1; ;i++)
	{
		cin >> lea[i];
		if(cin.get() == 10)
			break;
	}

    int people[1020];
	for(i = 1; i < 1000; i++)
		people[i] = 0;
	for(i = 1; i <= num; i++)
	{
		for(j = arr[i]; j < lea[i]; j++)
			people[j] ++;
	}
	int Max_people = 0;
	for(i = 1; i < 1000; i++)
	{
		if(people[i] > Max_people)
			Max_people = people[i];
	}
	cout << num << ' '<< Max_people << endl;

	return 0;
}


int a[2][100000];
int add(int i,int n)
{
	int k,temp=0;
	for(k=1;k<=n;k++)
		if(a[0][k]<=i&&a[1][k]>i)
			temp++;
	return temp;
}
void main()
{
	int i=1,n;
	char c;
	scanf("%d",&a[0][i]);
	c=getchar();
	i++;
	while(c!='\n')
	{
		scanf("%d",&a[0][i]);
		c=getchar();
		i++;
	}
	printf("%d ",i-1);
	i=1;
	scanf("%d",&a[1][i]);
	c=getchar();
	i++;
	while(c!='\n')
	{
		scanf("%d",&a[1][i]);
		c=getchar();
		i++;
	}
	n=i-1;
	int result=0;
	for(i=0;i<=1000;i++)
	{
		int temp=add(i,n);
		if(result<temp)
			result=temp;
	}
	printf("%d",result);
}


int main()
{
int lai[1001]={0},zou[1001]={0};
int tongji[1001]={0};
int count=1,renshu=0;
char meiyong=0;
int shijianbiao[1001]={0};
cin>>lai[1];                    //??????????????????????????????????cin.get()?????????????
while(meiyong=cin.get()==',')
{
count++;
cin>>lai[count];
}
renshu=count;
count=1;
cin>>zou[1];                    //??????????????
while(meiyong=cin.get()==',')
{
count++;
cin>>zou[count];
}
int i=0;                        //????????
for(count=1;count<=renshu;count++)
for(i=lai[count];i<zou[count];i++)
{shijianbiao[i]++;}
int max=shijianbiao[0];
for(count=1;count<=1000;count++)
if(shijianbiao[count]>max)max=shijianbiao[count];
cout<<renshu<<" "<<max<<endl;
return 0;

}


int main ()
{
	int in[1000], out[1000], time[1000] = {0}, count = 0, max = 0, i, j;
	char sign;
	for (count = 0; ; count++)
	{
		cin >> in[count];
		cin.get(sign);
		if (sign != ',')
			break;

	}
	for (i = 0; i <= count; i++)
	{
		cin >> out[i];
		cin.get(sign);
		for (j = in[i]; j < out[i]; j++)
		{
			time[j]++;
		}
	}
	for (i = 0; i <= 999; i++)
	{
		if (time[i] > max)
		{
			max = time[i];
		}
	}
	cout << count + 1<< " ";
	cout << max << endl;
	return 0;
}


int main(int argc, char *argv[])
{
    int numary1[1000], numary2[1000];
    char temp;        int min=1000, max=0;
    int t=0;                  int count1=0,count2=0;
    while(t==0){
                scanf("%d%c",&numary1[count1], &temp);
                if(numary1[count1] > max){
                                      max= numary1[count1];
                }
                if(numary1[count1] < min){
                                      min= numary1[count1];
                }
                count1++;
                if(temp== '\n'){
                          t++;
                }
    }
    while(t==1){
                scanf("%d%c",&numary2[count2], &temp);
                if(numary2[count2] > max){
                                      max= numary2[count2];
                }
                if(numary2[count2] < min){
                                      min= numary2[count2];
                }
                count2++;
                if(count2 == count1){
                          t++;
                }
    }
    int i,j,k;  int tong[1000]={0};
    int maxpopu=0;
    for(i=min; i<=max ; i++){
             for(j=0; j<count1; j++){
                      if(i>=numary1[j] && i<numary2[j]){
                                       tong[i]++;
                      }
             }
             if(tong[i]> maxpopu){
                         maxpopu= tong[i];
             }
    }
    cout << count1 << " " << maxpopu;

    return EXIT_SUCCESS;
}


struct ren
{
	int x;
	int y;
} a[3000];
int judge(struct ren a,int t)
{
	if(t<a.y&&t>=a.x)
	{
		return 1;
	}
	else
		return 0;
}

int main()
{
	char line1[200000];
	char line2[200000];
	char b[100];
	int i,j;
	int p=0;
	int num=0;
	int count[1100]={0};
	memset(line1,0,sizeof(line1));
	memset(line2,0,sizeof(line2));
	memset(b,0,sizeof(b));
	cin.getline(line1,200000);
	cin.getline(line2,200000);

	int len1,len2;
	len1=strlen(line1);
	len2=strlen(line2);
	int sum=1;
	for(i=0;i<len1;i++)
	{
		if(line1[i]==',')
			sum++;
	}

	for(i=0;i<len1;i++)
	{
		if(line1[i]!=',')
		{
           b[p]=line1[i];
		   p++;
		}
		else
		{
			a[num].x=atoi(b);
			memset(b,0,sizeof(b));
			p=0;
			num++;
		}
	}
	a[num].x=atoi(b);
    memset(b,0,sizeof(b));
    p=0;
    num=0;
	for(i=0;i<len2;i++)
	{
		if(line2[i]!=',')
		{
           b[p]=line2[i];
		   p++;
		}
		else
		{
			a[num].y=atoi(b);
			memset(b,0,sizeof(b));
			p=0;
			num++;
		}
	}
	a[num].y=atoi(b);
	for(i=0;i<=1001;i++)
	{
		for(j=0;j<sum;j++)
		{
			if(judge(a[j],i))
				count[i]++;
		}
	}
	int max=0;
	for(i=0;i<1002;i++)
	{
		if(max<count[i])
			max=count[i];
	}
	cout<<sum<<" "<<max<<endl;
	return 0;
}


int main()
{
        int count[1001];

        memset(count,0,sizeof(count));

        int come[1000],go[1000];
        char m;

        int i,j,max;

        for(i=0;;i++)
        {
                cin>>come[i];
                m=cin.get();
                if(m=='\n')
                        break;
        }

        for(i=0;;i++)
        {
                cin>>go[i];
                m=cin.get();
                if(m!=',')
                        break;
        }

        int num=i+1;

        for(i=0;i<num;i++)
                for(j=come[i];j<go[i];j++)
                        count[j]++;
        max=0;
        for(i=0;i<=1000;i++)
                if(count[i]>max)
                        max=count[i];

        cout<<num<<" "<<max<<endl;

        return 0;
}


int main()
{
    int temp;
    char m;
    int a[1001] = {0};
    int num;
    int i, j, k;
    int come[1000];
    int leave[1000];
    for(num = 0; ;num ++)
    {
          cin >> come[num];
          m = cin.get();
          if (m == '\n')
          break;
    }
    for(num = 0; ;num ++)
    {
          cin >> leave[num];
          m = cin.get();
          if (m == '\n')
          break;
    }
    for (i = 0; i <= num; i ++)
    {
         for(j = come[i]; j < leave[i]; j++)
         {
               a[j] ++;
         }
    }
    temp = a[0];
    for (i = 1;i <= 1000; i++)
    {
        if (a[i] >= temp)
        {
            temp = a[i];
        }
    }
    cout << num + 1<< " " << temp << endl;
    return 0;
}


int main()
{
	int total;
	int getin[1000];
	int getout[1000];
	int i=0,j=0;
	char x;
	do
	{
		cin>>getin[j];
		j++;
		x = getchar();
	}while(x==',');
	total = j;
	for(j=0;j<total;j++)
	{
		cin>>getout[j];
		x = getchar();
	}
	cout<<total<<" ";
    int people[2000];
	for(i=0;i<2000;i++)
	{
		people[i] = 0;
	}
	for(i=0;i<2000;i++)
	{
		for(j=0;j<total;j++)
		{
			if((i>=getin[j])&&(i<getout[j]))
			{
				people[i]++;
			}
		}
	}
	int max = 0;
	for(i=0;i<2000;i++)
	{
		if(people[i]>max)
			max = people[i];
	}
	cout<<max;
	return 0;
}


int change(char p[],int n)
{
	int i,result=0;
	for(i=0;i<n;i++)
	{
		result=result*10+p[i]-'0';
	}
	return result;
}
int manzu(int p[],int n)
{
	if(n>=p[0]&&n<p[1])
		return 1;
	return 0;
}
void main()
{
	int time[1000][2]={0},i=0,j=0,k,num,(*p)[2],max,count=0;
	char ch,temp[5]={'\0'};
	p=time;
	for(k=0;k<=1;k++)
	{
	while((ch=getchar())!='\n')
	{
		if(ch!=',')
			temp[i++]=ch;
		else {temp[i]='\0';time[j++][k]=change(temp,i);i=0;}///
	}
	temp[i]='\0';time[j++][k]=change(temp,i);i=0;
	num=j;
	j=0;
	}
	max=0;
	for(i=0;i<1000;i++)
	{
		for(j=0;j<num;j++)
			if(manzu(p[j],i))///
				count++;
		if(count>max)
			max=count;
		count=0;
	}
	printf("%d %d",num,max);
}


int sum=0,len=0,maxn=0;
char times[10001]={0};
char inch[1001][5],outch[1001][5];
int in[2001],out[1001],sch[1001]={0};
int main()
{
    int i,j=0,k=0;
    memset(times,0,sizeof(times));
    cin>>times;
    while(times[len]) len+=1;
    for(i=0;i<len;++i)
    {
            if(isdigit(times[i]))
            {
                    inch[j][k]=times[i];
                    k++;
            }
            else
            {
                    j++;
                    k=0;
            }
    }
    len=0;
    j=0;
    k=0;
    memset(times,0,sizeof(times));
    cin>>times;
    while(times[len]) len++;
    for(i=0;i<len;++i)
    {
            if(isdigit(times[i]))
            {
                    outch[j][k]=times[i];
                    k++;
            }
            else
            {
                    j++;
                    k=0;
            }
    }
    sum=j+1;
    for(i=0;i<sum;++i)
    {
            in[i]=atoi(inch[i]);
            out[i]=atoi(outch[i]);
    }
    for(i=0;i<sum;++i)
    {
            for(j=in[i];j<out[i];++j)
            {
                    sch[j]++;
            }
    }
    for(i=0;i<1001;++i) if(sch[i]>maxn) maxn=sch[i];
    cout<<sum<<" "<<maxn<<endl;
    return 0;
}


int main()
{
	int in[1002],out[1002],time[1002]={0};
	int temp,i,j,k,num;
	char space;
	for(i=0;;i++)
	{
		scanf("%d%c",&temp,&space);
		in[i]=temp;
		if(space!=',') break;
	}
	num=i+1;
	for(i=0;;i++)
	{
		scanf("%d%c",&temp,&space);
		out[i]=temp;
		if(space!=',') break;
	}
	for(i=0;i<num;i++){
		for(j=in[i];j<out[i];j++){
			time[j]++;
		}
	}
	int max=0;
	for(i=0;i<=1001;i++){
		if(time[i]>max)
			max=time[i];
	}
	printf("%d %d",num,max);
}


int main()
{
    int x[1000]={0},y[1000]={0},counter=0,len,i,j,max=0,temp=0;;
    char s[10000];
    gets(s);
    len=strlen(s);
    for(i=0;i<len;i++)
    {
                      if(s[i]==',')
                      counter++;
                      else
                      {
                          x[counter]=x[counter]*10;
                          x[counter]=x[counter]+s[i]-'0';
                      }
    }
    gets(s);
    len=strlen(s);
    counter=0;
    for(i=0;i<len;i++)
    {
                      if(s[i]==',')
                      counter++;
                      else
                      {
                          y[counter]=y[counter]*10;
                          y[counter]=y[counter]+s[i]-'0';
                      }
    }
    counter++;//?????
    for(i=0;i<1000;i++)
    {
                       temp=0;
                       for(j=0;j<counter;j++)
                       {
                                               if(x[j]<=i&&y[j]>i)
                                               temp++;
                       }
                       if(temp>max)
                       max=temp;
    }
    printf("%d %d",counter,max);
    return 0;
}


int main() {
	int i, j, a = 0, lenth, max = 0;
	char come1[20000], leave1[20000];
	cin.getline(come1, 20000);
	cin.getline(leave1, 20000);
	lenth = strlen(come1);
	for (i = 0; i < lenth; i++)
		if (come1[i] == ',')
			a++;
	a++;
	cout << a << " ";
	int come[a], leave[a];
	int at[1000];
	come[0] = atoi(come1);
	a = 1;
	for (i = 0; i < lenth; i++) {
		if (come1[i] == ',') {
			come[a] = atoi(come1 + i + 1);
			a++;
		}
	}
	lenth = strlen(leave1);
	leave[0] = atoi(leave1);
	a = 1;
	for (i = 0; i < lenth; i++) {
		if (leave1[i] == ',') {
			leave[a] = atoi(leave1 + i + 1);
			a++;
		}
	}
	for (i = 0; i < 1000; i++)
		at[i] = 0;
	for (i = 0; i < a; i++) {
		for (j = come[i]; j < leave[i]; j++) {
			at[j]++;
		}
	}
	max = at[0];
	for (i = 1; i < 1000; i++) {
		if (at[i] > max) {
			max = at[i];
		}
	}
	cout << max << endl;
	return 0;
}


int main()
{
	int a[1001], b[1001], num = 1, i, j, temp = 0, max = 0;
	char c;
	do
	{
		cin >> a[num];
		cin.get(c);
		num++;
	}while (c == ',');
	num = 1;
	do
	{
		cin >> b[num];
		cin.get(c);
		num++;
	}while (c == ',');
	cout << num - 1;
	num--;
	for (i = 0; i < 1000; i++)
	{
		for (j = 1; j <= num; j++)
		{
			if (i >= a[j] && i < b[j])
				temp++;
		}
		if (max < temp)
			max = temp;
		temp = 0;
	}
	cout << ' ' << max << endl;
	return 0;
}


int p(int n)
{
    int sum=1;
    for(int i=0;i<n;i++)  sum=sum*10;
    return sum;
}
void change(int time[1001],char str[1001])
{
    int j=0,k=0;
    for(int i=strlen(str)-1;i>=0;i--)
    {
            if(str[i]!=',')
            {
                           time[k]=time[k]+(str[i]-'0')*p(j);
                           j++;
            }
            else
            {
                j=0;
                k++;
            }
    }
    return ;
}
int length(char str[100000])
{
    int count=1;
    for(int i=0;i<strlen(str);i++)
    {
            if(str[i]==',')
            count++;
    }
    return count;
}
int main()
{
    char str1[100000],str2[100000];
    cin>>str1>>str2;
    int time1[1000],time2[1000];
    memset(time1,0,sizeof(time1));  memset(time2,0,sizeof(time2));
    change(time1,str1);  change(time2,str2);
    int len1,len2;
    len2=len1=length(str1);
    cout<<len1<<' ';
    int time[1001];
    memset(time,0,sizeof(time));
    for(int i=0;i<len1;i++)
    {
            for(int j=time1[i];j<time2[i];j++)   time[j]++;
    }
    int max=0;
    for(int i=0;i<1001;i++)
    {
            if(max<time[i])  max=time[i];
    }
    cout<<max<<endl;
    return 0;
}


int main()
{
	int in[1000],out[1000];
	int num=1,time=0,ma=0,s=0;
	while(1)
	{
		cin>>in[num];
		if(getchar()=='\n')
		{
			break;
		}
		else
		{
			num++;
		}
	}
	num=1;
	while(1)
	{
		cin>>out[num];
		if(getchar()=='\n')
		{
			break;
		}
		else
		{
			num++;
		}
	}
	for(time=1;time<=1000;time++)
	{
		s=0;
		for(int i=1;i<=num;i++)
			if(in[i]<=time&&out[i]>time)
				s++;
		if(ma<s)
			ma=s;
	}
	cout<<num<<" "<<ma<<endl;
	return 0;
}


int  num1[10000],num2[10000],n;

int main()
{
    char str;
    int temp=0,i,max=0,tmp,j;
    n=0;
    scanf("%c",&str);
    while(str != '\n')
    {
         if(str==',')
         {
               num1[n]=temp;
               temp=0;
               n++;
         }
         else temp=temp*10+str-'0';
         scanf("%c",&str);
    }
    num1[n]=temp;
    n++;
    for(i=0;i<n;i++)
    {
          scanf("%d",&num2[i]);
          scanf("%c",&str);
    }

   for(i=0;i<1000;i++)
   {
         tmp=0;
         for(j=0;j<n;j++)
         if(i>=num1[j] && i<num2[j])
              tmp++;
         if(tmp>max)
            max=tmp;
   }
   printf("%d %d",n,max);

    return 0;
}


int main()
{
	char temp;
	int c[1000],d[1000],i=0,j=0,t=0,k=0,count=0,max=0,sum;
	while(1)
	{
		cin >> c[i];
		temp=getchar();
			if(temp!=',')
				break;
			i++;
	}
	i=0;
	while(1)
	{
		cin >> d[i];
		temp=getchar();
			if(temp!=',')
				break;
			i++;
	}
	sum=i+1;
		cout << sum << " ";
	for(k=1;k<=1000;k++)
	{
		for(j=0;j<=sum-1;j++)
			if(c[j]<=k && d[j]>k)
				count++;
			if(count>max)
				max=count;
			count=0;
	}
	cout << max << endl;
	return 0;
}


int main()
{
	int begin[10000]={' '},end[10000]={' '};			//begin and end array:record time
	int sum[10000]={' '};			//record amount of the people present at the same time
	int max_sum=0;
	int num_sum=0;
	char b[10]={' '};
	int i,j=0;		//cyclic variable
	char a[10000]={' '};			//read input
	char a1[10000]={' '};
			//next thirteen lines get the input
	cin.getline(a,10000);
	int length=strlen(a);
	for(i=0;i<=length;i++)
	{
		if((a[i]<='9')&&(a[i]>='0'))
		{
			b[j]=a[i];
			j++;
		}
		else
		{
			begin[num_sum]=atoi(b);
			num_sum++;
			for(int k=0;k<j;k++)
				b[k]='\0';
			j=0;
		}
	}
	num_sum=0;
	cin.getline(a1,10000);
	int length1=strlen(a1);
	for(i=0;i<=length1;i++)
	{
		if((a1[i]<='9')&&(a1[i]>='0'))
		{
			b[j]=a1[i];
			j++;
		}
		else
		{
			end[num_sum]=atoi(b);
			num_sum++;
			for(int k=0;k<j;k++)
				b[k]='\0';
			j=0;
		}
	}
	for(i=1;i<10000;i++)
		for(j=0;j<num_sum;j++)
			if((i>=begin[j])&&(i<end[j]))
				sum[i]++;

	for(i=1;i<10000;i++)
		if(sum[i]>max_sum)
			max_sum=sum[i];
	cout<<num_sum<<' '<<max_sum;
	return 0;
}


int arr[1000000];
int brr[1000000];
int tot[1004];
int main()
{

	char a;
	int renshu=0,renshu1=0;
	char ch;
	while(1)
	{
		scanf("%d", &arr[renshu]);
		renshu++;
		ch=getchar();
		if(ch!=',')
			break;
	}
	while(1)
	{
		scanf("%d", &brr[renshu1]);
		renshu1++;
		ch=getchar();
		if(ch!=',')
			break;
	}
	cout<<renshu<<" ";
    tot[0]=0;
	int i,j;
	for(i=1;i<=1000;i++)
	{
		for(j=0;j<renshu;j++)
		{
		   if(i>=arr[j] && i<brr[j])
			   tot[i]++;
		}
	}
    sort(tot,tot+1001);
	cout<<tot[1000]<<endl;
	return 0;
}


int a[1000];
int b[1000];

int main()
{
	int n;
	char ch;
	//??
	int al=0;
	while(cin>>n)
	{
		a[al++]=n;
		cin.get(ch);
		if(ch=='\n')
			break;
	}
	//??
	int bl=0;
	while(cin>>n)
	{
		b[bl++]=n;
		cin.get(ch);
		if(ch=='\n')
			break;
	}
	//??
	int len=bl;
	//
	int max=0;
	for(int i=0; i < 999; i++)
	{
		int cnt=0;
		for(int j=0; j < len; j++)
		{
			if(i >= a[j] && i < b[j])
				cnt++;
		}
		if(cnt > max)
			max=cnt;
	}
	cout<<len<<" "<<max<<endl;

	return 0;
}


void main()
{
	int intime[1000],outtime[1000],trs[1000],i,j,k,a,b,c,rs,maxrs=0;
	for(i=0;;i++)
	{
		scanf("%d",&intime[i]);
		if((c=getchar())!=',') break;
	}
	rs=i+1;
	for(i=0;;i++)
	{
		scanf("%d",&outtime[i]);
		if((c=getchar())!=',') break;
	}
	for(i=0;i<1000;i++)
		trs[i]=0;
	for(i=0;i<rs;i++)
		for(j=intime[i];j<outtime[i];j++)
		trs[j]++;
	for(i=0;i<1000;i++)
		if(trs[i]>maxrs) maxrs=trs[i];

	printf("%d %d",rs,maxrs);
}


int main ()
{
	int time[3][1005]={0}, i=1,j, num, tmax=0;
	int count[1005]={0}, countmax=0;
	char p=0;
	while ( p!='\n' )
	{
		cin >> time [1][i];
		p = cin.get();
		i++;
	}
	p=0,i=1;
	while ( p!='\n' )
	{
		cin >> time [2][i];
		p = cin.get();
		i++;
	}
	num = i-1;
	for ( i=1; i <=num; i++ )
		if ( time[2][i] > tmax )
			tmax = time [2][i];
	for ( i=1; i<=tmax; i++ )
	{
		for ( j=1; j <= num; j++ )
		{
			if ( time [2][j] > i &&  time [1][j] <= i )
				count[i]++;
		}
	}
	for ( i=1; i<=tmax; i++)
		if ( count[i] > countmax )
			countmax=count[i];
	cout << num << " " << countmax << endl;
	return 0;
}


struct men
{
	int x;
	int y;
}time[1000];

int main()
{
	int i=0,j,max=0,n,sum;
	char c;
	do
	{
		scanf("%d",&time[i].x);
		i++;
	}while((c=getchar())!='\n');
	i=0;
	do
	{
		scanf("%d",&time[i].y);
		i++;
	}while((c=getchar())!='\n');
	n=i;
	printf("%d ",n);
	for(i=0;i<1000;i++)
	{
		sum=0;
		for(j=0;j<n;j++)
		{
			if(i>=time[j].x&&i<time[j].y)
				sum++;
		}
		if(sum>max)
			max=sum;
	}
	printf("%d\n",max);
	return 0;
}


/*	???:???
	???:1000012896 leo
	????:2010.12.1
	????:??????????
	*/
int main()
{
	int atime[10000], ltime[10000], min = 1000, max = 0, count = 0, per, maxp = 0, i, j;
	for (i = 1; ;i++)
	{
		cin >> atime[i];
		if (atime[i] < min)
			min = atime[i];
			if (getchar() == '\n')
			break;
	}
	for (i = 1; ;i++)
	{
		cin >> ltime[i];
		if (ltime[i] > max)
			max = ltime[i];
			if (getchar() == '\n')
			break;
	}
	count = i;
	for (j = min; j <= max - 1; j++)
	{
		per = 0;
		for (i = 1; i <= count; i++)
			if ( atime[i] <= j && ltime[i] > j)
				per ++;
		if (per > maxp)
			maxp = per;
	}
	cout << count << ' ' << maxp;
	return 0;
}


int main()
{
	int list1[1000];
	int list2[1000];
	scanf("%d",&list1[0]);
	int count=1;
	while(scanf(",%d",&list1[count++])!=0);
	count--;
	int index=1;
	scanf("%d",&list2[0]);
	while(scanf(",%d",&list2[index++])!=0);

	int max=0;
	int num=0;
	int i=0;
	for(i=0;i<1000;i++)
	{
		num=0;
		for(index=0;index<count;index++)
		{
			if(i>=list1[index] && i<list2[index])
				num++;
		}
		if(num>max)
			max=num;
	}

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


void main()
{
	int max(int a[],int n);
	int min(int a[],int n);
	int a[1000],b[1000],i=1,j,c[1000]={0},count=0,n,maxa,maxb,mina,minb,max_,min_,max0,maxman;
	scanf("%d",&a[0]);
	while(getchar()==',')
	{
		scanf("%d",&a[i]);
		i++;
	}
	n=i;
	i=1;
	scanf("%d",&b[0]);
	while(getchar()==',')
	{
		scanf("%d",&b[i]);
		i++;
	}
	maxa=max(a,n);
	maxb=max(b,n);
	mina=min(a,n);
	minb=min(b,n);
	if(maxa>=maxb)max_=maxa;else max_=maxb;
	if(mina<=minb)min_=mina;else min_=minb;
	for(max0=min_;max0<=max_;max0++)
	{
		for(i=0;i<n;i++)
		{
			if(max0>=a[i]&&max0<b[i])
				c[count]++;
		}
		count++;
	}
	count--;
	maxman=c[0];
	for(i=1;i<=count;i++)
	{
		if(c[i]>=maxman)maxman=c[i];
	}
	printf("%d %d\n",n,maxman);
}

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

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


int input(int a[],int b[],int c[])
{
	int m=0;
	int small,big;
	char cd;
	scanf("%d",&a[m]);
	small=a[m];
	while((cd=getchar())!='\n')
	{
		m=m+1;
		scanf("%d",&a[m]);
		if(a[m]<small)
			small=a[m];
	}
	m=0;
	scanf("%d",&b[m]);
	big=b[m];
	while((cd=getchar())!='\n')
	{
		m=m+1;
		scanf("%d",&b[m]);
		if(b[m]>big)
			big=b[m];
	}
	c[0]=small;
	c[1]=big;
	return (m+1);
}

void count(int a[],int b[],int d[],int r)
{
	int i;int j;
	for(i=0;i<r;i++)
		for(j=a[i];j<b[i];j++)
			d[j]++;

}
int maxi(int c[],int d[])
{
	int i;
	int max=d[c[0]];
	for(i=c[0]+1;i<c[1];i++)
	{
		if(d[i]>max)
			max=d[i];
	}
	return max;

}
void main()
{
	int a[N],b[N];
	int d[1001]={0};
	int c[2];
	int i=0;
	int r,max;
	r=input(a,b,c);
	count(a,b,d,r);
	max=maxi(c,d);
	printf("%d %d",r,max);

}


int main()
{
	int i, j;
	int x[1000 + 1];
	int y[1000 + 1];
	int flag[1000 + 1]={0};
	char p;
    int number , n;
	int max , sum , a = 0 , k;
	max = 1;
	number = 1;

	for(i = 1 ; i <= 2 ; i ++)
	{
		while(1)
		{
			scanf("%c",&p);
			if(p == '\n' || p == ',')
			{

				if(i == 1)
				{
					x[number] = a;
					number ++ ;
				}
				else
				{
					y[number] = a;
					number ++ ;
				}
				a = 0;
				if( p == '\n')
					break;
			}
            else
		    a = a * 10 + p - '0';
		}
		n = number - 1;
		number = 1;
	}

	for( i = 1 ; i <= n ; i ++)
	{
		for( j = x[i] ; j < y[i] ; j ++)
		{
			flag[j] ++;

		}
	}

	for( i = 0 ; i < 1000; i ++)
	{
		if(max < flag[i])
		max = flag[i] ;
	}
	printf("%d %d\n",n ,max);

	return 0;
}


int main()
{
	int time[2][1000];
	int n, i, j, k;
	char c[2][1000];
	int max, min;
	int mostpeople, countpeople;
	for (i = 0; i < 2; i++)
	{
		for (j = 0; ; j++)
		{
			cin >> time[i][j];
			c[i][j]=cin.get();
			if (c[i][j] != ',')
				break;
		}
	}
	n = j;
	cout << n + 1<< " ";
	min = time[0][0];
	for (j = 0; j <= n; j++)
	{
		if (min > time[0][j])
			min = time[0][j];
	}
	max = time[1][0];
	for (j = 0; j <= n; j++)
	{
		if (max < time[1][j])
			max = time[1][j];
	}
	mostpeople = 0;
	for (k = min; k <= max; k++)
	{
		countpeople = 0;
		for (j = 0; j <= n; j++)
		{
			if ((k >= time[0][j]) && (k < time[1][j]))
				countpeople += 1;
		}
		if (mostpeople < countpeople)
			mostpeople = countpeople;
	}
	cout << mostpeople;
	return 0;
}


int n;

int x[10010],y[10010];
char a[100010],b[100010];

int tonum(char *s, int a,int b){
    int ans = 0;
    for(int i=a;i<=b;i++)
        ans = ans * 10 + (s[i] - '0');
    return ans;
}
int main(){
    //n = 1;
    while(scanf("%s %s",a,b) != EOF){
        n = 0;

        int len = strlen(a);
        int pre = 0;
        for(int i=0;i<=len;i++)
            if(i == len || a[i] == ',')
                x[++n] = tonum(a,pre,i-1),pre = i + 1;

        len = strlen(b);
        pre = 0;
        n = 0;
        for(int i=0;i<=len;i++)
            if(i == len || b[i] == ',')
                y[++n] = tonum(b,pre,i-1),pre = i + 1;

        int ans = 0;
        for(int i=0;i<=1000;i++){
            int ccount = 0;
            for(int j=1;j<=n;j++)
                if(x[j] <= i && y[j] > i)
                    ccount ++;
            ans = max(ans ,ccount);
        }

        printf("%d %d\n",n,ans);
    }
    return 0;
}


int main()
{
    int time, cnt = 0;
    int delta[1001] = {0};

    while (1)
    {
        cin >> time;
        delta[time]++;
        cnt++;
        if (cin.get() != ',')
            break;
    }

    int i;
    char comma;
    for (i=0; i<cnt; i++)
    {
        cin >> time >> comma;
        delta[time]--;
    }

    int curprecent = 0, max = 0;
    for (i=0; i<1001; ++i)
    {
        curprecent += delta[i];
        if (curprecent > max)
            max = curprecent;
    }

    cout << cnt << ' ' << max << endl;
    return 0;
}


int main()
{
	int start1[10000],end1[10000];
	int i=0,renshu=0,max=0,flag=0,flag1=0,j=0;
	int num[100000];
	char start[200000],end[200000];
	memset(num,0,sizeof(num));
	memset(start1,0,sizeof(start1));
	memset(start,0,sizeof(start));
	memset(end,0,sizeof(end));
	memset(end1,0,sizeof(end1));
	cin.getline(start,200000,'\n');
	cin.getline(end,200000,'\n');
	for(i=0;i<200000;i++)
	{
		if(start[i]==0)
		{
			renshu++;
			flag=flag1;
			flag1=i-1;
			if(renshu==1)
			{
				for(j=flag1;j>=0;j--)
					start1[renshu]=start1[renshu]+(start[j]-'0')*pow((double)10,(double)(flag1-j));
			}
			else
			{
				for(j=flag1;j>flag+1;j--)
					start1[renshu]=start1[renshu]+(start[j]-'0')*pow((double)10,(double)(flag1-j));
			}
			break;
		}
		if(start[i]!=0)
		{
			if(start[i]==',')
			{
				renshu++;
				flag=flag1;
				flag1=i-1;
				if(renshu==1)
				{
					for(j=flag1;j>=0;j--)
						start1[renshu]=start1[renshu]+(start[j]-'0')*pow((double)10,(double)(flag1-j));
				}
				else
				{
					for(j=flag1;j>flag+1;j--)
						start1[renshu]=start1[renshu]+(start[j]-'0')*pow((double)10,(double)(flag1-j));
				}
			}
		}
	}
	flag=0;
	flag1=0;
	renshu=0;
	for(i=0;i<200000;i++)
	{
		if(end[i]==0)
		{
			renshu++;
			flag=flag1;
			flag1=i-1;
			if(renshu==1)
			{
				for(j=flag1;j>=0;j--)
					end1[renshu]=end1[renshu]+(end[j]-'0')*pow((double)10,(double)(flag1-j));
			}
			else
			{
				for(j=flag1;j>flag+1;j--)
					end1[renshu]=end1[renshu]+(end[j]-'0')*pow((double)10,(double)(flag1-j));
			}
			break;
		}
		if(end[i]!=0)
		{
			if(end[i]==',')
			{
				renshu++;
				flag=flag1;
				flag1=i-1;
				if(renshu==1)
				{
					for(j=flag1;j>=0;j--)
						end1[renshu]=end1[renshu]+(end[j]-'0')*pow((double)10,(double)(flag1-j));
				}
				else
				{
					for(j=flag1;j>flag+1;j--)
						end1[renshu]=end1[renshu]+(end[j]-'0')*pow((double)10,(double)(flag1-j));
				}
			}
		}
	}
	for(i=1;i<=renshu;i++)
	{
		for(j=start1[i];j<end1[i];j++)
			num[j]++;
	}
	for(i=0;i<1000;i++)
	{
		if(num[i]>max)
			max=num[i];
	}
	cout<<renshu<<" "<<max<<endl;
	return 0;
}


int main()
{
	int t1[1000],t2[1000],num=0,mint1,maxt2=0;
	char c;
	scanf("%d%c",&t1[num],&c);
	mint1=t1[num];
	while (c!='\n')
	{
		num++;
		scanf("%d%c",&t1[num],&c);
		if(t1[num]<mint1)
			mint1=t1[num];
	}
	int i;
	scanf("%d",&t2[0]);
	maxt2=t2[0];
	for(i=1;i<=num;i++)
	{
		scanf(",%d",&t2[i]);
		if(t2[i]>maxt2)
			maxt2=t2[i];

	}
	scanf("%d",t2[num]);
	printf("%d ",num+1);
	int t,maxnum=0,n;
	for(t=mint1;t<maxt2;t++)
	{
		n=0;
		for(i=0;i<=num;i++)
		{
			if(t>=t1[i]&&t<t2[i])
			{
				n++;
			}
		}
		if(n>maxnum)maxnum=n;
	}
	printf("%d",maxnum);
}


int main()
{
	int i,j,n,arrive[1000],leave[1000],time[2000]={0};
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>arrive[i];
	}
	for(i=0;i<n;i++)
	{
		cin>>leave[i];
	}
	for(i=0;i<n;i++)
	{
		for(j=arrive[i];j<leave[i];j++)
			time[j]++;
	}
	int max=0;
	for(i=0;i<2000;i++)
	{
		if(max<time[i]) max=time[i];
	}
	cout<<max<<endl;
	return 0;
}


int main()
{
    int in[1005], out[1005], num = 0, count[1005] = {0}, max = 0;
    char f;
    while (1)
    {
        cin >> in[num++];
        if (cin.get() == '\n') break;
    }
    for (int i = 0; i < num; i++)
    {
        scanf("%d", &out[i]);
        cin.get();
        for (int j = in[i]; j < out[i]; j++)
            count[j]++;
    }
    for (int i = 0; i < 1001; i++)
        if (max < count[i]) max = count[i];
    cout << num << " " << max << endl;
    return 0;
}


/*
 * zhaopinhuirenshu.cpp
 *
 *  Created on: 2011-12-22
 *      Author: Administrator
 */
int main()
{
	int a[1000],b[1000],time[1000]={0};
	int i=0,k=0,j,max=0;
	do
	{
		cin>>a[i];
		i++;
	}
	while((getchar())!='\n');
	do
	{
		cin>>b[k];
		k++;
	}
	while((getchar())!='\n');
	for (int p=0;p<i;p++)
	{
		for (j=a[p];j<b[p];j++)
		{
			time[j]++;
		}
	}
	for (int p=0;p<1000;p++)
		if (time[p] > max)
		{
			max=time[p];
		}
	cout<<i<<" "<<max<<endl;
	return 0;
}


int main()
{
	int a[1000];
	int b[1000];
	int mark[1000];
	char c;
	int i=0;
	int j=0;
	int num;
	int max;
	int k;
	scanf("%d",&a[i]);
	while (c=getchar()==',')
		{
		i=i+1;
		scanf("%d",&a[i]);
		}
	scanf("%d",&b[j]);
	while (c=getchar()==',')
	{
		j=j+1;
		scanf("%d",&b[j]);
	}
	num=j+1;
	for(k=0;k<1000;k++)
	{
		for(i=0;i<num;i++)
		{
			if(k>=a[i]&&k<b[i])
				mark[k]=mark[k]+1;
		}
	}
	max=mark[0];
	for(k=0;k<1000;k++)
	{
		if(mark[k]>max)
			max=mark[k];
	}
	printf("%d %d",num,max);
	return 0;
}


int main()
{
     int i,j,n,m,temp,arrive[1600],leave[1600],times[1001]={0};
     char c;
     c=getchar();
     while(c!=EOF)
     {
       n=0;
       while(c!='\n')
       {
         m=c-'0';
         temp=0;
         while((m<=9)&&(m>=0))
         {
           temp=temp*10+m;
           c=getchar();
           m=c-'0';
          }
          arrive[n]=temp;
          n++;
          if(c==',')
	  c=getchar();

         }
	c=getchar();
       n=0;
       while(c!='\n')
       {
         m=c-'0';
         temp=0;
         while((m<=9)&&(m>=0))
         {
           temp=temp*10+m;
           c=getchar();
           m=c-'0';
          }
          leave[n]=temp;
          n++;
          if(c==',')
	   c=getchar();
         }
         for(i=0;i<1000;++i)
           times[i]=0;
	for(i=0;i<n;i++)
	{
		for(j=arrive[i];j<leave[i];j++)
			times[j]++;
	}
	int max=0;
	for(i=0;i<1000;i++)
	{
		if(max<times[i]) max=times[i];
	}
	printf("%d %d\n",n,max);
         while(c=='\n')
	  c=getchar();

      }
}


int main()
{
	int a[10000];
	int b[10000];
	int x;
	int min, max;

	cin >> a[0];

	x = 1;

	while(cin.get() != '\n')
	{
		cin >> a[x];
		x ++;
	}

	cin >> b[0];

	x = 1;

	while(cin.get() != '\n')
	{
		cin >> b[x];
		x ++;
	}

	min = 100000;
	max = 0;

	for(int i = 0; i <= x; i++)
	{
		if(a[i] < min)
		min = a[i];

		if(b[i] > max)
		max = b[i];
	}

	int maxcount = 0;

	for(int i = min; i <= max; i ++)
	{
		int count = 0;

		for(int j = 0; j <= x; j ++)
		{
			if(a[j] <= i && i < b[j])
			{
				count ++;
			}

			else
			continue;

			if(count > maxcount)
			maxcount = count;

		}
	}

	cout << x << " " << maxcount;

	return 0;
}


int main()
{
	int x,y,counter=0;
	int num[1000]={0};
	while(cin>>x)
	{
		counter++;
		num[x]++;
		if(cin.get()!=',')
			break;
	}
	while(cin>>y)
	{
		num[y]--;
		if(cin.get()!=',')
			break;
	}
	int max=0,contemperary=0;
	for(int j=0;j<1000;j++)
		{
			contemperary+=num[j];
			if(contemperary>max)
				max=contemperary;
	}
	cout<<counter<<" "<<max;
	return 0;
}


/*
 * T22.cpp
 *
 *  Created on: 2012-11-10
 *      Author: weiwan
 */

int main()
{
	int x[1010],y[1010],count[1010],xmin,ymax,countmax;
	int i,j;
	int n = 0;
	char c;
	memset(count,0,sizeof(count));
	do
	{
		cin >>x[n];n++;
		c = getchar();
	}while(c != '\n');
	n = 0;
	do{
		cin >>y[n];n++;
		c = getchar();
	}while(c != '\n');

	xmin = x[0];
	for (i = 1;i < n;i ++)
		if(x[i] < xmin)xmin = x[i];

	ymax = y[0];
	for (i = 1;i < n;i ++)
		if (y[i] > ymax)ymax = y[i];

	for (i = xmin;i <= ymax;i ++)
		for (j = 0;j < n;j ++)
		{
			if (x[j] <= i && y[j] > i)count[i] ++;
		}

	countmax = count[0];
	for (i = xmin;i <= ymax;i ++)
		if (count[i] > countmax)countmax = count[i];

	cout <<n <<' ' <<countmax <<endl;

	return 0;
}


int main()
{
	int in[1000];
	int out[1000];
	int i=0,j=0;
	int time[1000]={0};
	char a;
	while(cin>>in[i])
	{
		cin.get(a);
		i++;
		if(a!=',') break;
	}
	while(cin>>out[j])
	{
		cin.get(a);
		j++;
		if(a!=',') break;
	}
	for(int k=0;k<i;k++)
	{
		for(int l=0;l<1000;l++)
		{
			if(l>=in[k]&&l<out[k])
				time[l]++;
		}
	}
	int max=0;
	for(int k=0;k<1000;k++)
	{
		if(time[k]>=max)
			max=time[k];
	}
	cout<<i<<" "<<max<<endl;
	return 0;
}


static int TIME_LIMIT = 1000;

int parseInput(char * input, int * record);

int main() {
	char input[100000];
	int enter[TIME_LIMIT];
	int leave[TIME_LIMIT];
	for (int i=0; i<TIME_LIMIT; i++) {
		enter[i]=leave[i]=0;
	}
	cin.getline(input, 100000);
	int all = parseInput(input, enter);
	cin.getline(input, 100000);
	parseInput(input, leave);

	int max = 0;
	for (int i=0; i<TIME_LIMIT; i++) {
		if (enter[i]-leave[i] > max) {
			max = enter[i]-leave[i];
		}
	}
	cout << all << ' ' << max << endl;
	return 0;
}

int parseInput(char * input, int * record) {
	int idx = 0;
	char number[5];
	int number_idx = 0;
	int count = 0;
	while (idx < strlen(input)) {
		if (input[idx]!=',') {
			number[number_idx++] = input[idx];
		}
		else {
			number[number_idx] = '\0';
			number_idx = 0;
			int inum = atoi(number);
			for (int i=inum; i<TIME_LIMIT; i++) {
				record[i] ++;
			}
			count++;
		}
		idx++;
	}

	//???????
	number[number_idx] = '\0';
	int inum = atoi(number);
	for (int i=inum; i<TIME_LIMIT; i++) {
		record[i] ++;
	}
	count++;
	return count;
}


/*
 * intergratedexercise1.14.cpp
 *
 *  Created on: 2014-1-4
 *      Author: st
 */
int main()
{
	int in[10000],out[10000];
	cin>>in[0];
	int i,l,j=1,k=1;
	while(scanf(",%d",&in[j++]));
	cin>>out[0];
	while(scanf(",%d",&out[k++]));
	int min=in[0],max=out[0];
	for(i=0;i<j;i++)
		if(in[i]<min)
			min=in[i];
	for(i=0;i<k;i++)
		if(out[i]>max)
			max=out[i];
	//cout<<min<<' '<<max<<endl;
	int count=0,tem=0;
	for(i=min;i<max;i++){
		for(l=0;l<j;l++)
			if(in[l]<=i&&out[l]>i)
				tem++;
		if(tem>count)
			    	count=tem;
			    tem=0;
	}
	cout<<j-1<<' '<<count;

}


int main()
{
	int start[1000], out[1000], time[1001];  // in out?????0-999
	memset(time,0,sizeof(time));
	int i = 0, j = 0, k = 0, max = 0;
	char c;
	while (cin >> start[i])
	{
		c = cin.get();
		if (c != '\n')
		{
			i++;
		}
		else
		{
			break;
		}
	}
	while (cin >> out[j])
	{
		c = cin.get();
		if (c != '\n')
		{
			j++;
		}
		else
		{
			break;
		}
	}
	for (k = 0; k <= i ; k++)
	{
		for (int s = start[k]; s < out[k]; s++)
		{
			time[s]++;
		}
	}
	for (int r = 0; r < 1001; r++)
	{
		if (max < time[r])
		{
			max = time[r];
		}
	}
	cout << i + 1 << " " << max ;
	return 0;
}


int main()
{
    int intime,outtime;
    int time[1000]={0};
    int count=0;
    char a;
    int i;
    do
    {
        cin >> intime;
        count++;
        for (i=intime;i<1000;i++)
        {
            time[i]++;
        }
        cin.get(a);
    }
    while (a!='\n');
    do
    {
        cin >> outtime;

        for (i=outtime;i<1000;i++)
        {
            time[i]--;
        }
        cin.get(a);
    }
    while (a!='\n');
    int max=time[0];
    for (i=1;i<1000;i++)
    {
        if (time[i]>max)
        {
            max=time[i];
        }
    }
    cout << count << " " << max << endl;

    return 0;
}


int main()
{
	int i=0,n=0,j;
	int a[1000],b[1000],c[1001];
	char comma;
	int max=0;

	memset(c,0,sizeof(c));

	while (cin>>a[n++])
	{
		comma=getchar();
		if (comma!=',') break;
	}

	for (i=0;i<n;i++)
	{
		cin>>b[i];
		if (i<n-1) getchar();

		for (j=a[i];j<b[i];j++)
		{
			c[j]++;
			if (c[j]>max) max=c[j];
		}
	}

	cout<<n<<" "<<max<<endl;;

	return 0;

}


int main()
{
	int x[1001], y[1001];
	char comma;
	int i, j;
	for(i = 1;;i++)
	{
		cin >> x[i];
		comma = cin.get();
		if(comma == ',')
			continue;
		if(comma == '\n')
			break;
	}
	for(i = 1;;i++)
	{
		cin >> y[i];
		comma = cin.get();
		if(comma == ',')
			continue;
		if(comma == '\n')
			break;
	}
	int num = i;
	int time[1001] = {0};
	for(i = 1; i <= num; i++)
		for(j = x[i]; j < y[i]; j++)
			time[j]++;
	int max = time[1];
	for(i = 1; i <= 1000; i++)
		if(max < time[i])
			max = time[i];
	cout << num << " " << max << endl;
	return 0;
}


int main()
{
	int people[1000][2],sum=1,time[1000]={0};
	cin>>people[0][0];
	while(scanf(",%d",&people[sum++][0]));
	cin>>people[0][1];
	sum=1;
	while(scanf(",%d",&people[sum++][1]));

	for(int i=0;i<sum;i++){
		for(int j=people[i][0];j<people[i][1];j++)	time[j]++;
	}
	int max=0;
	for(int i=0;i<1000;i++){
		if(time[i]>max) max=time[i];
	}
	cout<<sum-1<<" "<<max<<endl;
}


int come[1000],out[1000];
int in();                  //??
int check(int max);        //??????
int search(int same[1000]);//???
int main()
{  int max;
  max=in();                //???????
  cout<<max+1<<" "<<check( max);//??
  return 0;
}
int in()
{int i=0,j=0;
	char a;
	while(true)
	{  cin>>come[i++];
		cin.get(a);   //????
		if(a=='\n')break;

		}
	i=0;

while(true)
	{  cin>>out[i++];
		cin.get(a);
		if(a=='\n')break;

		}
return i-1;
}
int check(int max)
{
	int i,j,k=0,same[1000]={0};
	for(i=0;i<=1000;i++)       //?????
	{for(j=0;j<=max;j++)
		if(i>=come[j]&&i<out[j])
			same[k]++;k++;}
	return search(same);

}
int search(int same[1000])
{
	int i,ma=0;
	for(i=0;i<1000;i++)
       if(ma<same[i])         //???
		   ma=same[i];
	return ma;
}


int main()
{
	int in[1001], out[1001], i, j, n, count[1001] = {0}, climax;
	char a;
	for (i = 0; ; i++)
	{
		cin >> in[i];
		cin.get(a);
		if (a == '\n')
			break;
	}
	for (i = 0; ; i++)
	{
		cin >> out[i];
		cin.get(a);
		if (a == '\n')
			break;
	}
	n = ++i;
	for (i = 0; i < n; i++)
	{
		for (j = in[i]; j < out[i]; j++)
			count[j]++;
	}
	climax = count[0];
	for (j = 0; j < 1000; j++)
		if (count[j] > climax)
			climax = count[j];
	cout << n << " " << climax << endl;
	return 0;
}


int main()
{
	int arrival[1000],depature[1000],i=0,j,count,max=0,t=0;
	char a[2000];
	while(true)
	{
		cin>>arrival[i];
		//cout<<arrival[i]<<' ';
		i++;
		if(cin.get()!=',')
			break;
	}
	//cout<<endl;
	int total=i;
	i=0;
	while(true)
	{
		cin>>depature[i];
		//cout<<depature[i]<<' ';
		i++;
		if(cin.get()!=',')
			break;
	}
	//cout<<endl;
	for(i=0;i<1000;i++)
	{
		count=0;
		for(j=0;j<total;j++)
			if(i>=arrival[j]&&i<depature[j])
				count++;
		if(count>max)
			{
			max=count;
			//cout<<"max="<<max<<' '<<"i="<<i<<endl;
			}
	}
	cout<<total<<' '<<max;
	return 0;
}

/*
cin.getline(a,2000);
	while(true)
	{
		char temp[20],time=0;
		memset(temp,0,sizeof(temp));
		for(;a[i]==',';i++)
		{
			if(a[i]=='\n')
			{
				letsBreak=true;
				arrival[t]=atof(temp);
				break;
			}
			temp[time]=a[i];
		}
		if(letsBreak)
			break;
		arrival[t]=atof(temp);
		i++;
		t++;
	}
	i=0,t=0;
	memset(a,0,sizeof(a));
	cin.getline(a,2000);
	while(true)
	{
		char temp[20],time=0;
		memset(temp,0,sizeof(temp));
		for(;a[i]==',';i++)
		{
			if(a[i]=='\n')
			{
				letsBreak=true;
				depature[t]=atof(temp);
				break;
			}
			temp[time]=a[i];
		}
		if(letsBreak)
			break;
		depature[t]=atof(temp);
		t++;
	}
	int total=t+1;
*/


int main()
{
    char input[4000], comma;
    int enter[1000], leave[1000];
    cin >> input;
    int len = strlen(input), i, j, k, u = 0, min = 1000, max = 0;

    for (i = 0; i < len; i++) {
        if (input[i] != ',') {
            char temp[2000];
            k = 0;
            for (j = i; input[j] >= '0' && input[j] <= '9'; j++, k++) temp[k] = input[j]; temp[k] = '\0';
            enter[u] = atoi(temp);
            if (enter[u] < min) min = enter[u];
            i = j;
            u++;
        }
    }

    len = u;
    for (i = 0; i < len - 1; i++) {
        cin >> leave[i] >> comma;
        if (leave[i] > max) max = leave[i];
    }
    cin >> leave[len - 1];
    if (leave[len - 1] > max) {
        max = leave[len - 1];
    }

    int num[1000];
    for (i = min; i < max; i++) {
        for (j = 0; j < len; j++) {
            if (i >= enter[j] && i < leave[j]) num[i]++;
        }
    }

    int maxans = num[min];
    for (i = min; i < max; i++) {
        if (num[i] > maxans) maxans = num[i];
    }
    cout << len << " " << maxans << endl;
    return 0;
}


main()
{
	int arv[1000],lve[1000],min=0,max=0,num,sum=0,person=0;
	char c;
	int i,j,k;
	for(i=0;;i++)
	{
		scanf("%d",&arv[i]);
		c=getchar();
		if(min>arv[i]) min=arv[i];
		if(c=='\n')
		{
			num=i+1;break;
		}
	}
	scanf("%d",&lve[0]);max=lve[0];
	for(i=1;i<num;i++)
	{
		scanf(",%d",&lve[i]);
		if(lve[i]>max) max=lve[i];
	}
	for(j=min;j<=max-1;j++)//min,max-1~min+1,max
	{
		for(k=0;k<num;k++)
		{
			if(arv[k]<=j&&j+1<=lve[k])
				sum++;
		}
		if(sum>person) person=sum;
		sum=0;
	}
	printf("%d %d\n",num,person);
	return 0;
}


int main() {
        int start[1000];
        int end[1000];

        int time[1024];
        int n = 0;
        for(int i = 0;;i++) {
                n ++;
                cin >> start[i] ;
                char c = cin.get();
                if (c!=',')
                        break;
        }
        for(int i = 0; ; i ++) {
                cin >> end[i];
                char c = cin.get();
                if(c!=',')
                        break;
        }

        for (int i = 0; i < 1024; i ++)
                time[i] = 0;
        for (int i = 0; i < n; i ++) {
                for (int j = start[i]; j < end[i]; j ++)
                        time[j] ++;
        }
        int max = 0;
        for (int i = 0; i < 1024; i ++) {
                if (max < time[i])
                        max = time[i];
        }
        cout << n << " " << max << endl;
        return 0;
}


int x[2000],y[2000];
int main()
{
	int n=0;
	char lt;
	while(++n){
		cin>>x[n];
		cin.get(lt);
		if(lt!=',')break;
	}
	for(int i=1;i<=n;i++){
		cin>>y[i];
		cin.get(lt);
	}
	int max=0;
	for(int i=0;i<1000;i++){
		int cnt=0;
		for(int j=1;j<=n;j++){
			if(x[j]<=i&&i<y[j])cnt++;
		}
		max=max>cnt?max:cnt;
	}
	cout<<n<<' '<<max;
	return 0;
}


int main()
{
	int time[1001] = {0}, tin[1001], tout[1001];
	char a = ',';
	int p_num = 1;
	cin >> tin[1];
	while ((a = getchar()) != '\n')
	{
		p_num++;
		cin >> tin[p_num];
	}
	p_num = 1;
	cin >> tout[1];
	while ((a = getchar()) != '\n')
	{
		p_num++;
		cin >> tout[p_num];
	}
	for (int p = 1; p <= p_num; p++)
		for (int i = tin[p]; i < tout[p]; i++)
			time[i]++;
	int p_max = 0;
	for (int i = 0; i <= 1000; i++)
		if (p_max < time[i])
			p_max = time[i];
	cout << p_num << ' ' << p_max;

	return 0;
}


int in[20000]={0},out[20000]={0};
char line1[20000], line2[20000];
int t=1,s=1;

struct time
{
    int in;
    int out;
}person[10000];

int convert();

int main()
{

	int	 max = 0;

	cin.getline(line1,20000);
	cin.getline(line2,20000);
	convert();

	for(int i=0; i<1000; i++)
	{
		int counter=0;
		for(int j=0; j<t; j++)
		{
			if(person[j].in<=i && person[j].out>i)
			{
				counter++;
				if(counter>max)
					max=counter;
			}

		}

	}

	cout<<t<<" " <<max;
return 0;
}

int convert()
{

	person[0].in=atof(line1);
	for(int i=0; i<strlen(line1);i++)
	{

		if(line1[i-1]!=',')
			continue;
		else
		{
			person[t].in=atof(&line1[i]);
			t++;
		}
	}

	person[0].out=atof(line2);
	for(int i=0; i<strlen(line2);i++)
	{

		if(line2[i-1]!=',')
			continue;
		else
		{
			person[s].out=atof(&line2[i]);
			s++;
		}
	}

return 0;
}


main()
{
	int i=0,j,k,reach[10000],leave[10000],num=0,max=0;char a;
	do
	{
		scanf("%d%c",&reach[i],&a);
		i++;
	}
	while(a!='\n');
	printf("%d ",i);
	for(j=0;j<i;j++)
		scanf("%d%c",&leave[j],&a);
	for(j=0;j<1000;j++)
	{
		for(k=0;k<=i;k++)
			if(reach[k]<=j&&leave[k]>j)num++;
		if(num>max)max=num;
		num=0;
	}
	printf("%d",max);
}


int main()
{
	int time[1000] = {0}, intime[1000] = {0}, outtime[1000] = {0},
		i = 0, j = 0, peoplesum = 0, maxsum = 0;
	char mark;
	do{
		cin >> intime[i];
		mark = cin.get();
		peoplesum++;
		i++;
	}while(mark != '\n');
	i = 0;
	do{
		cin >> outtime[i];
		mark = cin.get();
		i++;
	}while(mark != '\n');
	for (i = 0; i < peoplesum; i++)
		for (j = intime[i]; j < outtime[i]; j++)
			time[j]++;
	for (j = 0; j < 1000; j++)
		if (time[j] > maxsum)
			maxsum = time[j];
	cout << peoplesum << " " << maxsum;
	return 0;
}


void count(int n, int x[], int y[], int a[]);
int findmax(int a[]);
int main()
{
	int x[1000],y[1000],a[1001] = {0}, n = 0;
	int i;
	for(i = 0; ; i++)
	{
		cin >> x[i];
		n++;
		if(cin.get() != ',')
			break;
	}

	for(i = 0; i < n; i++)
	{
		cin >> y[i];
		cin.get();
	}

	count(n, x, y, a);
	cout << n << " " << findmax(a);
	return 0;
}

void count(int n, int x[], int y[], int a[])
{
	int i, j;
	for(i = 0; i < n; i++)
	{
		for(j = x[i]; j < y[i]; j++)
			a[j]++;
	}
}

int findmax(int a[])
{
	int i;
	int	max = 0;
	for(i = 1; i <= 1000; i++ )
	{
		if(max < a[i])
			max = a[i];
	}

	return max;

}


int main()
{
	int HalaMadrid[10000]={0};
	int BeatFCBarcelona[10000]={0};
	int n;
	int t[1000]={0};
	int max=0;
	int i,j;
for(i=0;i<10000;i++)
HalaMadrid[i]=-1;
for(i=0;i<10000;i++)
BeatFCBarcelona[i]=-1;
for(i=0;i<10000;i++)
{
if(i==0)
scanf("%d",&HalaMadrid[i]);
else scanf(",%d",&HalaMadrid[i]);
}
for(i=0;i<10000;i++)
{
if(i==0)
scanf("%d",&BeatFCBarcelona[i]);
else scanf(",%d",&BeatFCBarcelona[i]);
}
for(i=0;HalaMadrid[i]!=-1;i++);
n=i;
for(i=0;i<1000;i++)
{
	for(j=0;j<n;j++)
	{
		if(i+0.5>=HalaMadrid[j]&&i+0.5<BeatFCBarcelona[j])
			t[i]++;
	}
}
for(i=0;i<1000;i++)
{
	if(max<t[i])
		max=t[i];
}
printf("%d %d\n",n,max);
	return 0;
}


int main()
{
	int i , j , k , r , ren , max;
	int in[2000];
	int r1[2000] , r2[2000];
	char c;

	i = 0;
	while( 1 ){
		scanf( "%d" , &r1[i++] );
		c = getchar();
		if( c == ',' )
			continue;
		else
			break;
	}
	i = 0;
	while( 1 ){
		scanf( "%d" , &r2[i++] );
		c = getchar();
		if( c == ',' )
			continue;
		else
			break;
	}

	ren = i;

	memset( in , 0 , sizeof( in ) );

	for( i = 0 ; i < ren ; i++ ){
		for( j = r1[i] ; j < r2[i] ; j++ ){
			in[j]++;
		}
	}

	max = in[0] ;
	for( i = 1 ; i < 2000 ; i++ ){
		if( in[i] > max )
			max = in[i];
	}

	printf("%d %d\n" , ren , max );

	return 0;
}


int main()
{
	int myarray[1000]={0};
	int people[100000][2]={0};
	int size=0;
	int num=0;
	char a;
	while(1)
	{
		scanf("%d%c",&people[size++][0],&a);
		if(a!=',')break;
	}
	for(int i=0;i<size;i++)
	{
		scanf("%d%c",&people[i][1],&a);
	}
	for(int i=0;i<size;i++)
	{
		for(int j=people[i][0]+1;j<=people[i][1];j++)
		{
			myarray[j]++;
		}
	}
	for(int i=0;i<1000;i++)
	{
		if(myarray[i]>num) num=myarray[i];
	}

	printf("%d %d\n",size,num);
}


int main()
{
int in[1000],out[1000],flag[1000]={0},t;
int i,j,k;
int num=0;
char temp;
for(i=0;;i++){
	cin>>in[i];
	temp=cin.get();
	num++;
	if(temp=='\n')break;
}
for(i=0;;i++){
	cin>>out[i];
	temp=cin.get();
	if(temp=='\n')break;
}
for(i=1;i<=999;i++){
	for(j=0;j<=num-1;j++){
		if(in[j]<=i&&out[j]>i){
			flag[i]=flag[i]+1;
		}
	}
}
int tem=0;
for(i=1;i<=999;i++){
	if(tem<=flag[i]){
		tem=flag[i];
	}
}
	cout<<num<<" "<<tem<<endl;

return 0;
}


int main()
{
	int tim[1000], i, j, num, mac = 0;
	int star[1000],end[1000];
	for(i = 0; i < 1000; i++)
		tim[i] = 0;
	cin >> star[0];
	i = 1;
	while(cin.get() != '\n')
		cin >> star[i++];
	num = i;
	cin >> end[0];
	for(i = 1; i < num; i++)
	{
		cin.get();
		cin >> end[i];
	}
	for(i = 0; i < num; i++)
		for(j = star[i]; j < end[i]; j++)
			tim[j]++;
	for(i = 0; i < 1000; i++)
		mac = mac > tim[i] ? mac : tim[i];
	cout << num << " "<< mac << endl;
	return 0;
}


int main()
{
	int tmax=0;
	int a[3][1001];
	cin>>a[1][1];
	int tmin=a[1][1];
	int sum=1;
	while(cin.get()==',')
	{
		cin>>a[1][sum+1];
		if(a[1][sum+1]<tmin)
			tmin=a[1][sum+1];
		sum++;
	}
	for(int i=1;i<sum;i++)
	{
		cin>>a[2][i];
		if(a[2][i]>tmax)
			tmax=a[2][i];
		getchar();
	}
	cin>>a[2][sum];
	if(a[2][sum]>tmax)
		tmax=a[2][sum];
	cout<<sum<<" ";
	int ren=0;
	for(int t=tmin;t<=tmax;t++)
	{
		int temp=0;
		for(int i=1;i<=sum;i++)
		{
			if(t>=a[1][i]&&t<a[2][i])
			{
				temp++;
			}
		}
		if(ren<temp)
			ren=temp;
	}
	cout<<ren;

	return 0;
}


int main()
{
	int intime[9999],outtime[9999],count=0,sum[1000]={0};
	//intime???????outtime???????count?????sum?????????
	char temp;
	int i=0,j=0,max=0;//????i,j?max?????

	while (1) //?????
	{
		cin>>intime[count];
		cin.get(temp);
		if (temp!='\n')  count++;
		else { count++; break;}
	}
	count=0;
	while (1)  //?????
	{
		cin>>outtime[count];
		cin.get(temp);
		if (temp!='\n')  count++;
		else { count++; break;}
	}

	for (i=0;i<count;i++)
	{
		for (j=intime[i];j<outtime[i];j++)
			sum[j]++;
	}

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

	cout<<count<<" "<<max<<endl;

return 0;}


int main()
{
	int qiumax(int s[1005],int n);
	int a[1005]={0},b[1005]={0},i=0;
	char c;
	do
	{
		i++;
		scanf("%d",&a[i]);
		c=getchar();
	}
	while(c!='\n');
	int num=i;
	for(i=1;i<=num;i++)
	{scanf("%d",&b[i]);c=getchar();}
	int cnt[1002]={0},j,maxb=qiumax(b,num);
	for(i=1;i<=num;i++)
	{
		for(j=a[i];j<b[i];j++)
			cnt[j]++;
	}
	int maxpeople=qiumax(cnt,maxb-1);
	printf("%d %d",num,maxpeople);
	return 0;
}

int qiumax(int s[1005],int n)
{
	int i,max=0;
	for(i=0;i<=n;i++)
	{
		if(s[i]>max)
			max=s[i];
	}
	return max;
}


int convert(int a,int b,char str[])
{
	int i,m=0;
	for(i=a+1;i<b;++i)
		m=m*10+(str[i]-'0');
	return(m);
}
main()
{
	char str[5000];
	int len,i,j,count=1,comma[2000],max;
	gets(str);
	len=strlen(str);
	comma[0]=-1;
	for(i=0;i<len;++i)
		if(str[i]==',')
		{
			comma[count]=i;
			count++;
		}
	comma[count]=len;
	int a[2000],b[2000],c[2000];
	for(i=0;i<1000;++i)
		c[i]=0;
	for(i=0;i<count;++i)
		a[i]=convert(comma[i],comma[i+1],str);
	scanf("%d",&b[0]);
	for(i=1;i<count;++i)
		scanf(",%d",&b[i]);
	for(i=0;i<1000;i++)
		for(j=0;j<count;++j)
			if(i>=a[j]&&i<b[j])
				c[i]++;
	max=c[0];
	for(i=1;i<1000;++i)
		if(c[i]>max)
			max=c[i];
	printf("%d %d",count,max);
}


int main()
{
	char a;
	int x[1000], y[1000], hour[1000] = {0}, peo = 0, temp;

	for (int i = 0; i < 1000; i++)
	{
		cin >> x[i];
		cin.get(a);
	    peo++;
		if (a == '\n') break;
	}
	for (int j = 0; j <= peo; j++)
	{
		cin >> y[j];
		cin.get(a);
		if (a == '\n') break;
	}
	for (int k = 0; k < peo; k++)
	{
		for (int p = x[k]; p < y[k]; p++)
		{
			hour[p]++;
		}
	}
	for (int m = 0; m < 1000; m++)
	{

		if (hour[m] > hour[m + 1])
		{
			temp = hour[m + 1];
			hour[m + 1] = hour[m];
			hour[m] = temp;
		}
	}

	cout << peo << ' ' << hour[999];

	return 0;
}


int t[1005];
int in[1000];
int out[1000];
void main()
{
	char buf[4000], *p;
	int count;
	int i,j;
	int max=0;

	memset(t, 0, sizeof(t));

	fgets(buf, sizeof(buf), stdin);
	i=0;
	p = strtok(buf, ",");
	for (; p; p=strtok(NULL, ","))
	{
		in[i++] = atoi(p);
	}
	count = i;

	fgets(buf, sizeof(buf), stdin);
	i=0;
	p = strtok(buf, ",");
	for (; p; p=strtok(NULL, ","))
	{
		out[i++] = atoi(p);
	}

	for (i=0; i<count; i++)
	{
		int s=in[i];
		int e=out[i];
		for(j=s; j<e; j++)
		{
			t[j] ++;
			if (max<t[j])
				max=t[j];
		}
	}

	printf("%d %d\n",count, max);
}


int main()
{
	int a[1000], b[1000], t[1000] = {0};
	int i, j, count, maxNum = 0;
	i = 0;
	do
	{
		cin >> a[i];
		i++;
	} while (cin.get() != '\n');
	count = i;
	i = 0;
	do
	{
		cin >> b[i];
		i++;
		cin.get();
	} while (i < count);
	for (i = 0; i < count; i++)
		for (j = a[i]; j < b[i]; j++)
			t[j]++;
	for (i = 0; i < 1000; i++)
		if (t[i] > maxNum)
			maxNum = t[i];
	cout << count << " " << maxNum;
	return 0;
}


void main()
{
	int enter[1000]={0},leave[1000]={0},i,j=0,e=0,l=0;
	char c;
	int ans[1000]={0};
	do
	{
		scanf("%d",&enter[e]);
		scanf("%c",&c);
		e++;
	}while(c==',');
	do
	{
		scanf("%d",&leave[l]);
		scanf("%c",&c);
		l++;
	}while(c==',');
	printf("%d",l);
	int start=enter[0],end=leave[0];
	for(j=1;j<l;j++)
	{
		if(start>enter[j])
			start=enter[j];
		if(end<leave[j])
			end=leave[j];
	}
	for(i=start;i<end;i++)
	{
		for(j=0;j<l;j++)
		{
			if(enter[j]<=i&&leave[j]>i)
				ans[i]++;
		}
	}
	int m=ans[start];
	for(j=start;j<end;j++)
	{
		if(m<ans[j])
			m=ans[j];
	}
	printf(" %d",m);
}


int main()
{
    int x[1000] = {0}, y[1000] = {0}, s[1000] = {0};
    int i = 0, j, k, earliest, latest = 0, max = 0;
    char c;
    while (cin >> x[i])
    {
        i++;
        c = getchar();
        if (c == '\n')
            break;
    }
    for (j = 0; j < i; j++)
    {
        cin >> y[j];
        c = getchar();
    }
    earliest = x[0];
    for (j = 0; j < i; j++)
    {
        if (earliest > x[j])
            earliest = x[j];
        if (latest < y[j])
            latest = y[j];
    }
    for (j = earliest; j <= latest; j++)
    {
        for (k = 0; k <= i; k++)
        {
            if (x[k] <= j && y[k] > j)
                s[j]++;
        }
    }
    for (j = earliest; j <= latest; j++)
    {
        if (max < s[j])
            max = s[j];
    }
    cout << i << " " << max << endl;
    return 0;
}


int main()
{
	char a;
	int in[1001] = {0}, out[1001] = {0}, time[1001] = {0}, sumperson = 0, maxperson = 0;
	int i, j;
	for (i = 1; ; i++)
	{
		cin >> in[i];
		cin.get(a);
		sumperson++;
		if (a == '\n')
			break;
	}
	for (i = 1; ; i++)
	{
		cin >> out[i];
		cin.get(a);
		if (a == '\n')
			break;
	}
	for (i = 1; i <= sumperson; i++)
		for (j = in[i]; j < out[i]; j++)
			time[j] += 1;
	for (i = 1; i <=1001; i++)
	{
		if (time[i] > maxperson)
			maxperson = time [i];
	}
	cout << sumperson <<" " << maxperson << endl;
	return 0;
}


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

int main()
{
	int x[1000];
	int y[1000];
	char a;
	int sum = 0;
	int len = 0;
	int n[1001] = {0};
	int i = 0;
	int t = 0;
	int max = 0;

	for( i = 1;;i++ )
	{
		cin >> x[i];
		a = cin.get();

		if( a == '\n')
			break;
	}

	for( i = 1;;i++ )
	{
		cin >> y[i];
		a = cin.get();

		if( a == '\n')
			break;

	}
	sum = i;

	for( t = 1;t <= 1000;t++ )
		for( i = 0;i <= sum;i++ )
		{
			if( t >= x[i] && t < y[i] )
				n[t]++;
		}

	max = 1;

	for( t = 1;t <= 1000;t++ )
	{
		if( n[t] > n[max] )
			max = t;
	}

	cout << sum << " " << n[max];

	return 0;
}


int main()
{
    int time1[10000]={0},time2[10000]={0},p[1001]={0},num,i=0,j=0,k,max=0,temp=0;
    char timein[100000]={0},timeout[100000]={0};
    gets(timein);gets(timeout);
    for(i=0;timein[i]!=0;i++)
    {
                       if(timein[i]>'9'||timein[i]<'0')continue;
                       temp*=10;temp+=timein[i]-'0';
                       if(timein[i+1]>'9'||timein[i+1]<'0'){time1[j]=temp;j++;temp=0; continue;}
    }
    temp=0;cout<<j<<' ';j=0;
    for(i=0;timeout[i]!=0;i++)
    {
                       if(timeout[i]>'9'||timeout[i]<'0'){continue;}

                       temp*=10;temp+=timeout[i]-'0';
                       if(timeout[i+1]>'9'||timeout[i+1]<'0'){time2[j]=temp;j++;temp=0; continue;}
    }
    for(i=0;i<=j;i++)
          for(k=time1[i];k<time2[i];k++)p[k]++;
    for(j=0;j<1001;j++)if(max<p[j]){max=p[j];}
    cout<<max;
    getchar();getchar();
    return 0;
}


int main()
{
     int i,j,n,m,temp,arrive[1600],leave[1600],times[1001]={0};
     char c;
     c=getchar();
     while(c!=EOF)
     {
       n=0;
       while(c!='\n')
       {
         m=c-'0';
         temp=0;
         while((m<=9)&&(m>=0))
         {
           temp=temp*10+m;
           c=getchar();
           m=c-'0';
          }
          arrive[n]=temp;
          n++;
          if(c==',')
	  c=getchar();

         }
	c=getchar();
       n=0;
       while(c!='\n')
       {
         m=c-'0';
         temp=0;
         while((m<=9)&&(m>=0))
         {
           temp=temp*10+m;
           c=getchar();
           m=c-'0';
          }
          leave[n]=temp;
          n++;
          if(c==',')
	   c=getchar();
         }
	for(i=0;i<n;i++)
	{
		for(j=arrive[i];j<leave[i];j++)
			times[j]++;
	}
	int max=0;
	for(i=0;i<1000;i++)
	{
		if(max<times[i]) max=times[i];
	}
	printf("%d %d\n",n,max);
         while(c=='\n')
	  c=getchar();

      }
}


int main()
{
	int a[1000] = { 0 } , b[1000] = { 0 } ;
	int i , total , num , min , max , k ;
	char c ;
	i = 0 ;
	while ( c != '\n' )
	{
		cin >> num ;
		a[i] = num ;
		i++ ;
		c = cin.get() ;
	}
	for ( k = 0 ; k <= i - 1 ; k++ )
	{
		cin >> num ;
		b[k] = num ;
		c = cin.get() ;
	}
	total = i ;
	max = b[1] ;
	min = a[1] ;
	for ( i = 0 ; i <= total - 1 ; i++ )
	{
		if ( min >= a[i] )
			min = a[i] ;
		if ( max <= b[i] )
			max = b[i] ;
	}
	int x[1001] = { 0 } ;
	for ( k = 0 ; k <= total - 1 ; k++ )
		for ( i = a[k] ; i <= b[k] - 1 ; i++ )
			x[i] = x[i] + 1 ;
	int max1 = 0 ;
	for ( i = min ; i <= max ; i++ )
	{
		if ( max1 < x[i] )
			max1 = x[i] ;
	}
	cout << total << " " << max1 << endl ;
	return 0 ;
}


void main(void)
{
	int n=0,start[1000],end[1000];
	char c=',';
	while(c!='\n')
	{
		scanf("%d%c",&start[n],&c);
		n++;
	}

	int i;
	for(i=0;i<=n-1;i++)
		scanf("%d%c",&end[i],&c);

	int time=0;
	for(i=0;i<=n-1;i++)
		if(time<end[i])
			time=end[i];

	int member[1000],j;

	for(i=0;i<=time-1;i++)
		member[i]=0;

	for(i=0;i<=n-1;i++)
		for(j=start[i];j<end[i];j++)
			member[j-1]++;

	int max=0;
	for(i=0;i<=time-1;i++)
		if(max<member[i])
			max=member[i];

	printf("%d %d\n",n,max);
}


/*Conversion from characters to numbers*/
void char2int (int *length, char *a, int* aa){
    int temp = 0, k = 0;
    for(int j=0; j<*length; ++j){
        if(a[j] == ','){
            temp = 0;
            ++k;
        }
        else
            aa[k] = 10 * aa[k] + a[j]-'0';
    }
}

int main(){
    char c, a[4*1000], b[4*1000];
    int aa[1000] ={0}, bb[1000] = {0}, stat[1000]={0};
    int i = 0, num = 0, length1 = 0, length2 = 0, maxindex=0, in, out;
    while(scanf("%c",&c)!=EOF && c!='\n'){
        a[i++] = c;
        ++length1;
        if(c == ',')
            ++num;
    }
    i = 0;
    while(scanf("%c",&c)!=EOF && c!='\n'){
        b[i++] = c;
        ++length2;
    }
    char2int(&length1, a, aa);
    char2int(&length2, b, bb);
    ++num;
    for(int i=0; i<num; ++i){
        in = aa[i];
        out = bb[i];
        for(int j=in; j<out; ++j)
            ++stat[j];
    }
    for(int i=0; i<1000; ++i)
        if(stat[i] > stat[maxindex])
            maxindex = i;
    cout << num << " " << stat[maxindex] << endl;
    return 0;
}


/*
 * wanyi.cpp
 *
 *  Created on: 2012-11-10
 *      Author: 7
 */
int main()
{
	int x[1000];
	int y[1000];
	char a;
	int i=0,j,num=0,max=0,n,minx=10000,maxy=0;
	while(cin>>x[i])
	{
		if(x[i]<minx)
			minx=x[i];
		i++;
		cin.get(a);
		if(a=='\n')
			break;
	}
	n=i;
	i=0;
	while(cin>>y[i])
		{
		if(y[i]>maxy)
			maxy=y[i];
			i++;
			cin.get(a);
			if(a=='\n'||i>n)
				break;
		}
	for(i=minx;i<maxy;i++)
	{
		for(j=0;j<n;j++)
		{
			if(i>=x[j]&&i<y[j])
			{
				num++;
				if(num>max)
					max=num;
			}
		}
		num=0;
	}
	cout<<n<<" "<<max;
}


int main()
{
	int a[1001]={0},b[1001]={0};//???????
	int i=1,count,max1=INT_MIN,min1=INT_MAX,MAX=0,total=0;//??????????????
	while(1)//?????????? ????
	{
		scanf("%d", &a[i++]);
		char c = cin.get();
		if(c=='\n')
		{
			count=i;
			break;
		}
	}
	i=1;
	while(1)
	{
		scanf("%d", &b[i++]);
		char c = getchar();
		if(c=='\n')break;
	}
	count=i-1;
	for(int j=1;j<=count;j++)
		min1=min1>=a[j]?a[j]:min1;
	for(int j=1;j<=count;j++)
		max1=max1<=b[j]?b[j]:max1;
	for(int l=min1;l<=max1;l++)
	{
		for(int k=1;k<=count;k++)
		{
			if(a[k]==l)
			{
				total++;
			}
			if(b[k]==l)
			{
				total--;
			}

		}
		MAX=MAX>=total?MAX:total;
	}

	cout<<count<<" "<<MAX<<endl;
	return 0;
}


int main()
{
	char come[110000],go[110000];
	cin.getline(come,110000);
	cin.getline(go,110000);
	int x=1,i,j=1;
	int people=1,size=strlen(come);
	for(i=0;i<size;i++)
		if(come[i]==',')
		  people++;
		cout<<people;
	int come1[1000],go1[1000];
	come1[0]=atoi(come);
	for(i=0;i<size;i++)
		if(come[i]==',')
		{
			come1[j]=atoi(come+i+1);
			j++;
		}
	j=1;
	size=strlen(go);
	go1[0]=atoi(go);
	for(i=0;i<size;i++)
		if(go[i]==',')
		{
			go1[j]=atoi(go+i+1);
			j++;
		}
	int max=0;
	for(i=0;i<=1000;i++)
	{
		int number=0;
		for(j=0;j<people;j++)
		{
			if(i>=come1[j]&&i<go1[j])
				number++;
		}
		if(number>max)
			max=number;
	}

	cout<<' '<<max;
	return 0;

}


int main()
{
	int start[1000], end[1000], num = 0, i, j, max = 0, total;
	char c;
	for(num = 1; cin >> start[num - 1], (c = cin.peek() == ','); cin >> c, num++)
		;
	cin >> end[0];
	for(i = 1; i < num; i++)
		cin >> c >> end[i];
	for(i = 0; i < 1000; i++)
	{
		total = 0;
		for(j = 0; j < num; j++)
			if(start[j] <= i && i < end[j])
				total++;
		if(total > max)
			max = total;
	}
	cout << num << ' ' << max;
	return 0;
}


int max_people(int x[],int y[],int num)
{
	int i,j,max=0,temp;
	for(i=0;i<1000;i++)
	{
		temp=0;
		for(j=0;j<num;j++)
		{
			if((i>=x[j])&&(i<y[j]))
				temp++;
		}

		if(temp>max)
			max=temp;
	}
	return max;
}

void main()
{
	int i,num=0,x[8000],y[8000];
	char c;
	do
	{
		scanf("%d%c",&x[num++],&c);
	}while(c!='\n');
	num=0;
	do
	{
		scanf("%d%c",&y[num++],&c);
	}while(c!='\n');
	printf("%d ",num);
	int max=max_people(x,y,num);
	printf("%d",max);
}


int main()
{
	int x[1000 + 10] = {0}, y[1000 + 10] = {0}, presence[1000 + 10] = {0};
	int digit, i, j, k, nperson = 0, finaltime = 0;
	char c;
	cin >> x[nperson ++];
	while ((c = cin.get()) != '\n')
	{
		if (c == ',')
		{
			cin >> digit;
			x[nperson] = digit;
			nperson ++;
		}
	}
	nperson = 0;
	cin >> y[nperson ++];
	while ((c = cin.get()) != '\n')
	{
		if (c == ',')
		{
			cin >> digit;
			y[nperson] = digit;
			nperson ++;
			finaltime = finaltime > digit ? finaltime : digit;
		}
	}
	//cout << nperson;
	//for (i = 0; i < nperson; i ++)
	//	cout << x[i] << " ";
	//cout << endl;
	//for (i = 0; i < nperson; i ++)
	//	cout << y[i] << " ";
	//cout << endl;

	for (i = 0; i < nperson; i ++)
	{
		for (j = x[i]; j <= y[i] - 1; j ++)
			presence[j] ++;
	}
	int maxperson = 0;
	for (i = 0; i < finaltime; i ++)
	{
		//cout << presence[i] << " ";
		maxperson = maxperson > presence[i] ? maxperson : presence[i];
	}
	//cout << endl;
	cout << nperson << " " << maxperson << endl;
	return 0;
}


int main()
{
	char inp1[4000],inp2[4000];
	cin>>inp1>>inp2;

	int time1[1000],time2[1000];
	char temp[4];

	int pointer=0;
	int people=0;
	for(int k=0;inp1[k]!='\0';k++)
	{
		if(inp1[k]!=',')
		{
			temp[pointer++]=inp1[k];
		}
		else
		{
			temp[pointer]='\0';
			time1[people++]=atoi(temp);
			pointer=0;
		}
	}
	temp[pointer]='\0';
	time1[people++]=atoi(temp);

	pointer=0;
	people=0;
	for(int k=0;inp2[k]!='\0';k++)
	{
		if(inp2[k]!=',')
		{
			temp[pointer++]=inp2[k];
		}
		else
		{
			temp[pointer]='\0';
			time2[people++]=atoi(temp);
			pointer=0;
		}
	}
	temp[pointer]='\0';
	time2[people++]=atoi(temp);

	int max=0;
	for(int k=0;k!=1000;k++)
	{
		int counter=0;
		for(int i=0;i!=people;i++)
		{
			if(k>=time1[i]&&k<time2[i])
				counter++;
		}
		if(counter>max)
			max=counter;
	}
	cout<<people<<" "<<max<<endl;
	return 0;
}


int main( )
{
	int time,count=0,a[1001]={0},i;
	char b;
	while(1)
	{
		cin>>time;
		a[time]++;
		count++;
		if(cin.get()!=',')
			break;
	}
	for(i=0;i<count;++i)
	{
		cin>>time>>b;
		a[time]--;
	}
	int max=0,renshu=0;
	for(i=0;i<1001;++i)
	{
		renshu+=a[i];
		if(renshu>max)
			max=renshu;
	}
	cout<<count<<" "<<max;
	return 0;
}


int main()
{
    const int max_size = 1000;
    int l[max_size], r[max_size];
    for (int i = 0; i < max_size; ++i)
    {
        l[i] = 0;
        r[i] = 0;
    }
    int x, att; char ch;

    att = 1;
    cin >> x; ch = cin.get();
    ++ l[x];
    while (ch == ',')
    {
       cin >> x; ch = cin. get();
       ++ l[x];
       ++att;
    }
    cout << att << " ";
    cin >> x; ch = cin.get();
    ++ r[x];
    while (ch == ',')
    {
       cin >> x; ch = cin.get();
       ++ r[x];
    }

    int ans, num;
    ans = 0; num = 0;
    for (int i = 0; i < max_size; ++i)
    {
        num = num + l[i] - r[i];
        if (num > ans)
        {
                ans = num;
        }
    }
    cout << ans;
    return 0;
}


int main()
{
	int arrivetime[1000],leavetime[1000];
	int i=0,j=0,k,p,q;
	do{
		cin>>arrivetime[i];
		i++;
	}while(cin.get()!='\n');
	do{
		cin>>leavetime[j];
		j++;
	}while(cin.get()!='\n');
	int tpi,Endtime,Time,bein=0,mostbein=0;
	tpi=i;
	Endtime=leavetime[0];
	for(k=1;k<i;k++)
	{
		if(Endtime<leavetime[k])
		{Endtime=leavetime[k];}
		else
		{continue;}
	}
	for(Time=0;Time<=Endtime;Time++)
	{
		for(p=0;p<i;p++)
		{
			if(arrivetime[p]==Time)
			{
				bein++;
			}
			else
			{continue;}
		}
		for(q=0;q<i;q++)
		{
			if(leavetime[q]==Time)
			{
				bein--;
			}
			else
			{continue;}
		}
		if(mostbein<bein)
		{
			mostbein=bein;
		}
		else
		{continue;}
	}
	cout<<tpi<<" "<<mostbein<<endl;
	return 0;
}


int main()
{
	int count, i = 0, j, a[1000][2], max = 0;
	char ch;
	double temp;
	while(1)
	{
		cin >> a[i][0];
		i++;
		if ((ch = cin.get()) == '\n')
			break;
	}
	i = 0;
	while(1)
	{
		cin >> a[i][1];
		i++;
		if ((ch = cin.get()) == '\n')
			break;
	}
	for (temp = 0.5; temp < 1000; temp++)
	{
		count = 0;
		for (j = 0; j < i; j++)
			if (temp > a[j][0] && temp < a[j][1])
				count++;
		if (count > max)
			max = count;
	}
	cout << i << ' ' << max;
	return 0;
}


/*
 *???: party.cpp
 *??: ???
 *????: 2012-11-09
 *??:
 */

int main()
{
	int times[1000]={0};
	int start[1000],end[1000];
	int nPeople=0,mostPeople;
	char str[10000];
	cin.getline(str,sizeof(str));
	int readnum=0;
	for (int i=0; ;i++){
		switch(str[i]){
			case ',':
			case '\0':
				start[nPeople++]=readnum;
				readnum=0;
				break;
			default:
				readnum=readnum*10+str[i]-'0';
		}
		if (!str[i])
			break;
	}
	for (int i=0;i<nPeople;i++){
		char endchr;
		if (i<nPeople-1)
			endchr=',';
		else endchr='\n';
		cin.getline(str,sizeof(str),endchr);
		end[i]=atoi(str);
	}
	for (int i=0;i<nPeople;i++){
		for (int j=start[i];j<end[i];j++)
			times[j]++;
	}
	mostPeople=times[0];
	for (int i=1;i<1000;i++){
		if (times[i]>mostPeople)
			mostPeople=times[i];
	}
	cout << nPeople << ' ' << mostPeople << endl;
}


int main()
{
	int time[1001]={0};
	int xi[1001];
	int yi[1000];
	int i=0,n,j;
	char ch=',';

	while( ch!='\n' )
	{
		scanf("%d",&xi[i]);
		ch=getchar();
		i++;
	}
	i=0;
	ch=',';
	while( ch!='\n' )
	{
		scanf("%d",&yi[i]);
		ch=getchar();
		i++;
	}
	n=i;

	for( i=0;i<n;i++ )
	{
		for(j=xi[i];j<yi[i];j++)
			time[j]++;
	}
	int max=0;

	for(i=0;i<1001;i++)
		if( time[i]>=max )
			max=time[i];
	printf("%d %d\n",n,max);

	return 0;
}


int main()
{
	int begin[max], end[max];
	int i = 0;
	for (i = 0;; i++)
	{
		cin >> begin[i];
		char c = getchar();
		if (c == '\n')break;
	}	i++;

	for (int j = 0; j < i; j++)
	{
		cin >> end[j];
		char c = getchar();
		if (c == '\n')break;

	}

	cout << i;
	int num[1001] = { 0 };
	for (int j = 0; j < i;j++)
	for (int k = begin[j]; k < end[j]; k++)
		num[k]++;
	int imax = 0;
	for (int j = 0; j < max;j++)
	if (num[j]>imax)imax = num[j];
	cout <<" "<< imax;

}


int main ()
{
	int i,j,m,max=0,a[1001]={0},b[1001]={0},sum[1001]={0},count=0;

	char ch;

	while(1)
	{
		cin >> a[count] ;
		count ++ ;
		ch=cin.get();
		if (ch!=',')
		{
			break ;
		}
	}
	count=0;
	while(1)
	{
		cin >> b[count] ;
		count++;
		ch=cin.get();
		if (ch!=',')
		{
			break ;
		}
	}
	for (i=0;i<count;i++)
	{
		for (j=a[i];j<b[i];j++)
		{
			sum[j]++;
		}
	}
	for (i=1;i<=1000;i++)
	{
		if (sum[i]>max)
			max=sum[i];
	}
	cout <<count<<" "<<max<<endl;

	return 0;
}


char temp[5] = {0};
char in[100000] = {0};
char out[100000] = {0};
int intime[1000] = {0};
int outtime[1000] = {0};
int longtime[1000] ={0};

int main()
{
	cin.getline(in,100000);
	cin.getline(out,100000);

	int i, j;
	int p = 0;
	int q = 0;

	for (i = 0; in[i] != '\0'; i++)
	{
		if (in[i] == ',')
		{
			intime[p] = atoi(temp);
			memset(temp,0,5);
			p++;
			q = 0;
			continue;
		}
		temp[q] = in[i];
		q++;
	}

	intime[p] = atoi(temp);
	p++;

	q = p = 0;

	for (i = 0; out[i] != '\0'; i++)
	{

		if (out[i] == ',')
		{
			outtime[p] = atoi(temp);
			memset(temp,0,5);
			p++;
			q = 0;
			continue;
		}
		temp[q] = out[i];
		q++;

	}

	outtime[p] = atoi(temp);
	p++;

	int x = 0, y = 0;
	int max = 0;

	for (j = 0; j < p ; j++)
	{
		for (x = intime[j]; x < outtime[j]; x++)
		{
			longtime[x]++;
		}
	}

	for (y = 0; y < 1000; y++)
	{
		if (longtime[y] > max)
		{
			max = longtime[y];
		}
	}

	cout << p << " " << max << endl;

	return 0;

}


int main()
{
	int come[1000]={0};
	int leave[1000]={0};
	char comma;
	int i=0;
	int j=0;
	int total=0;
	int together=0;
	int count[1000]={0};
	cout<<endl;
	for(i=0;;i++)
	{
		cin>>come[i];
		comma=cin.get();
		if(comma==',')
			continue;
		else if(comma=='\n')
		{
			total=i+1;
			break;
		}
	}
	for(i=0;;i++)
	{
		cin>>leave[i];
		comma=cin.get();
		if(comma==',')
			continue;
		else if(comma=='\n')
			break;
	}
	for(i=0;i<total;i++)
	{
		for(j=come[i];j<leave[i];j++)
		{
			count[j]++;
		}
	}
	for(j=1;j<1000;j++)
	{
		if(count[j]>together)
		{
			together=count[j];
		}
	}
	cout<<total<<" "<<together<<endl;
	return 0;
}


int main ()
{
	int itime[10000],otime[10000],sum[1000];  //itime???????otime???????sum???????????
	int count=0,i=0,j=0,max=0;    //count??????i,j??????
	char temp;
	memset(sum,0,sizeof(sum));  //?????
	while(1)    //??????
	{
		cin>>itime[count];
		cin.get(temp);
		if(temp!='\n')  count++;
		else    { count++;   break;}
	}
	count=0;
	while(1)   //??????
	{
	cin>>otime[count];
	cin.get(temp);
	if(temp!='\n')   count++;
	else    {count++;  break;}
	}
	for(i=0;i<count;i++)    //????
	{
		for(j=itime[i];j<otime[i];j++)
			sum[j]++;
	}
	for(i=0;i<1000;i++)
	{
		if(  sum[i]>max )   max=sum[i];
	}
	cout<<count<<" "<<max<<endl;   //??????????????????
	return 0;
}


int fxiao(int N1[],int n)
{
	int i,xiao;
	xiao=N1[0];
	for(i=0;i<n;i++)
		if(N1[i]<xiao)xiao=N1[i];
	return xiao;
}
int fda(int N2[],int n)
{
	int i,da;
	da=N2[0];
	for(i=0;i<n;i++)
		if(N2[i]>da) da=N2[i];
	return da;
}

void main()
{
	int N1[1002],N2[1002];
	char b[1002];
	int i,j,num;
	for(i=0;;i++)
	{	scanf("%d%c",&N1[i],&b[i]);
	    if(b[i]!=',') {num=i+1;break;}
	}
	for(i=0;i<num;i++)
		scanf("%d%c",&N2[i],&b[i]);
    printf("%d ",num);
	int min=fxiao(N1,num),max=fda(N2,num);
	int N[1001]={0},k;
	for(i=min;i<=max;i++)
		for(j=0;j<num;j++)
		{if(i>=N1[j]&&i<N2[j])N[i]++;}
	int p=fda(N,max-min+1);
	printf("%d\n",p);
}


int main()
{
	int i=0,figure,figuremax,time,n,start[1001],end[1001];
	char sign;
	do
	{
		i++;
		cin>>start[i];
		cin.get(sign);
		if(sign=='\n') break;
	}while(1);
	n=i;
	for(i=1;i<=n;i++)
	{
		cin>>end[i];
		cin.get(sign);
	}
	cout<<n<<' ';
	figuremax=0;
	for(time=0;time<=1000;time++)
	{
		figure=0;
		for(i=1;i<=n;i++)
		{
			if(time>=start[i]&&time<end[i]) figure++;
		}
		if(figure>figuremax) figuremax=figure;
	}
	cout<<figuremax;

	return 0;
}


int main()
{
	int n,a[50000],b[50000];
	int i,count=0;
	scanf("%d",&n);
	int min=10000,max=0;
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		if(a[i]<min)
			min=a[i];
		if(b[i]>max)
			max=b[i];
	}
	double k;
	if(min==max)
		printf("%d %d",min,max);
	else
	{
		for(k=min+0.5;k<max;k++)
		{
			int mark=0;
			for(i=0;i<n;i++)
			{
				if(k>a[i]&&k<b[i])
				{
					mark=1;
					break;
				}
			}
			if(mark==1)
				count++;
		}
		if(count==(max-min))
			printf("%d %d",min,max);
		else printf("no");
	}
	return 0;
}


int judge(int x,int y,int z){
	if(x>=y&&x<=z){return 1;}
	return 0;

}
int main(){

	int max,min,start[50000],end[500000],all,i,p,ornot;
	max=0;min=9999;
	scanf("%d",&all);
	for(i=0;i<all;i++){scanf("%d %d",&start[i],&end[i]);if(max<end[i]){max=end[i];}if(min>start[i]){min=start[i];}}
	for(i=0;i<all;i++){ornot=0;for(p=0;p<all;p++){if(i!=p&&judge(start[i],start[p],end[p])){ornot=1;}if(start[i]==min){ornot=1;}}if(ornot==0){printf("no");return 0;}}
	for(i=0;i<all;i++){ornot=0;for(p=0;p<all;p++){if(i!=p&&judge(end[i],start[p],end[p])){ornot=1;}if(end[i]==max){ornot=1;}}if(ornot==0){printf("no");return 0;}}
	printf("%d %d",min,max);

return 0;}


struct area{
	int start;
	int end;
};
void main(){
	struct area area[50002],temp;
	int n,i,j,s,e,flag=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&area[i].start,&area[i].end);
	}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(area[i].start>area[j].start){
				temp=area[i];
				area[i]=area[j];
				area[j]=temp;
			}
		}
	}
		s=area[0].start;
		e=area[0].end;
	for(i=0;i<n;i++){
		if(area[i].start>e){

			flag=1;
                            break;
		}
		else if(area[i].start<=e  && e<=area[i].end){
			e=area[i].end;
		}
	}
	if(flag)
		printf("no");
	else
		printf("%d %d\n",s,e);
}


int main(){
    int i,j,min,max,n;
    int sz[50010];
    scanf("%d",&n);
    struct cui{
 int x;
 int y;
}cui[qujian];
for(i=0;i<n;i++){
    scanf("%d%d",&(cui[i].x),&(cui[i].y));
}
min=cui[0].x;
max=cui[0].y;
for(i=0;i<n;i++){
    if(cui[i].x<min){
        min=cui[i].x;
    }
}
for(i=0;i<n;i++){
    if(cui[i].y>max){
        max=cui[i].y;
    }
}
for(i=min;i<=max;i++){
    sz[i]=1;
}
for(i=0;i<n;i++){
    for(j=(cui[i].x);j<(cui[i].y);j++){
        sz[j]=0;
    }
}
for(i=min;i<max;i++){
    if(sz[i]==1){
printf("no");
return 0;
    }}
printf("%d %d",min,max);
return 0;
}


int main()
{
	struct point
	{
		int a,b;
	}
	c[50001],t;
	int n,i,j;
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d%d",&c[i].a,&c[i].b);
	for (i=1;i<n;i++)
	  for (j=n;j>i;j--)
	  {
  		 if (c[j].a<c[j-1].a)
  		 {
 		  	t=c[j];c[j]=c[j-1];c[j-1]=t;
         }
  	  }
     int st=c[1].a,en=0;
     for (i=1;i<n;i++)
     {
     	if (c[i].b>en) en=c[i].b;
        if (en<c[i+1].a) break;

     }
     if (i<n) printf("no");
       else printf("%d %d",st,en);
     return 0;
}


struct couple
{
       int x;
       int y;
};

int main(int argc, char *argv[])
{
  int n,i,j;
  scanf("%d",&n);
  struct couple line[n],temp;
  for (i=0;i<=n-1;i++)
      scanf("%d%d",&line[i].x,&line[i].y);
  int min=line[0].x,max=line[0].y;
  for (i=0;i<=n-1;i++)
  {
      if (line[i].x<min)
      min=line[i].x;
      if (line[i].y>max)
      max=line[i].y;
  }
  int a[max-min+1];
  for (i=0;i<=max-min;i++)
      a[i]=1;
  for (i=0;i<=n-1;i++)
  {
      for (j=line[i].x-min;j<=line[i].y-min-1;j++)
      a[j]=0;
  }
  int flag=1;
  for (i=0;i<=max-min-1;i++)
  {
      if (a[i]!=0)
      flag=0;
  }
  if (flag==0)
  printf("no");
  else
  printf("%d %d",min,max);
  return 0;
}


int main()
{
	int max,min,n,a[len],b[len],i,j,jg[len];
	scanf("%d",&n);
	scanf("%d %d",&a[0],&b[0]);
	max=min=a[0];
	for(i=1;i<n;i++)
	{
		scanf("%d %d",&a[i],&b[i]);
		if(b[i]>max)
		{
			max=b[i];
		}
		if(a[i]<min)
		{
			min=a[i];
		}
	}
	for(i=min;i<max;i++)
	{
		jg[i]=0;
	}
	for(j=0;j<n;j++)
	{
		for(i=a[j];i<b[j];i++)
		{
			jg[i]=1;
		}
	}
	for(i=min;i<max;i++)
	{
	if(jg[i]==0)
		{
			printf("no");
			break;
		}
	if(i==max-1)
		{
			printf("%d %d",min,max);
		}

	}
	return 0;
}


int main(){
    int n,min=10000,max=0,p,q=0;
    int az[50000],bz[50000],sz[10000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d %d",&az[i],&bz[i]);
    }
    for(int k=0;k<n;k++){
        if(min>az[k]){
           min=az[k];
        }
        if(max<bz[k]){
           max=bz[k];
        }
    }
    p=max-min;
    for(int m=min;m<=max;m++){
        sz[m]=0;
    }
    for(int t=0;t<n;t++){
        for(int x=az[t];x<bz[t];x++){
            sz[x]=1;
        }
    }
    for(int y=min;y<=max;y++){
        q=q+sz[y];
    }
    if(p==q){
        printf("%d %d",min,max);
    } else{
        printf("no");
    }
    return 0;
}


int main()
{
	struct qujian
	{
		int a;
		int b;
	}qj[50000],temp;
	int i,n,j,max;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&qj[i].a,&qj[i].b);
	}
	for(i=n-1;i>0;i--){
		for(j=0;j<i;j++){
			if(qj[j].a>qj[j+1].a){
				temp=qj[j];
				qj[j]=qj[j+1];
				qj[j+1]=temp;
			}
		}
	}
	max=qj[0].b;
	for(i=0;i<n-1;i++){
		if(qj[i].b>max){
			max=qj[i].b;
		}
		if(max<qj[i+1].a){
			printf("no");
			break;
		}
	}
	if(qj[n-1].b>max){
		max=qj[n-1].b;
	}
	if(i==n-1){
		printf("%d %d",qj[0].a,max);
	}
	return 0;
}


int main(){
	int n;
	scanf("%d",&n);
	int qujian[50000][2];
	int row;
	for(row=0;row<n;row++){
			scanf("%d%d",&qujian[row][0],&qujian[row][1]);
	}

	int i,zuo,you;
	for(i=1;i<n;i++){
		for(row=0;row<n-i;row++){
			if(qujian[row][0]>qujian[row+1][0]){
				zuo=qujian[row+1][0];
				you=qujian[row+1][1];
				qujian[row+1][0]=qujian[row][0];
				qujian[row+1][1]=qujian[row][1];
				qujian[row][0]=zuo;
				qujian[row][1]=you;
			}
		}
	}

	int jieguo=0,p;
	for(row=1;row<n;row++){
		for(p=0;p<row;p++){
			if(qujian[p][1]>=qujian[row][0]){
				jieguo++;break;
		}
	}
	}

	int j,e;
	for(j=1;j<n;j++){
		for(row=0;row<n-j;row++){
			if(qujian[row][1]>qujian[row+1][1]){
				e=qujian[row+1][1];
				qujian[row+1][1]=qujian[row][1];
				qujian[row][1]=e;
			}
		}
	}

	if(jieguo==n-1){
		printf("%d %d",qujian[0][0],qujian[n-1][1]);
	}
	else{
		printf("no");
	}
	return 0;
}


int main()
{
  // for every point i, point[2i] stands for [i,i], point[2i+1] stands for (i,i+1)
  // if point[i] == 1, it stands that this interval is included
  int n, point[2001];
  scanf("%d", &n);
  int i;
  int left = 2001;
  int right = 0;
  for (i = 1 * 2; i <= 1000 * 2; i++)
    point[i] = 0;
  for (i = 1; i <= n; i++)
    {
      int a, b;
      scanf("%d%d", &a, &b);
      if (a < left)
	left = a; // find the leftest point
      if (b > right)
	right = b; // find the rightest point
      int j;
      for (j = a * 2; j <= b * 2; j++)
	point[j] = 1;
    }
  int in = 0; // if in an interval, then value is 1, or the value is 0
  int num = 0; // number of interval(s)
  for (i = 1 * 2; i <= 1000 * 2; i++)
    if (point[i] == 1)
      {
	if (in == 0)
	  {
	    in = 1;
	    num++;
	  }
      }
    else
      if (in == 1)
	in = 0;
  if (num == 1)
    printf("%d %d\n", left, right);
  else
    printf("no\n");

  return 0;
}


int t[30000];
int max(int a,int b)
{return a>b?a:b;}
int min(int a,int b)
{return a<b?a:b;}

int main()
{
 int i,j,n,a,b,ma=0,mi=999999,f=1;
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
        scanf("%d%d",&a,&b);
        ma=max(ma,b);
        mi=min(mi,a);
        for(j=2*a;j<=2*b;j++)
        t[j]=1;
 }
        for(i=2*mi;i<=2*ma;i++)
    if(!t[i])f=0;
    f?printf("%d %d",mi,ma):printf("no");

        return 0;
}


int main(){
int i,n,g=1,a[50000],b[50000],min,max;
double x,t;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d%d",&a[i],&b[i]);
	}
min=a[0];max=b[0];
for(i=1;i<n;i++){
if(a[i]<min){
             min=a[i];
             }
if(b[i]>max){
             max=b[i];
             }
}
t=0.5+(double)min;
for(x=t;x<max;x=x+1.0){
for(i=0;i<n;i++){
      if(a[i]<x&&x<b[i]){
                         break;
                         }
      else if(i==n-1){
           g=0;
           printf("no");
           break;
           }
      }
if(g==0){
         break;
}
else if(x==(float)max-0.5){
     printf("%d %d",min,max);
     }
}
return 0;
}


int main(){
	int n,i,j,t,flag,aright;
	struct{
		int l;
		int r;
	}qj[50001];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&qj[i].l,&qj[i].r);
	}
	for(i=n-1;i>0;i--){
		for(j=0;j<i;j++){
			if(qj[j].l>qj[j+1].l){
				t=qj[j].l;
				qj[j].l=qj[j+1].l;
				qj[j+1].l=t;
				t=qj[j].r;
				qj[j].r=qj[j+1].r;
				qj[j+1].r=t;
			}
		}
	}
	for(i=n-1;i>0;i--){
		for(j=0;j<i;j++){
			if(qj[j].l==qj[j+1].l && qj[j].r>qj[j+1].r){
				t=qj[j].r;
				qj[j].r=qj[j+1].r;
				qj[j+1].r=t;
			}
		}
	}
	flag=1;
	aright=qj[0].r;
	j=1;
	do{
		if(j==n){
			flag==1;
			break;
		}
		if(aright<qj[j].l){
			flag=0;
			break;
		}else if(aright>=qj[j].l && aright<qj[j].r){
			aright=qj[j].r;
			j++;
		}else{
			j++;
		}
	}while(1);
	if(flag==0){
		printf("no\n");
	}else{
		printf("%d %d\n",qj[0].l,aright);
	}
	return 0;
}


int main()
{
      struct{
             int a;
             int b;
             }st[5001];
      int i,j,n,k;
      int l=0;
      int swap1,swap2;
      scanf("%d",&n);
      for(i=0;i<n;i++)
      {
          scanf("%d%d",&st[i].a,&st[i].b);
      }
      for(i=0;i<n-1;i++)
      {
          for(j=n-1;j>0;j--)
          {
              if(st[j].a<st[j-1].a)
              {
                  swap1 = st[j].a;
                  st[j].a = st[j-1].a;
                  st[j-1].a = swap1;
                  swap2 = st[j].b;
                  st[j].b = st[j-1].b;
                  st[j-1].b = swap2;
              }
          }
      }
      int t;
      t = st[0].b;
      for(i=1;i<n;i++)
      {
                      if(st[i].a > t)
                      {
                                 break;
                                 }
                                 else
                                 {
                                     if(t < st[i].b)
                                     t=st[i].b;
                                 }
                      }
                      if(i != n)
                      {
                                 printf("no");
                       }
else
{
    printf("%d %d",st[0].a,t);
}

      return 0;
}