#include<stdio.h>
struct trie
{
    int data;
    int count;
    struct trie *children[2];
};
struct trie *newnode(int data,int count)
{
    struct trie *ptr=(struct trie *)malloc(sizeof(struct trie));
    ptr->data=data;
    ptr->count=count;
    ptr->children[0]=NULL;
    ptr->children[1]=NULL;
}
int insert(char array[],struct trie *root)
{
    int i=0;
    while(array[i])
    {
        if(root->children[array[i]-'0'])
            root=root->children[array[i]-'0'];
        else
        {
            root->children[array[i]-'0']=newnode(array[i]-'0',0);
            root=root->children[array[i]-'0'];
        }
        i++;
    }
    root->count=root->count+1;
    return root->count;
}
int main()
{
    struct trie *root=newnode(0,0);
    int n,i,j;
    scanf("%d",&n);
    char array[n+1];
    int max=0;
    for(i=0;i<n;i++)
    {
        getchar();
        scanf("%s",array[i]);
        if((j=insert(array[i],root))>max)
            max=j;
    }
    printf("%d",max);
    return 0;
}


#include<stdio.h>
struct trie
{
    int data;
    int count;
    struct trie *children[2];
};
struct trie *newnode(int data,int count)
{
    struct trie *ptr=(struct trie *)malloc(sizeof(struct trie));
    ptr->data=data;
    ptr->count=count;
    ptr->children[0]=NULL;
    ptr->children[1]=NULL;
    return ptr;
}
int insert(char array[],struct trie *root)
{
    int i=0;
    while(array[i])
    {
        if(root->children[array[i]-'0'])
            root=root->children[array[i]-'0'];
        else
        {
            root->children[array[i]-'0']=newnode(array[i]-'0',0);
            root=root->children[array[i]-'0'];
        }
        i++;
    }
    root->count=root->count+1;
    return root->count;
}
int main()
{
    struct trie *root=newnode(0,0);
    int n,i,j;
    scanf("%d",&n);
    char array[n+1];
    int max=0;
    for(i=0;i<n;i++)
    {
        getchar();
        scanf("%s",array);
        if((j=insert(array,root))>max)
            max=j;
    }
    printf("%d",max);
    return 0;
}


#include<stdio.h>
struct trie
{
    int data;
    int count;
    struct trie *children[2];
};
struct trie *newnode(int data,int count)
{
    struct trie *ptr=(struct trie *)malloc(sizeof(struct trie));
    ptr->data=data;
    ptr->count=count;
    ptr->children[0]=NULL;
    ptr->children[1]=NULL;
}
int insert(char array[],struct trie *root)
{
    int i=0;
    while(array[i])
    {
        if(root->children[array[i]-'0'])
            root=root->children[array[i]-'0'];
        else
        {
            root->children[array[i]-'0']=newnode(array[i]-'0',0);
            root=root->children[array[i]-'0'];
        }
        i++;
    }
    root->count=root->count+1;
    return root->count;
}
int main()
{
    struct trie *root=newnode(0,0);
    int n,i,j;
    scanf("%d",&n);
    char array[n+1];
    int max=0;
    for(i=0;i<n;i++)
    {
        getchar();
        scanf("%s",array);
        if((j=insert(array,root))>max)
            max=j;
    }
    printf("%d",max);
    return 0;
}


#include<stdio.h>
struct trie
{
    int data;
    int count;
    struct trie *children[2];
};
struct trie *newnode(int data,int count)
{
    struct trie *ptr=(struct trie *)malloc(sizeof(struct trie));
    ptr->data=data;
    ptr->count=count;
    ptr->children[0]=NULL;
    ptr->children[1]=NULL;
}
int insert(char array[],struct trie *root)
{
    int i=0;
    while(array[i])
    {
        if(root->children[array[i]-'0'])
            root=root->children[array[i]-'0'];
        else
        {
            root->children[array[i]-'0']=newnode(array[i]-'0',0);
            root=root->children[array[i]-'0'];
        }
        i++;
    }
    root->count=root->count+1;
    return root->count;
}
int main()
{
    struct trie *root=newnode(0,0);
    int n,i,j;
    scanf("%d",&n);
    char array[n][n];
    int max=0;
    for(i=0;i<n;i++)
    {
        getchar();
        scanf("%s",array[i]);
        if((j=insert(array[i],root))>max)
            max=j;
    }
    printf("%d",max);
    return 0;
}


#include <stdio.h>
#include <string.h>

int main()
{
    int n,i,j,k=0,max=-1;
    scanf("%d",&n);
    char s[200][200];
    for(i=0;i<n;i++)
    {
        scanf("%s",s[i]);
    }
    for(i=0;i<n;i++)
    {
        k=0;
        for(j=i+1;j<n;j++)
        {
            if(!strcmp(s[i],s[j]))
            {
                k++;
            }
        }
        if(k>max)
        {
            max=k+1;
        }
    }
    printf("%d",max);
    return 0;
}


#include <stdio.h>
#include <string.h>

int main()
{
    int n,i,j,k=0,max=-1;
    scanf("%d",&n);
    char s[200][200];
    for(i=0;i<n;i++)
    {
        scanf("%s",s[i]);
    }
    for(i=0;i<n;i++)
    {
        k=1;
        for(j=i+1;j<n;j++)
        {
            if(strcmp(s[i],s[j])==0)
            {
                k++;
            }
        }
        if(k>=max)
        {
            max=k;
        }
    }
    printf("%d",max);
    return 0;
}


#include <stdio.h>
#include <string.h>

int main()
{
    int n,i,j,k=0,max=-1;
    scanf("%d",&n);
    char s[200][200];
    for(i=0;i<n;i++)
    {
        scanf("%s",s[i]);
    }
    for(i=0;i<n;i++)
    {
        k=0;
        for(j=i+1;j<n;j++)
        {
            if(!strcmp(s[i],s[j]))
            {
                k++;
            }
        }
        if(k>=max)
        {
            max=k;
        }
    }
    printf("%d",max);
    return 0;
}


#include <stdio.h>
char a[101][101];
int n;
int strcmp(char *c1,char *c2)
{
    int i;
    for(i=1;i<=n;i++)
    {
        if(*(c1+i)!=*(c2+i)) return 0;
    }
    return 1;
}
int main()
{
    scanf("%d",&n);
    char b;
    int i,j,k,max=0;
    int count[101];
    scanf("%c",&b);
    for(i=1;i<=n;i++)
    {
        count[i]=1;
        for(j=1;j<=n;j++)
        {
            scanf("%c",&a[i][j]);
        }
        if(i!=n) scanf("%c",&b);
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n && j!=i;j++)
        {
            count[i]=count[i]+strcmp(a[i],a[j]);
        }
        if(count[i]>max) max=count[i];
    }
    printf("%d",max);
    return 0;
}


#include<stdio.h>
#include<string.h>
char s[102][102];
int main()
{
    int n,i,j,max=0,f;
    scanf("%d",&n);
    for(i=0;i<n;++i)
        scanf("%s",s[i]);
    for(i=0;i<n;++i)
    {
        f=0;
        for(j=0;j<n;++j)
        {
            if(!strcmp(s[i],s[j]))
                ++f;
        }
        if(f>max)
            max=f;
    }
    printf("%d",max);
    return 0;
}


#include<stdio.h>
int main()
{

    int n,arr[100]={0},max=0,count,j,i;
    scanf("%d",&n);
    char str[100][101];
    for(i=0;i<n;i++)
        {
          scanf(" %s",str[i]);
        }
    for(i=0;i<n-1;i++)
    {
    count=1;
    for(j=i+1;j<n;j++)
    {
        if(!arr[j])
        {
            if(strcmp(str[i],str[j])==0)
                  {
                      arr[j]=1;
                      count++;

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

}


#include<stdio.h>
#include<string.h>
char str[100][101];
int main()
{

    int n,arr[100]={0},max=0,count,j,i,st0=1,st1=1;
    scanf("%d",&n);
    char one[101],zero[101];
    for(i=0;i<n;i++)
        {
         one[i]='1'; zero[i]='0';
          scanf(" %s",str[i]);
        }
        one[i]='1';  zero[i]='0';
    if(n==1)
    {
        printf("1");
        return 0;
    }
    for(i=0;i<n-1;i++)
    {
    count=1;
    if(st0)
    {
      if(strcmp(zero,str[i])==0)
        st0=1;
    }
    if(st1)
    {
      if(strcmp(one,str[i])==0)
        st1=1;
    }
    for(j=i+1;j<n;j++)
    {
      if(strcmp(str[i],str[j])==0)
                 count++;
    }
    if(count>max)
        max=count;
    }
    if(max==1&&n!=2&&!(st0==1||st1==1))
        max=0;

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

}


#include<stdio.h>
int main()
{

    int n,arr[100]={0},max=0,count,j,i;
    scanf("%d",&n);
    char str[100][101];
    for(i=0;i<n;i++)
        {
          scanf(" %s",str[i]);
        }
    for(i=0;i<n-1;i++)
    {
    count=1;
    for(j=i+1;j<n;j++)
    {
        if(!arr[j])
        {
            if(strcmp(str[i],str[j])==0)
                  {
                      arr[j]=1;
                      count++;

                  }
        }
    }
    if(count>max)
        max=count;
    }
    if(max==1)
        max=0;
    printf("%d",max);
    return 0;

}


#include<stdio.h>
#include<string.h>
char str[100][101];
int main()
{

    int n,arr[100]={0},max=0,count,j,i;
    scanf("%d",&n);

    for(i=0;i<n;i++)
        {
          scanf(" %s",str[i]);
        }
    for(i=0;i<n-1;i++)
    {
    count=1;
    for(j=i+1;j<n;j++)
    {

            if(strcmp(str[i],str[j])==0)
                  {

                      count++;

                  }

    }
    if(count>max)
        max=count;
    }
    if(max==1)
        max=0;
    if(n==1)
        max=1;
    printf("%d",max);
    return 0;

}


#include<stdio.h>
int main()
{

    int n,arr[100]={0},max=0,count,j,i;
    scanf("%d",&n);
    char str[100][101];
    for(i=0;i<n;i++)
        {
          scanf(" %s",str[i]);
        }
    for(i=0;i<n-1;i++)
    {
    count=1;
    for(j=i+1;j<n;j++)
    {
        if(!arr[j])
        {
            if(strcmp(str[i],str[j])==0)
                  {
                      arr[j]=1;
                      count++;

                  }
        }
    }
    if(count>max)
        max=count;
    }
    if(max==1)
        max=0;
    if(n==1)
        max=1;
    printf("%d",max);
    return 0;

}


#include "stdio.h"
#include "string.h"

int main(void){
    char array[100][100];
    int n = 0;
    scanf("%i", &n);
    int i;
    for (i = 0; i < n; i++){
        scanf("%s", array[i]);
    }
    //NOW COUNT NUMBER OF OCCURENCES OF EACH STRING
    int maxocc = 0;
    for (i = 0; i < n; i++){
        int occ = 0;
        int j;
        for (j = i; j < n; j++){
            if (strcmp(array[i], array[j]) == 0){
                occ++;
            }
        }
        if (occ > maxocc){
            maxocc = occ;
        }
    }
    printf("%i", maxocc);
    return 0;
}


#include "stdio.h"
#include "string.h"

int main(void){
    char array[101][101];
    int n = 0;
    scanf("%i", &n);
    int i;
    for (i = 0; i < n; i++){
        scanf("%s", array[i]);
    }
    //NOW COUNT NUMBER OF OCCURENCES OF EACH STRING
    int maxocc = 0;
    for (i = 0; i < n; i++){
        int occ = 0;
        int j;
        for (j = i; j < n; j++){
            if (strcmp(array[i], array[j]) == 0){
                occ++;
            }
        }
        if (occ > maxocc){
            maxocc = occ;
        }
    }
    printf("%i", maxocc);
    return 0;
}


 #include<stdio.h>
#include<string.h>
main()
{
 long int c, i, j, m=0, n;
 char s[100][101];
 scanf("%ld", &n);
 for(i=0;i<n;i++)
  scanf("%s", s[i]);
 for(i=0;i<n;i++)
 {
  c=0;
  for(j=0;j<n;j++)
   if(strcmp(s[i],s[j])==0)
    c++;
  if(m<c)
   m=c;
 }
 printf("%ld", m);
 return 0;
}


#include<stdio.h>
int main()
{
	int f,n,i,j,k,c=0,s=0;
	char a[101][101];
	scanf("%d",&n);
	getchar();
	//find max no. of identical rows
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			scanf("%c",&a[i][j]);
		getchar();
	}
	for(i=0;i<n;i++)
	{
		c=1;
		for(j=0;j<n && j!=i;j++)
		{
			f=0;
			for(k=0;k<n;k++)
			{
				if(a[i][k]!=a[j][k])
				{
					f=1;
					break;
				}
			}
			if(f==0)
				c++;
		}
		if(c>s)
			s=c;
	}
	printf("%d",s);

	return 0;
}


#include<stdio.h>

typedef struct node
{
	char a[101];
}node;

node s[101];
int pw(int j)
{
		int ans = 1;
		int base = 2;
		while(j>0)
		{
				if(j%2==1)
						ans = (ans* base)%50003;
				j = j>>1;
				base = (base * base)%50003;
		}
		return ans;
}

int main()
{
		int x,n,i,j,hash[50004]={0};

		scanf("%d",&n);
		int max =0;

		for(i=0;i<n;i++)
		{
				scanf("%s",s[i].a);
				x=0;
				for(j=0;j<n;j++)
					{
						x+=(pw(j)*(s[i].a[j]-'0'))%50003;
						x = (x%50003);
				}
				hash[x]++;
				if(max<hash[x])
						max=hash[x];
		}
		printf("%d\n",max);
		return 0;

}


#include<stdio.h>

typedef struct node
{
	char a[101];
}node;

node s[101];
int pw(int j)
{
		int ans = 1;
		int base = 2;
		while(j>0)
		{
				if(j%2==1)
						ans = (ans* base)%997;
				j = j>>1;
				base = (base * base)%997;
		}
		return ans;
}

int main()
{
		int x,n,i,j,hash[1000]={0};

		scanf("%d",&n);
		int max =0;

		for(i=0;i<n;i++)
		{
				scanf("%s",s[i].a);
				x=0;
				for(j=0;j<n;j++)
					{
						x+=(pw(j)*(s[i].a[j]-'0'))%997;
						x = (x%997);
				}
				hash[x]++;
				if(max<hash[x])
						max=hash[x];
		}
		printf("%d\n",max);
		return 0;

}


#include<stdio.h>

typedef struct node
{
	char a[101];
}node;

node s[101];
int pw(int j)
{
		int ans = 1;
		int base = 2;
		while(j>0)
		{
				if(j%2==1)
						ans = (ans* base)%10003;
				j = j>>1;
				base = (base * base)%10003;
		}
		return ans;
}

int main()
{
		int x,n,i,j,hash[10004]={0};

		scanf("%d",&n);
		int max =0;

		for(i=0;i<n;i++)
		{
				scanf("%s",s[i].a);
				x=0;
				for(j=0;j<n;j++)
					{
						x+=(pw(j)*(s[i].a[j]-'0'))%10003;
						x = (x%10003);
				}
				hash[x]++;
				if(max<hash[x])
						max=hash[x];
		}
		printf("%d\n",max);
		return 0;

}


#include<stdio.h>

typedef struct node
{
	char a[101];
}node;

node s[101];
int pw(int j)
{
		int ans = 1;
		int base = 2;
		while(j>0)
		{
				if(j%2==1)
						ans = (ans* base)%100003;
				j = j>>1;
				base = (base * base)%100003;
		}
		return ans;
}

int main()
{
		int x,n,i,j,hash[100004]={0};

		scanf("%d",&n);
		int max =0;

		for(i=0;i<n;i++)
		{
				scanf("%s",s[i].a);
				x=0;
				for(j=0;j<n;j++)
					{
						x+=(pw(j)*(s[i].a[j]-'0'))%100003;
						x = (x%100003);
				}
				hash[x]++;
				if(max<hash[x])
						max=hash[x];
		}
		printf("%d\n",max);
		return 0;

}


#include<stdio.h>

typedef struct node
{
	char a[101];
}node;

node s[101];
int pw(int j)
{
		int ans = 1;
		int base = 2;
		while(j>0)
		{
				if(j%2==1)
						ans = (ans* base)%997;
				j = j>>1;
				base = (base * base)%997;
		}
		return ans;
}

int main()
{
		int x,n,i,j,hash[1000]={0};

		scanf("%d",&n);
		int max =0;

		for(i=0;i<n;i++)
		{
				scanf("%s",s[i].a);
				x=0;
				for(j=0;j<n;j++)
					{
						x+=(pw(j)*(s[i].a[j]-'0'))%997;
				}
				hash[x]++;
				if(max<hash[x])
						max=hash[x];
		}
		printf("%d\n",max);
		return 0;

}


#include <stdio.h>
#include <string.h>
#define MAX 120

typedef struct s{
	char dan[MAX];
	int num;
}S;

main()
{
	int flag,i,j,n,count,max;
	char s[MAX][MAX]={{0}};
	S kind[MAX];

	scanf("%d",&n);
	getchar();
	for(i=0;i<n;i++)
	{
		gets(s[i]);
	}

	count = 0;
    strcpy(kind[count].dan,s[0]);
	kind[count].num = 1;
    count++;

	for(i=1;i<n;i++)
	{
		flag=0;
		for(j=0;j<count;j++)
		{
			if( strcmp(s[i],kind[j].dan)==0 )
			{
				flag=1;
				kind[j].num++;
				break;
			}
		}
		if(flag==0)
		{
			kind[count].num=1;
			strcpy(kind[count].dan,s[i]);
			count++;
		}
	}
    max = kind[0].num;
    for(i=0;i<count;i++)
	{
		if( max<kind[i].num)
        max = kind[i].num;
	}
	printf("%d\n",max);
	return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
	int i,j,k,l,n,count=0,max=0;
	scanf("%d",&n);
	char a[n+1][n+1];
	for(i=0;i<n;i++)
	{
		scanf("%s",a[i]);
	}
	for(i=0;i<n;i++)
	{
		count=0;

		for(j=i+1;j<n;j++)
		{
				l=strcmp(a[i],a[j]);
				if(l==0)
				{
					count++;
				}

		}
		if(count>max)
			max=count;
	}
	printf("%d",max+1);
	return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
	char tab[102][102];
	int i,j,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",tab[i]);
	}
	int cnt=0,tot=0;
	for(i=0;i<n;i++)
	{
		cnt=0;
		for(j=0;j<n;j++)
		{
			if(strcmp(tab[i],tab[j])==0)
				cnt++;
		}
		if(tot<cnt)
			tot=cnt;
	}
	printf("%d",tot);
	return 0;
}


#include<iostream>
#include<stack>
#include<vector>
using namespace std;
class Solution{
	public:
	int trap(const vector<int> &A);
};
int min(int a,int b)
{
    return (a<b)?a:b;
}
int Solution::trap(const vector<int> &A) {
    stack<int> s;
    int i=0,vol=0,b;
    while(i<A.size() && A[i]==0)
        i++;
    for(;i<A.size();)
    {
    	cout<<"s.size="<<s.size()<<endl;
        while(!s.empty() && A[i]>=A[s.top()])
        {
        	cout<<"s.top="<<s.top()<<endl;
            b=s.top();
            s.pop();
            if(s.empty())
                break;
            vol+=(i - s.top() -1)*(min(A[i],A[s.top()]) - A[b]);
        }
        s.push(i);
        i++;
    }
    return vol;
}
int main()
{
	Solution obj;
	vector<int> v;
	int n,t;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>t;
		v.push_back(t);
	}
	cout<<"vol="<<obj.trap(v)<<endl;
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
    int n;
    scanf("%d",&n);
    char s[101][101];

    int count=1,max=0,flag=1,i,j,k;

    for(i=0;i<n;i++)
    scanf("%s",s[i]);

    for(i=0;i<n;i++)
    {
        count = 1;
        for(j=i+1;j<n;j++)
        {
            flag = 1;
            for(k=0;k<n;k++)
            {
                if(s[i][k]!=s[j][k])
                flag=0;
            }
            if(flag==1)
            count++;
        }
        if(count>max)
        max=count;
    }
    printf("%d\n",max);
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,j,k;
    scanf("%d",&n);
    char s[n][n];
    for(i=0;i<n;i++)
        scanf("%s",s[i]);
    int max=0,cur=0;
    for(i=0;i<n;i++)
    {
        cur=0;
        for(j=0;j<n;j++)
        {
            k=0;
            while(s[i][k]==s[j][k])
            {
                k++;
                if(k==n)
                    break;
            }
            if(k==n)
                cur++;
        }
        if(cur>max)
            max=cur;
    }
    printf("%d\n",max);
    return 0;
}


#include<stdio.h>

int main()
{
        char str[102][102];
        int arr[102][102], i, j, k, count, ans, n, flag;

        scanf("%d", &n);

        for(i = 0; i < n; i++){
                scanf("%s", str[i]);
        }

        for(i = 0; i < n; i++){
                for(j = 0; j < n; j++){
                        if(str[i][j] == '0'){
                                arr[i][j] = 0;
                        } else {
                                arr[i][j] = 1;
                        }
                }
        }

        ans = 0;
        for(i = 0; i < n; i++){
                count = 0;
                for(j = 0; j < n; j++){
                        flag = 0;
                        for(k = 0; k < n; k++){
                                if(arr[i][k] != arr[j][k]){
                                        flag = 1;
                                        break;
                                }
                        }
                        if(flag == 0){
                                count++;
                        }
                }

                if(count > ans){
                        ans = count;
                }

        }

        printf("%d\n", ans);

        return 0;
}


#include<stdio.h>

int main()
{
    char a[110][110];
    int n,i,k,j,count[110]={0};
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%s",a[i]);
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        {
            for(k=0;k<n;k++)
                if(a[i][k]!=a[j][k])
                    break;
            if(k==n)
                count[i]++;
        }
    for(i=0;i<n;i++)
        if(count[0]<count[i])
            count[0]=count[i];
    printf("%d\n",count[0]);
    return 0;
}


#include<stdio.h>
int main(){
char s[120][120];
int n,i,j;
scanf("%d",&n);
int q[n][2];
for(i=0;i<n;i++){
    scanf("%s",&s[i]);
}
int max=0,count=0;
for(i=0;i<n;i++){
    for(j=i;j<n;j++){
        if(!strcmp(s[i],s[j]))
        //printf("%d %d\n",i,j);
            count++;
    }
    if(count>max)
        max=count;
    count=0;
}
printf("%d",max);
return 0;
}


#include<stdio.h>

int main()
{
	int n,i,j,count=0,max=0;
	char s[101][101];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s",&s[i]);
	for(i=0;i<n;i++)
	{
		for(j=i;j<n;j++)
		{
			if(strcmp(s[i],s[j])==0)
				count++;
		}
		if(count>max)
			max=count;
		count=0;
	}
	printf("%d",max);
}


#include<stdio.h>
#include<string.h>
main()
{
    int i,j,k,a,b,max=0,count,n;
    scanf("%d",&n);
    char num[200][200];
    for(i=0;i<n;i++)scanf("%s",&num[i]);
    for(i=0;i<n;i++)
    {
        count=0;
        for(j=0;j<n;j++)
        {
            if(strcmp(num[i],num[j])==0)count++;
        }
        if(count>max)max=count;
    }
    printf("%d",max);

}


#include<stdio.h>
#include<string.h>
main()
{
    int i,j,k,a,b,max=0,count,n;
    scanf("%d",&n);
    char num[100][100];
    for(i=0;i<n;i++)scanf("%s",&num[i]);
    for(i=0;i<n;i++)
    {
        count=0;
        for(j=0;j<n;j++)
        {
            if(strcmp(num[i],num[j])==0)count++;
        }
        if(count>max)max=count;
    }
    printf("%d",max);

}


#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main(void)
{
  int n, i, j;

  printf("Enter n:\n");

  scanf("%d", &n);

  bool ** matrix = (bool **)malloc(n * sizeof(bool *));

  for (i = 0; i < n; i++)
      matrix[i] = (bool *)malloc(n * sizeof(bool));

  char * enteredCharTempString = (char *)malloc(n * sizeof(char));

  printf("Enter n lines, with length n:\n");

  for (i = 0; i < n; i++)
  {
     scanf("%s", enteredCharTempString);

     for (j = 0; enteredCharTempString[j] != '\0'; j++)
        matrix[j][i] = !!(enteredCharTempString[j] - '0');
  }

  free(enteredCharTempString);

  int max = 0, max_check = 0, answer = 0;

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

      for (j = 0; j < n; j++)
          if (matrix[i][j] == 1)
             max++;

      if (max > max_check)
      {
          max_check = max;

          answer = i+1;
      }
  }

  printf("Answer: %d", answer);

  for (i = 0; i < n; i++)
      free(matrix[i]);

  free(* matrix);

  return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

int main(void)
{
  int n, i, j;

  scanf("%d", &n);

  bool ** matrix = (bool **)malloc(n * sizeof(bool *));

  for (i = 0; i < n; i++)
      matrix[i] = (bool *)malloc(n * sizeof(bool));

  char * enteredCharTempString = (char *)malloc(n * sizeof(char));

  printf("Enter n lines, with length n:\n");

  for (i = 0; i < n; i++)
  {
     scanf("%s", enteredCharTempString);

     for (j = 0; enteredCharTempString[j] != '\0'; j++)
        matrix[j][i] = !!(enteredCharTempString[j] - '0');
  }

  free(enteredCharTempString);

  int max = 0, max_check = 0, answer = 0;

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

      for (j = 0; j < n; j++)
          if (strcmp(matrix[i], matrix[j]) == 0)
             max++;

      if (max > max_check)
      {
          max_check = max;
          answer = max;
      }
  }

  printf("Answer: %d", answer);

  for (i = 0; i < n; i++)
      free(matrix[i]);

  free(* matrix);

  return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

int check_equals(bool * a, bool * b, int n);

int main(void)
{
  int n, i, j;

  scanf("%d", &n);

  bool ** matrix = (bool **)malloc(n * sizeof(bool *));

  for (i = 0; i < n; i++)
      matrix[i] = (bool *)malloc(n * sizeof(bool));

  char * enteredCharTempString = (char *)malloc(n * sizeof(char));

  for (i = 0; i < n; i++)
  {
     scanf("%s", enteredCharTempString);

     for (j = 0; enteredCharTempString[j] != '\0'; j++)
        matrix[i][j] = !!(enteredCharTempString[j] - '0');
  }

  free(enteredCharTempString);

  int max = 0, max_check = 0, answer = 0;

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

      for (j = 0; j < n; j++)
          if (check_equals(matrix[i], matrix[j], n) == true)
             max++;

      if (max > max_check)
      {
          max_check = max;
          answer = max;
      }
  }

  printf("%d", answer);

  for (i = 0; i < n; i++)
      free(matrix[i]);

  free(* matrix);

  return 0;
}

int check_equals(bool * a, bool * b, int n)
{
int i = 0;
bool check = true;
  for (i = 0; i < n; i++)
{
      if (a[i] != b[i])
      {
      check = false;
      break;
      }
}
  return(check);
}


#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main(void)
{
  int n, i, j;

  scanf("%d", &n);

  bool ** matrix = (bool **)malloc(n * sizeof(bool *));

  for (i = 0; i < n; i++)
      matrix[i] = (bool *)malloc(n * sizeof(bool));

  char * enteredCharTempString = (char *)malloc(n * sizeof(char));

  for (i = 0; i < n; i++)
  {
     scanf("%s", enteredCharTempString);

     for (j = 0; enteredCharTempString[j] != '\0'; j++)
        matrix[j][i] = !!(enteredCharTempString[j] - '0');
  }

  free(enteredCharTempString);

  int max = 0, max_check = 0, answer = 0;

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

      for (j = 0; j < n; j++)
          if (matrix[i][j] == 1)
             max++;

      if (max > max_check)
      {
          max_check = max;

          answer = max;
      }
  }

  printf("%d", answer);

  for (i = 0; i < n; i++)
      free(matrix[i]);

  free(* matrix);

  return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

int check_equals(bool * a, bool * b, int n);

int main(void)
{
  int n, i, j;

  scanf("%d", &n);

  bool ** matrix = (bool **)malloc(n * sizeof(bool *));

  for (i = 0; i < n; i++)
      matrix[i] = (bool *)malloc(n * sizeof(bool));

  char * enteredCharTempString = (char *)malloc(n * sizeof(char));

  for (i = 0; i < n; i++)
  {
     scanf("%s", enteredCharTempString);

     for (j = 0; enteredCharTempString[j] != '\0'; j++)
        matrix[j][i] = !!(enteredCharTempString[j] - '0');
  }

  free(enteredCharTempString);

  int max = 0, max_check = 0, answer = 0;

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

      for (j = 0; j < n; j++)
          if (check_equals(matrix[i], matrix[j], n) == true)
             max++;

      if (max > max_check)
      {
          max_check = max;
          answer = max;
      }
  }

  printf("%d", answer);

  for (i = 0; i < n; i++)
      free(matrix[i]);

  free(* matrix);

  return 0;
}

int check_equals(bool * a, bool * b, int n)
{
int i = 0;
bool check = true;
  for (i = 0; i < n; i++)
{
      if (a[i] != b[i])
      {
      check = false;
      break;
      }
}
  return(check);
}


#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

int main(void)
{
  int n, i, j;

  scanf("%d", &n);

  bool ** matrix = (bool **)malloc(n * sizeof(bool *));

  for (i = 0; i < n; i++)
      matrix[i] = (bool *)malloc(n * sizeof(bool));

  char * enteredCharTempString = (char *)malloc(n * sizeof(char));

  for (i = 0; i < n; i++)
  {
     scanf("%s", enteredCharTempString);

     for (j = 0; enteredCharTempString[j] != '\0'; j++)
        matrix[j][i] = !!(enteredCharTempString[j] - '0');
  }

  free(enteredCharTempString);

  int max = 0, max_check = 0, answer = 0;

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

      for (j = 0; j < n; j++)
          if (strcmp(matrix[i], matrix[j]) == 0)
             max++;

      if (max > max_check)
      {
          max_check = max;
          answer = max;
      }
  }

  printf("%d", answer);

  for (i = 0; i < n; i++)
      free(matrix[i]);

  free(* matrix);

  return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main(void)
{
  int n, i, j;

  scanf("%d", &n);

  bool ** matrix = (bool **)malloc(n * sizeof(bool *));

  for (i = 0; i < n; i++)
      matrix[i] = (bool *)malloc(n * sizeof(bool));

  char * enteredCharTempString = (char *)malloc(n * sizeof(char));

  for (i = 0; i < n; i++)
  {
     scanf("%s", enteredCharTempString);

     for (j = 0; enteredCharTempString[j] != '\0'; j++)
        matrix[j][i] = !!(enteredCharTempString[j] - '0');
  }

  free(enteredCharTempString);

  int max = 0, max_check = 0, answer = 0;

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

      for (j = 0; j < n; j++)
          if (matrix[i][j] == 1)
             max++;

      if (max > max_check)
      {
          max_check = max;

          answer = i+1;
      }
  }

  printf("%d", answer);

  for (i = 0; i < n; i++)
      free(matrix[i]);

  free(* matrix);

  return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

int check_equals(bool * a, bool * b, int n);

int main(void)
{
  int n, i, j;

  scanf("%d", &n);

  bool ** matrix = (bool **)malloc(n * sizeof(bool *));

  for (i = 0; i < n; i++)
      matrix[i] = (bool *)malloc(n * sizeof(bool));

  char * enteredCharTempString = (char *)malloc(n * sizeof(char));

  printf("Enter n lines, with length n:\n");

  for (i = 0; i < n; i++)
  {
     scanf("%s", enteredCharTempString);

     for (j = 0; enteredCharTempString[j] != '\0'; j++)
        matrix[j][i] = !!(enteredCharTempString[j] - '0');
  }

  free(enteredCharTempString);

  int max = 0, max_check = 0, answer = 0;

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

      for (j = 0; j < n; j++)
          if (check_equals(matrix[i], matrix[j], n) == true)
             max++;

      if (max > max_check)
      {
          max_check = max;
          answer = max;
      }
  }

  printf("Answer: %d", answer);

  for (i = 0; i < n; i++)
      free(matrix[i]);

  free(* matrix);

  return 0;
}

int check_equals(bool * a, bool * b, int n)
{
int i = 0;
bool check = true;
  for (i = 0; i < n; i++)
{
      if (a[i] != b[i])
      {
      check = false;
      break;
      }
}
  return(check);
}


#include "stdio.h"
#include "stdlib.h"

#define BUFFER_SIZE 101

int main(int argc, char ** args) {
	int i, j, k, size, counter, max = 0, ** data, succ;
	char input[BUFFER_SIZE] = {0};
	scanf("%d", &size);
	data = (int **) malloc(4 * sizeof(*data));
	for (i = 0; i < 4; i++) {
		data[i] = (int *) calloc(size, sizeof(*data[i]));
	}
	for (i = 0; i < size; i++) {
		scanf("%s", input);
		for (j = 0; j < 4; j++) {
			for (k = j * 25; k < (j + 1) * 25 && k < size; k++) {
				data[j][i] += (1 << (k - j * 25)) * (input[k] - '0');
			}
		}
	}
	for (i = 0; i < size; i++) {
		counter = 1;
		for (j = i + 1; j < size; j++) {
			succ = 1;
			for (k = 0; k < 4; k++) {
				succ = (succ && data[k][i] == data[k][j]);
			}
			counter += succ;
		}
		if (counter > max) {
			max = counter;
		}
	}
	printf("%d\n", max);
	for (i = 0; i < 4; i++) {
		free(data[i]);
	}
	free(data);
	return 0;
}


#include "stdio.h"
#include "stdlib.h"
#include "stdint.h"

#define BUFFER_SIZE 101

int main(int argc, char ** args) {
	int i, j, size, counter, max = 0;
	char input[BUFFER_SIZE];
	uint64_t * upper_bits, * lower_bits;
	scanf("%d", &size);
	upper_bits = (uint64_t *) calloc(size, sizeof(*upper_bits));
	lower_bits = (uint64_t *) calloc(size, sizeof(*lower_bits));
	for (i = 0; i < size; i++) {
		scanf("%s", input);
		for (j = 0; j < 63; j++) {
			lower_bits[i] += 1 << ((input[j] - '0') * j);
		}
		for (j = 63; j < size; j++) {
			upper_bits[i] += 1 << ((input[j] - '0') * (j - 63));
		}
	}
	for (i = 0; i < size; i++) {
		counter = 1;
		for (j = i + 1; j < size; j++) {
			if (lower_bits[i] == lower_bits[j] && upper_bits[i] == upper_bits[j]) {
				counter++;
			}
		}
		if (counter > max) {
			max = counter;
		}
	}
	printf("%d\n", max);
	free(upper_bits);
	free(lower_bits);
	return 0;
}


#include "stdio.h"
#include "stdlib.h"
#include "stdint.h"

#define BUFFER_SIZE 101

int main(int argc, char ** args) {
	int i, j, size, counter, max = 0;
	char input[BUFFER_SIZE];
	uint64_t * upper_bits, * lower_bits;
	scanf("%d", &size);
	upper_bits = (uint64_t *) calloc(size, sizeof(*upper_bits));
	lower_bits = (uint64_t *) calloc(size, sizeof(*lower_bits));
	for (i = 0; i < size; i++) {
		scanf("%s", input);
		for (j = 0; j < 64; j++) {
			lower_bits[i] += 1 << ((input[j] - '0') * j);
		}
		for (j = 64; j < size; j++) {
			upper_bits[i] += 1 << ((input[j] - '0') * (j - 64));
		}
	}
	for (i = 0; i < size; i++) {
		counter = 1;
		for (j = i + 1; j < size; j++) {
			if (lower_bits[i] == lower_bits[j] && upper_bits[i] == upper_bits[j]) {
				counter++;
			}
		}
		if (counter > max) {
			max = counter;
		}
	}
	printf("%d\n", max);
	free(upper_bits);
	free(lower_bits);
	return 0;
}


#include "stdio.h"
#include "stdlib.h"
#include "math.h"

#define BUFFER_SIZE 101
#define ARRAY_SIZE ceil(BUFFER_SIZE / sizeof(int))

int main(int argc, char ** args) {
	int i, j, k, size, counter, max = 0, ** data, succ;
	char input[BUFFER_SIZE];
	scanf("%d", &size);
	data = (int **) malloc(size * sizeof(*data));
	for (i = 0; i < ARRAY_SIZE; i++) {
		data[i] = (int *) calloc(size, sizeof(*data[i]));
	}
	for (i = 0; i < size; i++) {
		scanf("%s", input);
		for (j = 0; j < ARRAY_SIZE; j++) {
			for (k = j * BUFFER_SIZE / ARRAY_SIZE; k < (j + 1) * BUFFER_SIZE / ARRAY_SIZE && k < size; k++) {
				data[j][i] += (1 << (int) (k - j * BUFFER_SIZE / ARRAY_SIZE)) * (input[k] - '0');
			}
		}
	}
	for (i = 0; i < size; i++) {
		counter = 1;
		for (j = i + 1; j < size; j++) {
			succ = 1;
			for (k = 0; k < ARRAY_SIZE; k++) {
				succ = (succ && data[k][i] == data[k][j]);
			}
			counter += succ;
		}
		if (counter > max) {
			max = counter;
		}
	}
	printf("%d\n", max);
	for (i = 0; i < ARRAY_SIZE; i++) {
		free(data[i]);
	}
	free(data);
	return 0;
}


#include "stdio.h"
#include "stdlib.h"
#include "stdint.h"

#define BUFFER_SIZE 101

int main(int argc, char ** args) {
	int i, j, size, counter, max = 0;
	char input[BUFFER_SIZE];
	uint64_t * upper_bits, * lower_bits;
	scanf("%d", &size);
	upper_bits = (uint64_t *) calloc(size, sizeof(*upper_bits));
	lower_bits = (uint64_t *) calloc(size, sizeof(*lower_bits));
	for (i = 0; i < size; i++) {
		scanf("%s", input);
		for (j = 0; j < 64; j++) {
			lower_bits[i] += 1 << (input[j] - '0');
		}
		for (j = 64; j < size; j++) {
			upper_bits[i] += 1 << (input[j] - '0');
		}
	}
	for (i = 0; i < size; i++) {
		counter = 1;
		for (j = i + 1; j < size; j++) {
			if (lower_bits[i] == lower_bits[j] && upper_bits[i] == upper_bits[j]) {
				counter++;
			}
		}
		if (counter > max) {
			max = counter;
		}
	}
	printf("%d\n", max);
	free(upper_bits);
	free(lower_bits);
	return 0;
}


#include "stdio.h"
#include "stdlib.h"
#include "stdint.h"

#define BUFFER_SIZE 101

int main(int argc, char ** args) {
	int i, j, size, counter, max = 0;
	char input[BUFFER_SIZE];
	uint64_t * upper_bits, * lower_bits;
	scanf("%d", &size);
	upper_bits = (uint64_t *) calloc(size, sizeof(*upper_bits));
	lower_bits = (uint64_t *) calloc(size, sizeof(*lower_bits));
	for (i = 0; i < size; i++) {
		scanf("%s", input);
		for (j = 0; j < 50; j++) {
			lower_bits[i] += 1 << ((input[j] - '0') * j);
		}
		for (j = 50; j < size; j++) {
			upper_bits[i] += 1 << ((input[j] - '0') * (j - 50));
		}
	}
	for (i = 0; i < size; i++) {
		counter = 1;
		for (j = i + 1; j < size; j++) {
			if (lower_bits[i] == lower_bits[j] && upper_bits[i] == upper_bits[j]) {
				counter++;
			}
		}
		if (counter > max) {
			max = counter;
		}
	}
	printf("%d\n", max);
	free(upper_bits);
	free(lower_bits);
	return 0;
}


#include "stdio.h"
#include "stdlib.h"
#include "stdint.h"

#define BUFFER_SIZE 101

int main(int argc, char ** args) {
	int i, j, size, counter, max = 0;
	char input[BUFFER_SIZE];
	uint64_t * upper_bits, * lower_bits;
	scanf("%d", &size);
	upper_bits = (uint64_t *) calloc(size, sizeof(*upper_bits));
	lower_bits = (uint64_t *) calloc(size, sizeof(*lower_bits));
	for (i = 0; i < size; i++) {
		scanf("%s", input);
		for (j = 0; j < 50; j++) {
			lower_bits[i] += (1 << j) * (input[j] - '0');
		}
		for (j = 50; j < size; j++) {
			upper_bits[i] += (1 << (j - 50)) * (input[j] - '0');
		}
	}
	for (i = 0; i < size; i++) {
		counter = 1;
		for (j = i + 1; j < size; j++) {
			if (lower_bits[i] == lower_bits[j] && upper_bits[i] == upper_bits[j]) {
				counter++;
			}
		}
		if (counter > max) {
			max = counter;
		}
	}
	printf("%d\n", max);
	free(upper_bits);
	free(lower_bits);
	return 0;
}


/* Problem: 554B - Ohana Cleans Up */
/* Solver: Gusztav Szmolik */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int cmp (const void*, const void*);

unsigned char s[100][102];

int main ()
    {
    unsigned short n;
    unsigned short i;
    unsigned short j;
    unsigned short ec;
    unsigned short ecx;

    if (scanf("%hu",&n) != 1)
        return -1;
    if (n < 1 || n > 100)
        return -1;
    for (i = 0; i < n; i++)
        {
        if (scanf("%101s",s[i]) != 1)
            return -1;
        if (strlen(s[i]) != n)
            return -1;
        for (j = 0; j < n; j++)
            if (s[i][j] != '0' && s[i][j] != '1')
                return -1;
        }
    qsort (s,n,102*sizeof(unsigned char),cmp);
    ec = ecx = 0;
    for (i = 1; i < n; i++)
        {
        if (!strcmp(s[i-1],s[i]))
            ec++;
        if (strcmp(s[i-1],s[i]) || i == n-1)
            {
            if (ec > ecx)
                ecx = ec;
            ec = 0;
            }
        }
    printf ("%hu\n",ecx+1);
    return 0;
    }

int cmp (p1,p2)
    const void* p1;
    const void* p2;
    {
    unsigned char* a;
    unsigned char* b;

    a = (unsigned char*)p1;
    b = (unsigned char*)p2;
    return (strcmp(a,b));
    }


#include<stdio.h>
char  a[101];
int m=0;
struct trie
{
    int info;
    struct trie *next[2];
};
struct trie *getnode();
struct trie *root=NULL;
int main()
{
    int n,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s",a);
        trie(root,n);
    }
    printf("%d",m);
    return 0;
}
void trie(struct trie *p,int l)
{
    int i;
    if(p==NULL)
        root=p=getnode();
    for(i=0;i<l;i++)
    {
        if(p->next[a[i]-48]==NULL)
            p->next[a[i]-48]=getnode();
        p=p->next[a[i]-48];
    }
    p->info++;
    if(p->info>m)
        m=p->info;
}
struct trie *getnode()
{
    struct trie *p;
    p=(struct trie *)malloc(sizeof(struct trie ));
    p->next[0]=p->next[1]=NULL;
    p->info=0;
};


#include<stdio.h>
char  s[100][101];
int m=0;
int main()
{
    int n,i,j,c;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%s",s[i]);
    for(i=0;i<n;i++)
    {
        c=0;
        for(j=i+1;j<n;j++)
        {
            if(!strcmp(s[i],s[j]))
                c++;
        }
        if(c>m)
            m=c;
    }
    printf("%d",m+1);
    return 0;
}


#include <stdio.h>
#include <string.h>
int main()
{
	int n,i,j,f,maxi;
	scanf("%d",&n);
	char str[100][101];
	for (i=0;i<n;i++){
		scanf("%s",str[i]);

	}
	maxi=0;
	for (i=0;i<n-1;i++){
		f=1;
		for (j=i+1;j<n;j++){
			if (strcmp(str[i],str[j])==0){
				f=f+1;
			}
		}
		if (f>maxi){
			maxi=f;
		}
	}
	printf("%d",maxi);
	return 0;
}


#include <stdio.h>
#include <string.h>
int main()
{
	int n,i,j,f,maxi;
	scanf("%d",&n);
	char str[100][101];
	for (i=0;i<n;i++){
		scanf("%s",str[i]);

	}
	if (n==1){
		printf("1");
	}
	else{
	maxi=0;
	for (i=0;i<n-1;i++){
		f=1;
		for (j=i+1;j<n;j++){
			if (strcmp(str[i],str[j])==0){
				f=f+1;
			}
		}
		if (f>maxi){
			maxi=f;
		}
	}
	printf("%d",maxi);
	}
	return 0;
}


#include <stdio.h>
#include <strings.h>
main()
{
int n;
scanf("%d",&n);
char s[n][n+1];
int i,j,k,c,max;
for(i=0;i<n;i++)
scanf("%s",s[i]);
for(i=0;i<n;i++)
{ c=0;
for(j=0;j<n;j++)
{
if(!strcmp(s[i],s[j]))
c++;
if(i==0)
max=c;
else if(c>max)
max=c;

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

}


#include<stdio.h>
#include<string.h>
int main()
{
    int i,j,count=0,max=0,n;
    char a[110][110];
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%s",a[i]);
    }
    for(i=0; i<n; i++)
    {
        for(j=i; j<n; j++)
        {
            if(strcmp(a[i],a[j])==0)
            {
                count++;

            }
        }
        if(count>max)
        {
            max=count;
        }
        count=0;
    }
    printf("%d",max);

    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,result,count=1,j;
    char a[110][110];
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%s",a[i]);
    }
    for(i=0,j=0; i<n-1; i++)
    {
        if((result=strcmp(a[j],a[i+1]))==0)
        {
            count++;
        }
    }
    printf("%d",count);

    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int i,j,count=0,max=0,n;
    char a[100][100];
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%s",a[i]);
    }
    for(i=0; i<n; i++)
    {
        for(j=i; j<n; j++)
        {
            if((strcmp(a[i],a[j]))==0)
            {
                count++;

            }
        }
        if(count>max)
        {
            max=count;
        }
        count=0;
    }
    printf("%d",max);

    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,result,count=1,j=0;
    char a[110][110];
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%s",a[i]);
    }
    for(i=0; i<n-1; i++)
    {
        result=strcmp(a[j],a[i+1]);
        if(result==0)
        {
            count++;
        }
        else
        {
            j++;
        }
    }
    printf("%d",count);

    return 0;
}


#include<stdio.h>
int main()
{
    int **a,n,i,j,count1=1,temp=1;
    scanf("%d",&n);
    char b[101][101];
    if(n>=1&&n<=100)
    {
       a=calloc(n,sizeof(int));
       for(i=0;i<n;i++)
       {
          a[i]=calloc(n,sizeof(int));
       }
       for(i=0;i<n;i++)
       {
               scanf("%s",b[i]);

        }

       for(i=0;i<n-1;i++)
       {
           count1=1;
           temp=1;
            for(j=i+1;j<n;j++)
            {
             if(strcmp(b[i],b[j])==0)
             {
                 count1++;
             }
            }
             if(temp<count1)
                temp=count1;

       }
       if(count1==1)
       {
           printf("1");
       }
       else
       {
           printf("%d",temp+1);
       }
}

    else
        return 0;
    return 0;
}


#include<stdio.h>
int main()
{
    int **a,n,i,j,count1=1,temp=1;
    scanf("%d",&n);
    char b[101][101];
    if(n>=1&&n<=100)
    {
       a=calloc(n,sizeof(int));
       for(i=0;i<n;i++)
       {
          a[i]=calloc(n,sizeof(int));
       }
       for(i=0;i<n;i++)
       {
               scanf("%s",b[i]);

        }

       for(i=0;i<n-1;i++)
       {
           count1=1;
          // temp=1;
            for(j=i+1;j<n;j++)
            {
             if(strcmp(b[i],b[j])==0)
             {
                 count1++;
             }
            }
             if(temp<count1)
                temp=count1;

       }

           printf("%d",temp);

}

    else
        return 0;
    return 0;
}


#include<stdio.h>
int main()
{
    int **a,n,i,j,count1=1,temp=1;
    scanf("%d",&n);
    char b[101][101];
    if(n>=1&&n<=100)
    {
       a=calloc(n,sizeof(int));
       for(i=0;i<n;i++)
       {
          a[i]=calloc(n,sizeof(int));
       }
       for(i=0;i<n;i++)
       {
          for(j=0;j<n;j++)
          {
              scanf("%d",&a[i][j]);
              if(a[i][j]<0||a[i][j]>1)
                return 0;

                b[i][j]=a[i][j]+'0';

          }
       }
       for(i=0;i<n-1;i++)
       {
           count1=1;
           temp=1;
            for(j=i+1;j<n;j++)
            {
             if(strcmp(b[i],b[j])==0)
             {
                 count1++;
             }
            }
             if(temp<count1)
                temp=count1;

       }
       if(count1==0)
       {
           printf("1");
       }
       else
       {
           printf("%d",temp+1);
       }
    }
    else
        return 0;
    return 0;
}


#include<stdio.h>
int main()
{
    int **a,n,i,j,count1=1,temp=1;
    scanf("%d",&n);
    char b[101][101];
    if(n>=1&&n<=100)
    {
       a=calloc(n,sizeof(int));
       for(i=0;i<n;i++)
       {
          a[i]=calloc(n,sizeof(int));
       }
       for(i=0;i<n;i++)
       {
               scanf("%s",b[i]);

        }

       for(i=0;i<n-1;i++)
       {
           count1=1;
           temp=1;
            for(j=i+1;j<n;j++)
            {
             if(strcmp(b[i],b[j])==0)
             {
                 count1++;
             }
            }
             if(temp<count1)
                temp=count1;

       }
       if(count1==0)
       {
           printf("1");
       }
       else
       {
           printf("%d",temp+1);
       }
}

    else
        return 0;
    return 0;
}


#include <stdio.h>
#define MAX 100

char flor[MAX][MAX];

int check(int i,int n){
    int j,k,count=0;
    for(j=0;j<n;j++){
        int flag=0;
        for(k=0;k<n;k++){
            if(flor[i][k]!=flor[j][k]) flag=1;
        }
        if(flag==0) count++;
    }
    return count;
}
int main()
{
    int n,max=0,count;
    scanf("%d",&n);
    int i;
    for(i=0;i<n;i++){
            scanf("%s",flor[i]);
    }
    for(i=0;i<n;i++){
        count=check(i,n);
        max=(max>count)?max:count;
    }
    printf("%d",max);

    return 0;
}


#include <stdio.h>
#define MAX 100

int flor[MAX][MAX];

int check(int i,int n){
    int j,k,count=0;
    for(j=0;j<n;j++){
        int flag=0;
        for(k=0;k<n;k++){
            if(flor[i][k]!=flor[j][k]) flag=1;
        }
        if(flag==0) count++;
    }
    return count;
}
int main()
{
    int n,max=0,count;
    scanf("%d",&n);
    int i,j;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            scanf("%d",&flor[i][j]);
        }
    }
    for(i=0;i<n;i++){
        count=check(i,n);
        max=(max>count)?max:count;
    }
    printf("%d",max);

    return 0;
}


#include <stdio.h>
#define MAX 100

int flor[MAX][MAX];

int check(int i,int n){
    int j,k,count=0;
    for(j=0;j<n;j++){
        int flag=0;
        for(k=0;k<n;k++){
            if(flor[i][k]!=flor[j][k]) flag=1;
        }
        if(flag==0) count++;
    }
    return count;
}
int main()
{
    int n,max=0,count;
    scanf("%d",&n);
    int i,j;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            scanf("%d",&flor[i][j]);
        }
    }
    for(i=0;i<n;i++){
        count=check(i,n);
        max=(max>count)?max:count;
    }
    printf("%d",max);

}


#include<stdio.h>

int main()
{
    int a, b, i, j, sum=0, max=0;
    char st[104][103];
    scanf("%d", &a);
    for(i=0;i<a;i++){
        scanf("%s", st[i]);
    }
    for(i=0;i<a;i++){
        sum=0;
        for(j=0;j<a;j++){
            if(strcmp(st[i],st[j])==0){
                sum++;
            }
        }
        if(sum>=max){
            max = sum;
        }

    }
    printf("%d", max);

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

	char str[n][n+1];
	int i,j,k,l;

	for(i=0;i<n;i++)
	{
		scanf("\n%s", str[i]);
		str[i][n]='\0';
	}

	int arr[n];
	for(i=0;i<n;i++)
	arr[i]=1;

	l=0;
	for(i=0;i<n;i++)
	{
		if(str[i][0]=='1' || str[i][0]=='0')
		{
			for(j=i+1;j<n;j++)
			{
				for(k=0;k<4;k++)
				{
					if(str[j][k]!=str[i][k])
					break;
				}
				if(k==4)
				{
					arr[l]++;
					str[j][0]='x';
				}
			}
			l++;
		}
	}

	/*for(i=0;i<l;i++)
	{
		printf("%d ", arr[i]);
	}*/

	int max_index=0;

	for(i=0;i<l;i++)
	{
		if(arr[i]>arr[max_index])
		max_index=i;
	}

	printf("%d", arr[max_index]);

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

	char str[n][n+1];
	int i,j,k,l;

	for(i=0;i<n;i++)
	{
		scanf("\n%s", str[i]);
		str[i][n]='\0';
	}

	int arr[n];
	for(i=0;i<n;i++)
	arr[i]=1;

	l=0;
	for(i=0;i<n;i++)
	{
		if(str[i][0]=='1' || str[i][0]=='0')
		{
			for(j=i+1;j<n;j++)
			{
				for(k=0;k<n;k++)
				{
					if(str[j][k]!=str[i][k])
					break;
				}
				if(k==n)
				{
					arr[l]++;
					str[j][0]='x';
				}
			}
			l++;
		}
	}

	/*for(i=0;i<l;i++)
	{
		printf("%d ", arr[i]);
	}*/

	int max_index=0;

	for(i=0;i<l;i++)
	{
		if(arr[i]>arr[max_index])
		max_index=i;
	}

	printf("%d", arr[max_index]);

	return 0;
}


#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <string.h>
typedef long long ll;
int max(int a,int b){return a>b?a:b;}
int main(void)
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	#endif
	char a[100][101];
	int n;
	scanf("%d",&n);
	int c,i,j,k,ans=0,z;
	//0=dirty
	for(i=0;i<n;i++)scanf("%s",a[i]);
	int count[100]={0};
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)if(a[i][j]=='0')count[i]++;
	}
	int x[100],sz=0;
	memset(x,-1,sizeof(x));
	for(i=0;i<n;i++)
	{
		sz=0;c=1;
		for(j=0;j<n;j++)
		{
			if(a[i][j]=='0')
			{
				x[sz++]=j;
			}
		}
		for(j=i+1;j<n;j++)//for all rows ahead..
		{
			if(count[j]!=count[i])continue;
			for(k=0;k<sz;k++)
			{
				if(a[j][x[k]]!='0')break;
			}
			if(k!=sz)continue;
			c++;
		}
		ans=max(ans,c);
	}
	printf("%d\n",ans);
	return 0;
}


#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <string.h>
typedef long long ll;
int max(int a,int b){return a>b?a:b;}
int main(void)
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	#endif
	char a[100][101];
	int n;
	scanf("%d",&n);
	int c,i,j,k,ans=1,z;
	//0=dirty
	for(i=0;i<n;i++)scanf("%s",a[i]);
	int x[100],sz=0;
	memset(x,-1,sizeof(x));
	for(i=0;i<n;i++)
	{
		sz=0;c=1;
		for(j=0;j<n;j++)
		{
			if(a[i][j]=='0')
			{
				x[sz++]=j;
			}
		}
		for(j=i+1;j<n;j++)//for all rows ahead..
		{
			for(z=0,k=0;k<n;k++)
			{
				if(x[z]==k)//ith row had a 0 here
				{	z++;
					if(a[j][k]!='0')break;
				}
				else if(a[j][k]=='0')break;
			}
			//printf("%d\n",k);
			if(k==n)c++;
		}
		ans=max(ans,c);
	}
	printf("%d\n",ans);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int n, i, j, sum = 0, max = 0;
    scanf("%d", &n);
    char arr[n][n+5];
    for (i = 0; i < n; i++){
        scanf("%s", &arr[i]);
    }
    for (i = 0; i < n; i++){
        max = 0;
        for (j = 0; j < n; j++){
            if (strcmp(arr[i], arr[j]) == 0) max++;
        }
        if (sum < max) sum = max;
    }
    printf("%d\n", sum);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int n=0,i,j;
    scanf("%d",&n);
    char A[101][101];
    for(i=1;i<=n;i++)
        scanf("%s",A[i]);

    int same=0,max=0;
    for(i=1;i<=n-1;i++){
        for(j=i+1;j<=n;j++){
            if(strcmp(A[i],A[j])==0){
                same++;
            }
        }
         if(same>max) max=same;
            same=0;
    }
    max = max + 1;
    printf("%d",max);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int n=0,i,j;
    scanf("%d",&n);
    char A[101][101];
    for(i=1;i<=n;i++)
        scanf("%s",A[i]);

    int same=0,max=0;
    for(i=1;i<=n-1;i++){
        for(j=i+1;j<=n;j++){
            if(strcmp(A[i],A[j])==0){
                same++;
            }
        }
         if(same>max) max=same;
            same=0;
    }
    max = max + 1;
    printf("%d",max);
    return 0;
}
//102020031


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
//||
//\n
int cmpfunc (const void * a, const void * b)
{
   return ( *(int*)a - *(int*)b );
}
int main()
{
             int a,b,c,d,e,i,j,k,sum=0,sum1=0;
             int x[100001],y[200001],z[200001];
             char s[110][110];
             scanf("%d",&a);
             for(i=0;i<101;i++)
                          y[i]=0;
             for(i=0;i<a;i++)
             {
                          scanf("%d",&s[i]);
             }
             for(i=0;i<a;i++)
             {
                          for(j=i;j<a;j++)
                          {
                                       c=strcmp(s[i],s[j]);
                                       if(c==0)
                                       {y[i]=y[i]+1;}

                          }
             }

             qsort(y,a,sizeof(int),cmpfunc);
             printf("%d",y[a-1]);
             return 0;
}


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
//||
//\n
int cmpfunc (const void * a, const void * b)
{
   return ( *(int*)a - *(int*)b );
}
int main()
{
             int a,b,c,d,e,i,j,k,sum=0,sum1=0;
             int x[100001],y[200001],z[200001];
             char s[110][110];
             scanf("%d",&a);
             for(i=0;i<a;i++)
                          y[i]=0;
             for(i=0;i<a;i++)
             {
                          scanf("%s",&s[i]);
             }
             for(i=0;i<a;i++)
             {
                          for(j=0;j<a;j++)
                          {
                                       c=strcmp(s[i],s[j]);
                                       printf("%d ",c);
                                       if(c==0)
                                       {y[i]=y[i]+1;}

                          }
             }

             qsort(y,a,sizeof(int),cmpfunc);
             printf("%d",y[a-1]);
             return 0;
}


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
//||
//\n
int cmpfunc (const void * a, const void * b)
{
   return ( *(int*)a - *(int*)b );
}
int main()
{
             int a,b,c,d,e,i,j,k,sum=0,sum1=0;
             int x[100001],y[200001],z[200001];
             char s[110][110];
             scanf("%d",&a);
             for(i=0;i<a;i++)
                          y[i]=0;
             for(i=0;i<a;i++)
             {
                          scanf("%d",&s[i]);
             }
             for(i=0;i<a;i++)
             {
                          for(j=0;j<a;j++)
                          {
                                       c=strcmp(s[i],s[j]);
                                       if(c==0)
                                       {y[i]=y[i]+1;}

                          }
             }

             qsort(y,a,sizeof(int),cmpfunc);
             printf("%d",y[a-1]);
             return 0;
}


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
//||
//\n
int cmpfunc (const void * a, const void * b)
{
   return ( *(int*)a - *(int*)b );
}
int main()
{
             int a,b,c,d,e,i,j,k,sum=0,sum1=0;
             int x[100001],y[200001],z[200001];
             char s[110][110];
             scanf("%d",&a);
             for(i=0;i<a;i++)
                          y[i]=0;
             for(i=0;i<a;i++)
             {
                          scanf("%s",&s[i]);
             }
             for(i=0;i<a;i++)
             {
                          for(j=0;j<a;j++)
                          {
                                       c=strcmp(s[i],s[j]);

                                       if(c==0)
                                       {y[i]=y[i]+1;}

                          }
             }

             qsort(y,a,sizeof(int),cmpfunc);
             printf("%d",y[a-1]);
             return 0;
}


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
//||
//\n
int cmpfunc (const void * a, const void * b)
{
   return ( *(int*)a - *(int*)b );
}
int main()
{
             int a,b,c,d,e,i,j,k,sum=0,sum1=0;
             int x[100001],y[200001],z[200001];
             char s[110][110];
             scanf("%d",&a);
             for(i=0;i<101;i++)
                          y[i]=0;
             for(i=0;i<a;i++)
             {
                          scanf("%d",&s[i]);
             }
             for(i=0;i<a;i++)
             {
                          for(j=0;j<a;j++)
                          {
                                       c=strcmp(s[i],s[j]);
                                       if(c==0)
                                       {y[i]=y[i]+1;}

                          }
             }

             qsort(y,a,sizeof(int),cmpfunc);
             printf("%d",y[a-1]);
             return 0;
}


#include<stdio.h>
#include<string.h>
int n,i,j,t,s,m;
char carpet[105][105];
int main(){
    scanf("%d",&n);
    for(;i<n;i++) scanf("%s",carpet[i]);
    for(i=0;i<n;i++){
        s=0;
        for(j=0;j<n;j++){
            if(!strcmp(carpet[i],carpet[j]))s++;
        }
        if(s>m)m=s;
    }
    printf("%d",m);
    return 0;
}


#include<stdio.h>
int main()
{
    int n,a,b,c,counting,ans,d,x;
    char arr[111] [111];
    while(scanf(" %d",&n)==1)
    {
        for(a=0; a<n; a++)
        {
            for(b=0; b<n; b++)
            {
                scanf(" %c",&arr[a][b]);
            }
        }
        if(n==1)
        {
            printf("1\n");
        }
        else
        {
            for(b=0; b<n; b++)
            {
                counting=0;
                for(a=0; a<n; a++)
                {
                    if(arr[a][b]=='0')
                        counting++;
                }
                if(counting>=n/2)
                {
                    for(d=0; d<n; d++)
                    {
                        if(arr[d][b]=='0') arr[d][b]='1';
                        else arr[d][b]='0';
                    }
                }
            }
            ans=0;
            for(a=0; a<n; a++)
            {
                counting=0;
                for(b=0; b<n; b++)
                {
                    if(arr[a][b]=='1') counting++;
                }
                if(counting==n) ans++;
            }
            printf("%d\n",ans);
        }
    }
    return 0;
}


#include<stdio.h>
int main()
{
    int n,a,b,c,counting,ans,d,x;
    char arr[111] [111];
    while(scanf(" %d",&n)==1)
    {
        for(a=0; a<n; a++)
        {
            for(b=0; b<n; b++)
            {
                scanf(" %c",&arr[a][b]);
            }
        }
        for(b=0; b<n; b++)
        {
            counting=0;
            for(a=0; a<n; a++)
            {
                if(arr[a][b]=='0')
                    counting++;
            }
            if(counting>=n/2)
            {
                for(d=0; d<n; d++)
                {
                    if(arr[d][b]=='0') arr[d][b]='1';
                    else arr[d][b]='0';
                }
            }
        }
        ans=0;
        for(a=0; a<n; a++)
        {
            counting=0;
            for(b=0; b<n; b++)
            {
                if(arr[a][b]=='1') counting++;
            }
            if(counting==n) ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,a,b,counting,ans;
    char str[111][111];
    while(scanf(" %d",&n)==1)
    {
        for(a=0; a<n; a++)
        {
            scanf("%s",str[a]);
        }
        ans=0;
        for(a=0; a<n; a++)
        {
            counting=0;
            for(b=0; b<n; b++)
            {
                if(strcmp(str[a],str[b])==0)
                    counting++;
            }
            if(counting>ans) ans=counting;
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main() {
	int t,x,i,f=1,j,u,top=1,max=0,adim=0;
	char arr[1000][1000];
	scanf("%d",&x);
	for(i=0;i<x;i++)
			scanf("%s",arr[i]);
	t=x;
	u=strlen(arr);
while(t--){
	for(i=1;i<x;i++){
		for(j=0;j<u;j++){
			if(arr[adim][j]!=arr[i][j]){
				f=0;
				break;
			}
			f=1;
		}
		if(f)
			top++;
	}
	if(top>max)
		max=top;
	adim++;
	top=0;
}
	printf("%d",max);
}


#include <stdio.h>
#include <string.h>

int main()
{
	int i, j, n, cnt=0, ar[101],max=0;
	char a[105][105];

	scanf("%d ",&n);

	for (i = 0; i < n; i++){
		gets(a[i]);
	}
	for ( i = 0; i < n; i++){

		cnt=0;

		if (strcmp(a[i],"a")){

			for (j=i+1;j<n;j++){

				if (!strcmp(a[i],a[j])){
					cnt++;
					strcpy(a[j],"a");
				}
			}
		}
		if (max<cnt) max=cnt;
	}

	if (max==0) printf("1\n");
	else printf("%d\n", max+1);

	return 0;
}


#include <stdio.h>

int main()
{
	int i, j, a[1005], n, nrotate=0, cnt=0, tem;;

	scanf("%d",&n);

	for (i = 0;i < n; i++){
		scanf("%d",&a[i]);
		if (i==0 && a[i]!=0) nrotate=n-a[i];
	}

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

		//clock_wise
		if (i%2==0){
			tem=a[i]+nrotate;
			a[i]=tem%n;
		}

		else{
			tem=a[i]-nrotate;
			if (tem<0){
				a[i]=n+tem;
			}
			else a[i]=tem;
		}

		if (a[i]==i){
			cnt++;
		}
	}
	if (cnt==n) printf("Yes\n");
	else printf("No\n");

/*	for (i=0;i<n;i++){
		printf("%d ",a[i]);
	}
	*/

	return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n,m,x;
    vector<int> a[1000],u;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&m);
        while(m--){
            scanf("%d",&x);
            u.push_back(x);
            a[i].push_back(x);
        }
        sort(a[i].begin(),a[i].end());
    }
    sort(u.begin(),u.end());
    for(int i=0;i<n;i++)
        for(int& x:a[i]) x=lower_bound(u.begin(),u.end(),x)-u.begin();
    int ans=0;
    for(int i=0;i<n;i++){
        int p=(i+n-1)%n,q=(i+1)%n;
        for(size_t j=0;j+1<a[i].size();j++){
            int lo=a[i][j],hi=a[i][j+1];
            auto plo=upper_bound(a[p].begin(),a[p].end(),lo);
            auto phi=lower_bound(a[p].begin(),a[p].end(),hi);
            auto qlo=upper_bound(a[q].begin(),a[q].end(),lo);
            auto qhi=lower_bound(a[q].begin(),a[q].end(),hi);
            if(phi-plo!=qhi-qlo) ans++;
        }
    }
    printf("%d\n",ans);
}


#include <bits/stdc++.h>

using namespace std;
#define int long long
const int maxN = 1000 + 321;
const int mod = 12391;
vector<int> a[maxN];
main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    for(int i = 0; i < n; i ++)
    {
	  int d; cin >> d;
	  for(int j = 0; j < d; j ++)
	  {
		int k; cin >> k;
		a[i].push_back(k);
	  }
	  sort(a[i].begin(), a[i].end());
    }
    int ans = 0;
    for(int i = 0; i < n; i ++)
    {
	  int prev = (i - 1 + n) % n;
	  int nex = (i + 1) % n;
	  for(int j = 0; j < a[i].size() - 1; j ++)
	  {
		int s1 = upper_bound(a[prev].begin(), a[prev].end(), a[i][j]) - a[prev].begin();
		int e1 = lower_bound(a[prev].begin(), a[prev].end(), a[i][j + 1]) - a[prev].begin();
		int s2 = upper_bound(a[nex].begin(), a[nex].end(), a[i][j]) - a[nex].begin();
		int e2 = upper_bound(a[nex].begin(), a[nex].end(), a[i][j + 1]) - a[nex].begin();
		if(e1 - s1 != e2 - s2) ans ++;
	  }
    }
    cout << ans << endl;
    return 0 ;
}


//solution by Wsl_F
#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cmath>
#include <math.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <bitset>
#include <numeric>
#include <cassert>
#include <time.h>
#include <ctime>
#include <memory.h>
#include <complex>
#include <utility>
#include <climits>
#include <cctype>
#include <x86intrin.h>

using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")

typedef long long LL;
typedef unsigned long long uLL;
typedef double dbl;
typedef vector<int> vi;
typedef vector<LL> vL;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;

#define mp(x,y)  make_pair((x),(y))
#define pb(x)  push_back(x)
#define sqr(x) ((x)*(x))

vi p[1010];

int main()
{
 ios_base::sync_with_stdio(0);
 cin.tie(0);
 srand(__rdtsc());
 // LL a[110];
 // memset(a,0,sizeof(a));

 //freopen("input.txt","r",stdin);
 //freopen("output.txt","w",stdout);
 //cout<<fixed;
 //cout<<setprecision(9);
 int n;
 int k;
 int t;
 cin>>n;
 for (int i=0; i<n; i++)
 {
     cin>>k;
     for (int j=0; j<k; j++)
     {
         cin>>t;
         p[i].pb(t);
     }
     sort(p[i].begin(),p[i].end());
 }

int ans= 0;
 for (int i=0; i<n; i++)
 {
     if (p[i].size()<2) continue;
     int l= (i-1+n)%n;
     int r= (i+1)%n;
     int min= p[i][0];
     int jl,jr,kl,kr;
     kl= 0; kr= 0; jl= -1; jr= -1;
        while (jl+1<p[l].size() && p[l][jl+1]<=p[i][0]) jl++;
        while (jr+1<p[r].size() && p[r][jr+1]<=p[i][0]) jr++;

     for (int j=1; j<p[i].size(); j++)
     {
        while (jl+1<p[l].size() && p[l][jl+1]<=p[i][j]) {jl++; kl++;}
        while (jr+1<p[r].size() && p[r][jr+1]<=p[i][j]) {jr++; kr++;}
        if (kl!=kr) {ans++; kl= 0; kr= 0;}
     }
 }
 cout<<ans<<endl;
 return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n;~scanf("%d",&n);){
		vvi bs(n);
		rep(i,n){
			int k; cin>>k;
			bs[i].resize(k);
			rep(j,k)
				cin>>bs[i][j];
			sort(all(bs[i]));
		}

		deque<vi> ps(3,vi(100001));
		rep(i,3){
			vi& b=bs[(i+n-1)%n];
			rep(j,b.size())
				ps[i][b[j]]=1;
			rep(j,100000)
				ps[i][j+1]+=ps[i][j];
		}

		int res=0;
		rep(i,n){
			repi(j,1,bs[i].size()){
				int x1=bs[i][j-1],x2=bs[i][j];
				res+=(ps[0][x2]-ps[0][x1])!=(ps[2][x2]-ps[2][x1]);
			}
			ps.pop_front();
			ps.push_back(vi(100001));
			vi b=bs[(i+2)%n];
			rep(j,b.size())
				ps[2][b[j]]=1;
			rep(j,100000)
				ps[2][j+1]+=ps[2][j];
		}

		cout<<res<<endl;
	}

	return 0;
}