/*
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
int n,t=0,sum=0;
scanf("%d", &n);
while(n>0)
{
t=t*10+n%10;
sum+=n%10;
n/=10;
}
printf("%d\n%d",t,sum );
return 0;
}
*/
/*
#include<stdio.h>
int main()
{
int n,i,a[10]={0},b[10]={0},c[10]={0},d[10]={0},t[1010]={0};
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
}
for(i=0;i<=n;i++)
{
if(a[i]==b[i]&&b[i]==c[i]&&c[i]==d[i])
{
t[i]=50000+a[i]*5000;
}
else if(a[i]==b[i]&&b[i]==c[i]||a[i]==b[i]&&b[i]==d[i]||a[i]==c[i]&&c[i]==d[i])
{
t[i]=10000+a[i]*1000;
}
else if(b[i]==c[i]&&c[i]==d[i])
{
t[i]==10000+b[i]*1000
}
}
}
*/
#include<stdio.h>
int main()
{
int n,i,j,map[1002][5]={0},max=0,a,b,c;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=3;j++)
{
scanf("%d",map[i][j]);
}
}
for(i=1;i<=n;i++)
{
for(j=1;j<=3;j++)
{
if(map[i][1]==3)
{
a+=3;
}
else if(map[i][2]==3)
{
a+=2;
}
else if(map[i][3]==3)
{
a+=1;
}
else if(map[i][1]==2)
{
b+=3;
}
else if(map[i][2]==2)
{
b+=2;
}
else if(map[i][3]==2)
{
b+=1;
}
else if(map[i][1]==1)
{
c+=3;
}
else if()
}
}
}