#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//code here;
//	ll t; cin>>t;
//	while(t--) {
		ll n,m,i,j,k; cin>>n>>m;
		vector<string> v(n);
		string s;
		s+="0";
		vector<pair<string,string> > p;
		for(ll i=0;i<n;i++) cin>>v[i];
		for(i=0;i<n;i++) {
			for(j=i+1;j<n;j++) if(v[i][0]==v[j][m-1]) {
				ll k;
				for(k=0;k<m;k++) if(v[i][k]!=v[j][m-1-k]) break;
				if(k==m) {
					p.push_back(make_pair(v[i],v[j]));
					break;
				}
			}
			if(j==n) {
				for(k=0;k<m/2;k++) if(v[i][k]!=v[i][m-1-k]) break;
				if(k==m/2) s=v[i];
			}
		}
		if(s[0]!='0') cout<<2*p.size()*m+m<<endl;
		else cout<<2*p.size()*m<<endl;
		for(i=0;i<p.size();i++) cout<<p[i].first;
		if(s[0]!='0') cout<<s;
		for(i=p.size()-1;i>=0;i--) cout<<p[i].second;
//	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//code here;
//	ll t; cin>>t;
//	while(t--) {
		ll n,m,i,j,k; cin>>n>>m;
		vector<string> v(n);
		string s;
		s+="0";
		vector<pair<string,string> > p;
		for(ll i=0;i<n;i++) cin>>v[i];
		for(i=0;i<n;i++) {
			for(j=i+1;j<n;j++) if(v[i][0]==v[j][m-1]) {
				ll k;
				for(k=0;k<m;k++) if(v[i][k]!=v[j][m-1-k]) break;
				if(k==m) {
					p.push_back(make_pair(v[i],v[j]));
					break;
				}
			}
			if(j==n) {
				for(j=0;j<n/2;j++) if(v[i][j]!=v[i][m-1-j]) break;
				if(j==n/2) s=v[i];
			}
		}
		if(s[0]!='0') cout<<2*p.size()*m+m<<endl;
		else cout<<2*p.size()*m<<endl;
		for(i=0;i<p.size();i++) cout<<p[i].first;
		if(s[0]!='0') cout<<s;
		for(i=p.size()-1;i>=0;i--) cout<<p[i].second;
//	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//code here;
//	ll t; cin>>t;
//	while(t--) {
		ll n,m,i,j,k; cin>>n>>m;
		vector<string> v(n);
		string s;
		s+="0";
		map<ll,ll> mp;
		map<ll,ll> :: iterator it;
		for(ll i=0;i<n;i++) cin>>v[i];
		for(i=0;i<n;i++) {
			for(j=i+1;j<n;j++) if(v[i][0]==v[j][m-1]) {
				ll k;
				for(k=0;k<m;k++) if(v[i][k]!=v[j][m-1-k]) break;
				if(k==m) {
					mp[i]=j;
					break;
				}
			}
			if(j==n) {
				for(j=0;j<n/2;j++) if(v[i][j]!=v[i][m-1-j]) break;
				if(j==n/2) s=v[i];
			}
		}
		if(mp.size()==0 && s[0]=='0') {
			cout<<"0"<<endl;
			return 0;
		}
		if(s[0]!='0') cout<<2*mp.size()*m+m<<endl;
		else cout<<2*mp.size()*m<<endl;
		for(it=mp.begin();it!=mp.end();it++) cout<<v[it->first];
		if(s[0]!='0') cout<<s;
		it=mp.end();
		it--;
		for(;;it--) {
			cout<<v[it->second];
			if(it==mp.begin()) break;
		}
		cout<<endl;
//	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//code here;
//	ll t; cin>>t;
//	while(t--) {
		ll n,m,i,j,k; cin>>n>>m;
		vector<string> v(n);
		string s;
		s+="0";
		vector<pair<string,string> > p;
		for(ll i=0;i<n;i++) cin>>v[i];
		for(i=0;i<n;i++) {
			for(j=i+1;j<n;j++) if(v[i][0]==v[j][m-1]) {
				ll k;
				for(k=0;k<m;k++) if(v[i][k]!=v[j][m-1-k]) break;
				if(k==m) {
					p.push_back(make_pair(v[i],v[j]));
					break;
				}
			}
			if(j==n) {
				for(k=0;k<m/2;k++) if(v[i][k]!=v[i][m-1-k]) break;
				if(k==m/2) s=v[i];
			}
		}
		if(p.size()==0 && s[0]=='0') {
			cout<<"0"<<endl;
			return 0;
		}
		if(s[0]!='0') cout<<2*p.size()*m+m<<endl;
		else cout<<2*p.size()*m<<endl;
		for(i=0;i<p.size();i++) cout<<p[i].first;
		if(s[0]!='0') cout<<s;
		for(i=p.size()-1;i>=0;i--) cout<<p[i].second;
//	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//code here;
//	ll t; cin>>t;
//	while(t--) {
		ll n,m,i,j,k; cin>>n>>m;
		vector<string> v(n);
		string s;
		s+="0";
		vector<pair<string,string> > p;
		for(ll i=0;i<n;i++) cin>>v[i];
		for(i=0;i<n;i++) {
			for(j=i+1;j<n;j++) if(v[i][0]==v[j][m-1]) {
				ll k;
				for(k=0;k<m;k++) if(v[i][k]!=v[j][m-1-k]) break;
				if(k==m) {
					p.push_back(make_pair(v[i],v[j]));
					break;
				}
			}
			if(j==n) {
				for(k=0;k<m/2;k++) if(v[i][k]!=v[i][m-1-k]) break;
				if(k==m/2) s=v[i];
			}
		}
		if(p.size()==0 && s[0]=='0') {
			cout<<"0"<<endl;
			return 0;
		} else if(p.size()==0) {
			cout<<m<<endl<<s<<endl;
			return 0;
		}
		if(s[0]!='0') cout<<2*p.size()*m+m<<endl;
		else cout<<2*p.size()*m<<endl;
		for(i=0;i<p.size();i++) cout<<p[i].first;
		if(s[0]!='0') cout<<s;
		for(i=p.size()-1;i>=0;i--) cout<<p[i].second;
//	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//code here;
//	ll t; cin>>t;
//	while(t--) {
		ll n,m,i,j,k; cin>>n>>m;
		vector<string> v(n);
		string s;
		s+="0";
		vector<pair<string,string> > p;
		for(ll i=0;i<n;i++) cin>>v[i];
		for(i=0;i<n;i++) {
			for(j=i+1;j<n;j++) if(v[i][0]==v[j][m-1]) {
				ll k;
				for(k=0;k<m;k++) if(v[i][k]!=v[j][m-1-k]) break;
				if(k==m) {
					p.push_back(make_pair(v[i],v[j]));
					break;
				}
			}
			if(j==n) {
				for(j=0;j<n/2;j++) if(v[i][j]!=v[i][m-1-j]) break;
				if(j==n/2) s=v[i];
			}
		}
		if(p.size()==0 && s[0]=='0') {
			cout<<"0"<<endl;
			return 0;
		}
		if(s[0]!='0') cout<<2*p.size()*m+m<<endl;
		else cout<<2*p.size()*m<<endl;
		for(i=0;i<p.size();i++) {
			cout<<p[i].first;
			if(i==p.size()) break;
		}
		if(s[0]!='0') cout<<s;
		for(i=p.size()-1;i>=0;i--) {
			cout<<p[i].second;
			if(i==0) break;
		}
//	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//code here;
//	ll t; cin>>t;
//	while(t--) {
		ll n,m,i,j,k; cin>>n>>m;
		vector<string> v(n);
		string s;
		s+="0";
		vector<pair<string,string> > p;
		for(ll i=0;i<n;i++) cin>>v[i];
		for(i=0;i<n;i++) {
			for(j=i+1;j<n;j++) if(v[i][0]==v[j][m-1]) {
				ll k;
				for(k=0;k<m;k++) if(v[i][k]!=v[j][m-1-k]) break;
				if(k==m) {
					p.push_back(make_pair(v[i],v[j]));
					break;
				}
			}
			if(j==n) {
				for(j=0;j<n/2;j++) if(v[i][j]!=v[i][m-1-j]) break;
				if(j==n/2) s=v[i];
			}
		}
		if(p.size()==0 && s[0]=='0') {
			cout<<"0"<<endl;
			return 0;
		} else if(p.size()==0) {
			cout<<m<<endl;
			cout<<s<<endl;
			return 0;
		}
		if(s[0]!='0') cout<<2*p.size()*m+m<<endl;
		else cout<<2*p.size()*m<<endl;
		for(i=0;i<p.size();i++) {
			cout<<p[i].first;
			if(i==p.size()) break;
		}
		if(s[0]!='0') cout<<s;
		for(i=p.size()-1;i>=0;i--) {
			cout<<p[i].second;
			if(i==0) break;
		}
//	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	//code
	int t=1;
	//cin>>t;
	while(t--)
	{
	    int n,m;
	    cin>>n>>m;
	    map<string,int> mp;
	    for(int i=0;i<n;i++)
	     {
	         string s;
	         cin>>s;
	         sort(s.begin(),s.end());
	         if(mp.find(s)!=mp.end())
	          mp[s]++;
	         else
	          mp[s]=1;
	     }

	     string ans="",ans1="";
	     for(auto it=mp.begin();it!=mp.end();it++)
	     {

	   		for(int i=0;i< (it->second)/2;i++)
	   		{
	   			ans+=(it->first);
	   		}
	   		it->second=(it->second)%2;

	     }
	      for(auto it=mp.begin();it!=mp.end();it++)
	     {
	     	if(it->second == 1)
	     	{
	   		  int h[26]={0};
	   		  string st=it->first;
	   		  for(int i=0;i<m;i++)
	   		  {
	   		  	h[st[i]-'a']++;
	   		  }
	   		  int o=0;
	   		  for(int i=0;i<26;i++)
	   		  {
	   		  	if(h[i]%2 ==1)
	   		  	 o++;
	   		  }
	   		  if(o==1 || o==0)
	   		  {
	   		  	char c='#';
	   		  	 for(int i=0;i<26;i++)
	   		    {
	   		  	  if(h[i]>1)
	   		  	   {
	   		  	   	  for(int j=0;j<h[i]/2;j++)
	   		  	   	  ans1+=('a'+i);
	   		  	   }
	   		  	  if(h[i]==1)
	   		  	   c=('a'+i);
	   		    }
	   		    string p=ans1;
	   		    reverse(p.begin(),p.end());
	   		    if(o==1)
	   		    ans1+=c;
	   		    ans1+=p;
	   		    break;
	   		  }
	     	}
	     }

	     string p=ans;
	     reverse(p.begin(),p.end());
	     ans+=ans1;
	     ans+=p;
	     cout<<ans.length()<<"\n";
	     if(ans.length()>0)
	     cout<<ans<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	//code
	int t=1;
	//cin>>t;
	while(t--)
	{
	    int n,m;
	    cin>>n>>m;
	    map<string,int> mp;
	    vector<string> v;
	    for(int i=0;i<n;i++)
	     {
	         string s;
	         cin>>s;
	        // sort(s.begin(),s.end());
	         //if(mp.find(s)!=mp.end())
	         // mp[s]++;
	         //else
	         // mp[s]=1;
	         v.push_back(s);
	     }

	     string ans="",ans1="";
	    for(int i=0;i<n;i++)
	    {
	    	if(v[i]=="")
	    	 continue;
	    	string p=v[i];
	    	reverse(p.begin(),p.end());
	    	for(int j=i+1;j<n;j++)
	    	{
	    		if(v[j]==p)
	    		{
	    			v[j]="";
	    			ans+=v[i];
	    			v[i]="";
	    			break;
	    		}
	    	}
	    }
	      for(int i=0;i<n;i++)
	     {
	     	if(v[i]!="")
	     	{
	   		  string p=v[i];
	   		  reverse(p.begin(),p.end());
	   		  if(v[i]==p)
	   		  {
	   		  	ans1=v[i];
	   		  	break;
	   		  }

	     	}
	     }
	     string f="";
	     if(ans1!="")
	     {
	     for(int i=0;i<n;i++)
	     {
	     	if(v[i]!="")
	     	{
	   		  //string p=v[i];
	   		  //reverse(p.begin(),p.end());
	   		  if(v[i]==ans1)
	   		  {
	   		  	f+=v[i];
	   		  }

	     	}
	     }
	     }
	     string p=ans;
	     reverse(p.begin(),p.end());
	     if(f!="")
	     ans+=f;
	     ans+=p;
	     cout<<ans.length()<<"\n";
	     if(ans.length()>0)
	     cout<<ans;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	//code
	int t=1;
	//cin>>t;
	while(t--)
	{
	    int n,m;
	    cin>>n>>m;
	    map<string,int> mp;
	    vector<string> v;
	    for(int i=0;i<n;i++)
	     {
	         string s;
	         cin>>s;
	        // sort(s.begin(),s.end());
	         //if(mp.find(s)!=mp.end())
	         // mp[s]++;
	         //else
	         // mp[s]=1;
	         v.push_back(s);
	     }

	     string ans="",ans1="";
	    for(int i=0;i<n;i++)
	    {
	    	if(v[i]=="")
	    	 continue;
	    	string p=v[i];
	    	reverse(p.begin(),p.end());
	    	for(int j=i+1;j<n;j++)
	    	{
	    		if(v[j]==p)
	    		{
	    			v[j]="";
	    			ans+=v[i];
	    			v[i]="";
	    			break;
	    		}
	    	}
	    }
	      for(int i=0;i<n;i++)
	     {
	     	if(v[i]!="")
	     	{
	   		  int h[26]={0};
	   		  string st=v[i];
	   		  for(int i=0;i<m;i++)
	   		  {
	   		  	h[st[i]-'a']++;
	   		  }
	   		  int o=0;
	   		  for(int i=0;i<26;i++)
	   		  {
	   		  	if(h[i]%2 ==1)
	   		  	 o++;
	   		  }
	   		  if(o==1 || o==0)
	   		  {
	   		  	char c='#';
	   		  	 for(int i=0;i<26;i++)
	   		    {
	   		  	  if(h[i]>1)
	   		  	   {
	   		  	   	  for(int j=0;j<h[i]/2;j++)
	   		  	   	  ans1+=('a'+i);
	   		  	   }
	   		  	  if(h[i]==1)
	   		  	   c=('a'+i);
	   		    }
	   		    string p=ans1;
	   		    reverse(p.begin(),p.end());
	   		    if(o==1)
	   		    ans1+=c;
	   		    ans1+=p;
	   		    break;
	   		  }
	     	}
	     }

	     string p=ans;
	     reverse(p.begin(),p.end());
	     ans+=ans1;
	     ans+=p;
	     cout<<ans.length()<<"\n";
	     if(ans.length()>0)
	     cout<<ans;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	//code
	int t=1;
	//cin>>t;
	while(t--)
	{
	    int n,m;
	    cin>>n>>m;
	    map<string,int> mp;
	    for(int i=0;i<n;i++)
	     {
	         string s;
	         cin>>s;
	         sort(s.begin(),s.end());
	         if(mp.find(s)!=mp.end())
	          mp[s]++;
	         else
	          mp[s]=1;
	     }

	     string ans="",ans1="";
	     for(auto it=mp.begin();it!=mp.end();it++)
	     {

	   		for(int i=0;i< (it->second)/2;i++)
	   		{
	   			ans+=(it->first);
	   		}
	   		it->second=(it->second)%2;

	     }
	      for(auto it=mp.begin();it!=mp.end();it++)
	     {
	     	if(it->second == 1)
	     	{
	   		  int h[26]={0};
	   		  string st=it->first;
	   		  for(int i=0;i<m;i++)
	   		  {
	   		  	h[st[i]-'a']++;
	   		  }
	   		  int o=0;
	   		  for(int i=0;i<26;i++)
	   		  {
	   		  	if(h[i]%2 ==1)
	   		  	 o++;
	   		  }
	   		  if(o==1 || o==0)
	   		  {
	   		  	char c='#';
	   		  	 for(int i=0;i<26;i++)
	   		    {
	   		  	  if(h[i]>1)
	   		  	   {
	   		  	   	  for(int j=0;j<h[i]/2;j++)
	   		  	   	  ans1+=('a'+i);
	   		  	   }
	   		  	  if(h[i]==1)
	   		  	   c=('a'+i);
	   		    }
	   		    string p=ans1;
	   		    reverse(p.begin(),p.end());
	   		    if(o==1)
	   		    ans1+=c;
	   		    ans1+=p;
	   		    break;
	   		  }
	     	}
	     }

	     string p=ans;
	     reverse(p.begin(),p.end());
	     ans+=ans1;
	     ans+=p;
	     cout<<ans.length()<<"\n";
	     if(ans.length()>0)
	     cout<<ans;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	//code
	int t=1;
	//cin>>t;
	while(t--)
	{
	    int n,m;
	    cin>>n>>m;
	    map<string,int> mp;
	    for(int i=0;i<n;i++)
	     {
	         string s;
	         cin>>s;
	         sort(s.begin(),s.end());
	         if(mp.find(s)!=mp.end())
	          mp[s]++;
	         else
	          mp[s]=1;
	     }

	     string ans="",ans1="";
	     for(auto it=mp.begin();it!=mp.end();it++)
	     {

	   		for(int i=0;i< (it->second)/2;i++)
	   		{
	   			ans+=(it->first);
	   		}
	   		it->second=(it->second)%2;

	     }
	      for(auto it=mp.begin();it!=mp.end();it++)
	     {
	     	if(it->second == 1)
	     	{
	   		  int h[26]={0};
	   		  string st=it->first;
	   		  for(int i=0;i<m;i++)
	   		  {
	   		  	h[st[i]-'a']++;
	   		  }
	   		  int o=0;
	   		  for(int i=0;i<26;i++)
	   		  {
	   		  	if(h[i]%2 ==1)
	   		  	 o++;
	   		  }
	   		  if(o==1 || o==0)
	   		  {
	   		  	char c='#';
	   		  	 for(int i=0;i<26;i++)
	   		    {
	   		  	  if(h[i]>1)
	   		  	   {
	   		  	   	  for(int j=0;j<h[i]/2;j++)
	   		  	   	  ans1+=('a'+i);
	   		  	   }
	   		  	  if(h[i]==1)
	   		  	   c=('a'+i);
	   		    }
	   		    string p=ans1;
	   		    reverse(p.begin(),p.end());
	   		    if(o==1)
	   		    ans1+=c;
	   		    ans1+=p;
	   		    break;
	   		  }
	     	}
	     }

	     string p=ans;
	     reverse(p.begin(),p.end());
	     ans+=ans1;
	     ans+=p;
	     cout<<ans.length()<<"\n";
	     cout<<ans<<"\n";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
        int n,m;cin>>n>>m;
        vector<string>v(n);string itself="";
        for(int i=0;i<n;i++)cin>>v[i];
        deque<string>d;
        int flag=1;int g=1;

        for(int k=0;k<n;k++){
         string s1=v[k];
   for(int j=0;j<m/2;j++){if(s1[j]!=s1[m-1-j])
                            {g=0;break;}
                         }
                         if(g==1){itself=v[k];break;}
                     g=1;
        }

        for(auto it1=v.begin();it1!=v.end();it1++){
                 string s1=*it1;
                 string s2=s1;

                 reverse(s1.begin(),s1.end());auto it5=it1;it5++;
               auto it2=find(it5,v.end(),s1);
               if(it2!=v.end()){
                       d.push_back(s1);
                       d.push_front(s2);
               }
        }
        int y=d.size()/2;
        cout<<(d.size()*m)+itself.length()<<endl;
               for(auto it3=d.begin();it3!=d.end();it3++){
                       cout<<*it3;
                       if(it3-d.begin()==y-1)cout<<itself;
               }
               if(d.size()==0)cout<<itself();
                 cout<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int main(){
        int n,m;cin>>n>>m;
        vector<string>v(n);string itself="";
        for(int i=0;i<n;i++)cin>>v[i];
        deque<string>d;
        int flag=1;int g=1;

        for(int k=0;k<n;k++){
         string s1=v[k];
   for(int j=0;j<m/2;j++){if(s1[j]!=s1[m-1-j])
                            {g=0;break;}
                         }
                         if(g==1){itself=s1[k];break;}
                     g=1;
        }

        for(auto it1=v.begin();it1!=v.end();it1++){
                 string s1=*it1;
                 string s2=s1;

                 reverse(s1.begin(),s1.end());
               auto it2=find(it1,v.end(),s1);
               if(it2!=v.end()){
                       d.push_back(s2);
                       d.push_front(s1);
               }

               int y=d.size()/2;
               for(auto it3=d.begin();it3!=d.end();it3++){
                       cout<<*it3;
                       if(it3-d.begin()==y-1)cout<<itself;
               }
                 cout<<endl;

        }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
        int n,m;cin>>n>>m;
        vector<string>v(n);string itself="";
        for(int i=0;i<n;i++)cin>>v[i];
        deque<string>d;
        int flag=1;int g=1;

        for(int k=0;k<n;k++){
         string s1=v[k];
   for(int j=0;j<m/2;j++){if(s1[j]!=s1[m-1-j])
                            {g=0;break;}
                         }
                         if(g==1){itself=s1[k];break;}
                     g=1;
        }

        for(auto it1=v.begin();it1!=v.end();it1++){
                 string s1=*it1;
                 string s2=s1;

                 reverse(s1.begin(),s1.end());
               auto it2=find(it1,v.end(),s1);
               if(it2!=v.end()){
                       d.push_back(s1);
                       d.push_front(s2);
               }
        }
        int y=d.size()/2;
        cout<<d.size()<<endl;
               for(auto it3=d.begin();it3!=d.end();it3++){
                       cout<<*it3;
                       if(it3-d.begin()==y-1)cout<<itself;
               }
                 cout<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int main(){
        int n,m;cin>>n>>m;
        vector<string>v(n);string itself="";
        for(int i=0;i<n;i++)cin>>v[i];
        deque<string>d;
        int flag=1;int g=1;

        for(int k=0;k<n;k++){
         string s1=v[k];
   for(int j=0;j<m/2;j++){if(s1[j]!=s1[m-1-j])
                            {g=0;break;}
                         }
                         if(g==1){itself=s1[k];break;}
                     g=1;
        }

        for(auto it1=v.begin();it1!=v.end();it1++){
                 string s1=*it1;
                 string s2=s1;

                 reverse(s1.begin(),s1.end());
               auto it2=find(it1,v.end(),s1);
               if(it2!=v.end()){
                       d.push_back(s1);
                       d.push_front(s2);
               }
        }
        int y=d.size()/2;
               for(auto it3=d.begin();it3!=d.end();it3++){
                       cout<<*it3;
                       if(it3-d.begin()==y-1)cout<<itself;
               }
                 cout<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int main(){
        int n,m;cin>>n>>m;
        vector<string>v(n);string itself="";
        for(int i=0;i<n;i++)cin>>v[i];
        deque<string>d;
        int flag=1;int g=1;

        for(int k=0;k<n;k++){
         string s1=v[k];
   for(int j=0;j<m/2;j++){if(s1[j]!=s1[m-1-j])
                            {g=0;break;}
                         }
                         if(g==1){itself=v[k];break;}
                     g=1;
        }

        for(auto it1=v.begin();it1!=v.end();it1++){
                 string s1=*it1;
                 string s2=s1;

                 reverse(s1.begin(),s1.end());auto it5=it1;it5++;
               auto it2=find(it5,v.end(),s1);
               if(it2!=v.end()){
                       d.push_back(s1);
                       d.push_front(s2);
               }
        }
        int y=d.size()/2;
        cout<<d.size()*m<<endl;
               for(auto it3=d.begin();it3!=d.end();it3++){
                       cout<<*it3;
                       if(it3-d.begin()==y-1)cout<<itself;
               }
                 cout<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int main(){
        int n,m;cin>>n>>m;
        vector<string>v(n);string itself="";
        for(int i=0;i<n;i++)cin>>v[i];
        deque<string>d;
        int flag=1;int g=1;

        for(int k=0;k<n;k++){
         string s1=v[k];
   for(int j=0;j<m/2;j++){if(s1[j]!=s1[m-1-j])
                            {g=0;break;}
                         }
                         if(g==1){itself=s1[k];break;}
                     g=1;
        }

        for(auto it1=v.begin();it1!=v.end();it1++){
                 string s1=*it1;
                 string s2=s1;

                 reverse(s1.begin(),s1.end());auto it5=it1;it5++;
               auto it2=find(it5,v.end(),s1);
               if(it2!=v.end()){
                       d.push_back(s1);
                       d.push_front(s2);
               }
        }
        int y=d.size()/2;
        cout<<d.size()*m<<endl;
               for(auto it3=d.begin();it3!=d.end();it3++){
                       cout<<*it3;
                       if(it3-d.begin()==y-1)cout<<itself;
               }
                 cout<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int main(){
        int n,m;cin>>n>>m;
        vector<string>v(n);string itself="";
        for(int i=0;i<n;i++)cin>>v[i];
        deque<string>d;
        int flag=1;int g=1;

        for(int k=0;k<n;k++){
         string s1=v[k];
   for(int j=0;j<m/2;j++){if(s1[j]!=s1[m-1-j])
                            {g=0;break;}
                         }
                         if(g==1){itself=v[k];break;}
                     g=1;
        }

        for(auto it1=v.begin();it1!=v.end();it1++){
                 string s1=*it1;
                 string s2=s1;

                 reverse(s1.begin(),s1.end());auto it5=it1;it5++;
               auto it2=find(it5,v.end(),s1);
               if(it2!=v.end()){
                       d.push_back(s1);
                       d.push_front(s2);
               }
        }
        int y=d.size()/2;
        cout<<(d.size()*m)+itself.length()<<endl;
               for(auto it3=d.begin();it3!=d.end();it3++){
                       cout<<*it3;
                       if(it3-d.begin()==y-1)cout<<itself;
               }
               if(d.size()==0)cout<<itself;
                 cout<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int main(){
        int n,m;cin>>n>>m;
        vector<string>v(n);string itself="";
        for(int i=0;i<n;i++)cin>>v[i];
        deque<string>d;
        int flag=1;int g=1;

        for(int k=0;k<n;k++){
         string s1=v[k];
   for(int j=0;j<m/2;j++){if(s1[j]!=s1[m-1-j])
                            {g=0;break;}
                         }
                         if(g==1){itself=s1[k];break;}
                     g=1;
        }

        for(auto it1=v.begin();it1!=v.end();it1++){
                 string s1=*it1;
                 string s2=s1;

                 reverse(s1.begin(),s1.end());
               auto it2=find(it1,v.end(),s1);
               if(it2!=v.end()){
                       d.push_back(s2);
                       d.push_front(s1);
               }
        }
        int y=d.size()/2;
               for(auto it3=d.begin();it3!=d.end();it3++){
                       cout<<*it3;
                       if(it3-d.begin()==y-1)cout<<itself;
               }
                 cout<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int main(){
        int n,m;cin>>n>>m;
        vector<string>v(n);string itself="";
        for(int i=0;i<n;i++)cin>>v[i];
        deque<string>d;
        int flag=1;int g=1;

        for(int k=0;k<n;k++){
         string s1=v[k];
   for(int j=0;j<m/2;j++){if(s1[j]!=s1[m-1-j])
                            {g=0;break;}
                         }
                         if(g==1){itself=s1[k];break;}
                     g=1;
        }

        for(auto it1=v.begin();it1!=v.end();it1++){
                 string s1=*it1;
                 string s2=s1;

                 reverse(s1.begin(),s1.end());auto it5=it1;it5++;
               auto it2=find(it5,v.end(),s1);
               if(it2!=v.end()){
                       d.push_back(s1);
                       d.push_front(s2);
               }
        }
        int y=d.size()/2;
        cout<<d.size()<<endl;
               for(auto it3=d.begin();it3!=d.end();it3++){
                       cout<<*it3;
                       if(it3-d.begin()==y-1)cout<<itself;
               }
                 cout<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int main(){
        int n,m;cin>>n>>m;
        vector<string>v(n);string itself="";
        for(int i=0;i<n;i++)cin>>v[i];
        deque<string>d;
        int flag=1;int g=1;

        for(int k=0;k<n;k++){
         string s1=v[k];
   for(int j=0;j<m/2;j++){if(s1[j]!=s1[m-1-j])
                            {g=0;break;}
                         }
                         if(g==1){itself=s1[k];break;}
                     g=1;
        }

        for(auto it1=v.begin();it1!=v.end();it1++){
                 string s1=*it1;
                 string s2=s1;

                 reverse(s1.begin(),s1.end());
               auto it2=find(it1,v.end(),s1);
               if(it2!=v.end()){
                       d.push_back(s1);
                       d.push_front(s2);
               }
        }
        int y=d.size()/2;
        cout<<d.size()*m<<endl;
               for(auto it3=d.begin();it3!=d.end();it3++){
                       cout<<*it3;
                       if(it3-d.begin()==y-1)cout<<itself;
               }
                 cout<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int main(){
        int n,m;cin>>n>>m;
        vector<string>v(n);string itself="";
        for(int i=0;i<n;i++)cin>>v[i];
        deque<string>d;
        int flag=1;int g=1;

        for(int k=0;k<n;k++){
         string s1=v[k];
   for(int j=0;j<m/2;j++){if(s1[j]!=s1[m-1-j])
                            {g=0;break;}
                         }
                         if(g==1){itself=v[k];break;}
                     g=1;
        }

        for(auto it1=v.begin();it1!=v.end();it1++){
                 string s1=*it1;
                 string s2=s1;

                 reverse(s1.begin(),s1.end());auto it5=it1;it5++;
               auto it2=find(it5,v.end(),s1);
               if(it2!=v.end()){
                       d.push_back(s1);
                       d.push_front(s2);
               }
        }
        int y=d.size()/2;
        cout<<(d.size()*m)+itself.length()<<endl;
               for(auto it3=d.begin();it3!=d.end();it3++){
                       cout<<*it3;
                       if(it3-d.begin()==y-1)cout<<itself;
               }
                 cout<<endl;

}


#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;

typedef long long INT;
typedef pair<int,int> pii;

const int NN=1010;
const int inf=0x3f3f3f3f;

char s[NN][NN];
char t[NN];
int vst[NN];

vector<int> vec;

main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
#endif
	int n,m,tmp=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>s[i];

	for(int i=1;i<=n;i++){
		if(vst[i])continue;
		vst[i]=1;
		strcpy(t,s[i]);
		reverse(t,t+m);
		for(int j=1;j<=n;j++){
			if(vst[j])continue;
			if(strstr(t,s[j])){
				vst[j]=1;
				vst[i]=2;
				vec.push_back(i);
				break;
			}
		}
		if(vst[i]==1 && strcmp(t,s[i])==0){
			tmp=i;
		}
	}

	int sz=2*m*(vec.size());
	if(tmp)sz+=m;
	cout<<sz<<endl;

	for(int i:vec){
		cout<<s[i];
	}
	if(tmp)cout<<s[tmp];
	for(int i=vec.size()-1;i>=0;i--){
		int j=vec[i];
		strcpy(t,s[j]);
		reverse(t,t+m);
		cout<<t;
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
char s[111][55],a[111][55];
int f[111];
int num[111][3];
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>s[i];
		for(int j=0;j<m;j++){
			a[i][j]=s[i][m-1-j];
		}
	}
		int u=0;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(strcmp(s[i],a[j])==0 and !f[i] and !f[j]){
					u++;
					num[u][1]=i,num[u][2]=j;f[i]=1;f[j]=1;
					break;
				}
			}
		}
		int re=u*2;
		int t=-1;
		for(int i=0;i<n;i++){
			if(!f[i]) if(strcmp(s[i],a[i])==0) {re++;t=i;break;}
		}
		cout<<m*re<<endl;
		for(int i=1;i<=u;i++){
			for(int j=0;j<m;j++){
				cout<<s[num[i][1]][j];
			}
		}
		if(t>=0) for(int i=0;i<m;i++) cout<<s[t][i];
		for(int i=1;i<=u;i++){
			for(int j=0;j<m;j++){
				cout<<s[num[i][2]][j];
			}
		}
	}


#include<bits/stdc++.h>
using namespace std;
char s[111][55],a[111][55];
int f[111];
int num[111][3];
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>s[i];
		for(int j=0;j<m;j++){
			a[i][j]=s[i][m-1-j];
		}
	}
		int u=0;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(strcmp(s[i],a[j])==0 and !f[i] and !f[j]){
					u++;
					num[u][1]=i,num[u][2]=j;f[i]=1;f[j]=1;
					break;
				}
			}
		}
		int re=u*2;
		int t=-1;
		for(int i=0;i<n;i++){
			if(!f[i]) if(strcmp(s[i],a[i])==0) {re++;t=i;break;}
		}
		if(m*re) cout<<m*re<<endl;
		else cout<<0<<endl<<endl;
		for(int i=1;i<=u;i++){
			for(int j=0;j<m;j++){
				cout<<s[num[i][1]][j];
			}
		}
		if(t>=0) for(int i=0;i<m;i++) cout<<s[t][i];
		for(int i=1;i<=u;i++){
			for(int j=0;j<m;j++){
				cout<<s[num[i][2]][j];
			}
		}
	}


#include<bits/stdc++.h>

#define NN 110

using namespace std;

typedef long long INT;

char s[NN][NN],tmp[NN];
int flag[NN];

int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>s[i];
	int ans=0;
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			strcpy(tmp,s[j]);
			int f=0;
			for(int k=0;k<m;k++){
				if(s[i][k]!=tmp[m-k-1]){
					f=1;
					break;
				}
			}
			if(!f){
				flag[i]=j;
				ans++;
			}
		}
	}
	ans*=2;
	for(int i=1;i<=n;i++)
		if(!flag[i]){
			strcpy(tmp,s[i]);
			int f=0;
			for(int k=0;k<m;k++){
				if(s[i][k]!=tmp[m-1-k]){
					f=1;
					break;
				}
			}
			if(!f){
				flag[i]=i;
			}
		}
	for(int i=1;i<=n;i++)if(flag[i]==i){ans++;break;}
	printf("%d\n",ans*m);
	for(int i=1;i<=n;i++)if(flag[i] and flag[i]!=i)printf("%s",s[i]);
	for(int i=1;i<=n;i++)if(flag[i]==i){printf("%s",s[i]);break;}
	for(int i=n;i>=1;i--){
		if(flag[i] and flag[i]!=i){
			printf("%s",s[flag[i]]);
		}
	}

	return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main(){
    int a;
    int e = 0;
    int f = 0;
    cin >> a;
    string c;
    for(int b = 0; b < a; b++){
        getline(cin,c);

        for(int d = 0; d < 5; d+=2){
            if(c.substr(d) == "1"){
                e++;
            }
        }
        if(e > 1){
            f++;

        }
        e = 0;
    }
    cout << f << endl;
    f = 0;
}


#include <iostream>
#include <windows.h>
#define MAX 3
using namespace std;

//main program
main()
{
	//Variables
	int n = 0;
	int x [MAX];
	int y [MAX];
	int z [MAX];
	int result = 0;

	//Insert number of questions
	do
	{
		cin>>n;
	}
	while(n < 1 or n > 1000);

	//Insert 0 and 1
	for(int i = 0; i < n; i++)
	{
		cin>>x[i];
		cin>>y[i];
		cin>>z[i];
		cout<<endl;

		if(x[i] + y[i] + z[i] >= 2)
		{
			result++;
		}
	}

	//Print result
	cout<<result;
}


#include <iostream>
#include <windows.h>
using namespace std;

main()
{
	//Variables
	int n = 0;
	int number [2][n];
	int count = 0;

	//Insert input
	cin>>n;

	//Generate number
	for(int i = 0; i < n; i++)
	{
		cin>>number[0][i];
		cin>>number[1][i];
		cin>>number[2][i];
		cout<<endl;
	}

	//Count and set each result
	for(int i = 0; i < n; i++)
	{
		if((number[0][i] + number[1][i] + number[2][i]) >= 2)
		{
			count++;
		}
	}

	cout<<count<<endl;
}


#include <iostream>
#include <windows.h>
#define MAX 3
using namespace std;

//main program
main()
{
	//Variables
	int n = 0;
	int x [MAX];
	int y [MAX];
	int z [MAX];
	int result = 0;

	//Insert number of questions
	cin>>n;

	for(int i = 0; i < n; i++)
	{
		cin>>x[i];
		cin>>y[i];
		cin>>z[i];
		cout<<endl;

		if(x[i] + y[i] + z[i] >= 2)
		{
			result++;
		}
	}

	//Print result
	cout<<result;
}


#include <iostream>
#include <windows.h>
#define MAX 3
using namespace std;

//main program
main()
{
	//Variables
	int n = 0;
	int x [MAX];
	int y [MAX];
	int z [MAX];
	int result = 0;

	//Insert number of questions
	do
	{
		cin>>n;
	}
	while(n < 1 or n > 100);

	//Insert 0 and 1
	for(int i = 0; i < n; i++)
	{
		cin>>x[i];
		cin>>y[i];
		cin>>z[i];
		cout<<endl;

		if(x[i] + y[i] + z[i] >= 2)
		{
			result++;
		}
	}

	//Print result
	cout<<result;
}


#include <iostream>
#include <windows.h>
#define MAX 3
using namespace std;

//main program
main()
{
	//Variables
	int n = 0;
	int x [MAX];
	int y [MAX];
	int z [MAX];
	int result = 0;

	//Insert number of questions
	do
	{
		cin>>n;
	}
	while(n < 1 or n > 1000);

	//Insert 0 and 1
	for(int i = 0; i < n; i++)
	{
		cin>>x[i];
		cin>>y[i];
		cin>>z[i];
		cout<<endl;

		if(x[i] + y[i] + z[i] >= 2)
		{
			result++;
		}

		x[i] = 0;
		y[i] = 0;
		z[i] = 0;
	}

	//Print result
	cout<<result;
}


#include <iostream>
#include <windows.h>
using namespace std;

//main program
main()
{
	//Variables
	int n = 0;
	int x = 0;
	int y = 0;
	int z = 0;
	int result = 0;

	//Insert number of questions
	do
	{
		cin>>n;
	}
	while(n < 1 or n > 1000);

	//Insert 0 and 1
	for(int i = 0; i < n; i++)
	{
		cin>>x;
		cin>>y;
		cin>>z;
		cout<<endl;

		if(x + y + z >= 2)
		{
			result++;
		}

		x = 0;
		y = 0;
		z = 0;
	}

	//Print result
	cout<<result;
}


#include <iostream>
#include <windows.h>
#define MAX 3
using namespace std;

//Function count
int count(int n, int x[], int y[], int z[], int result)
{
	for(int i = 0; i < n; i++)
	{
		cin>>x[i];
		cin>>y[i];
		cin>>z[i];
		cout<<endl;

		if(x[i] + y[i] + z[i] >= 2)
		{
			result++;
		}
	}
	return result;
}

//main program
main()
{
	//Variables
	int n = 0;
	int x [MAX];
	int y [MAX];
	int z [MAX];
	int result = 0;
	int count(int n, int x[], int y[], int z[], int result);

	//Insert number of questions
	do
	{
		cin>>n;
	}
	while(n < 1 or n > 100);

	result = count(n,x,y,z,result);

	//Print result
	cout<<result;
}


#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
using namespace std;

int main()
{
     int n,p,q,r;
     cin>>n;
     while(n--)
     {
        int t=0;
        cin>>n>>p>>q;
        if(n+p+q>1)
        {
            t++;
        }

     }
     printf("%d",t);

 return 0;

}


#include<iostream>
#include<string>
using namespace std;
int main()
{
     int n,p,q,r,t=0;
     cin>>n;
     for(int i=0;i<n;i++)
     {
         cin>>p>>q>>r;
     }
     if(p+q+r>1)
     {
         t++;
     }
     cout<<t;

 return 0;

}


#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
using namespace std;

int main()
{
     int n,p,q,r,t;
     cin>>n;
     while(n--)
     {
        t=0;
        cin>>n>>p>>q;
        if(n+p+q>1)
        {
            t++;
        }

     }
     printf("%d",t);

 return 0;

}


#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
using namespace std;

int main()
{
     int n,p,q,r;
     cin>>n;
     while(n--)
     {
         int t=0;
        cin>>n>>p>>q;
        if(n+p+q>1)
        {
            t++;
        }

     }
     printf("%d",t);

 return 0;

}


#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
using namespace std;

int main()
{
     int n,p,q,r,t=0;
     cin>>n;
     while(n--)
     {
        cin>>n>>p>>q;
        if(n+p+q>1)
        {
            t++;
        }

     }
     printf("%d",t);

 return 0;

}


#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
using namespace std;

int main()
{
     int n,p,q,r,t=0;

     while(n--)
     {

        cin>>n>>p>>q;
        if(n+p+q>1)
        {
            t++;
        }

     }
     printf("%d",t);

 return 0;

}


#include<stdio.h>
int main(){
    int a;
    scanf("%d",&a);
    int x,y,z;
    int i,count=0;
    for(i=0;i<a;i++){
        scanf("%d%d%d",&x,&y,&z);
        if(x+y+z>1){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
     int n,p,q,r,t=0;
     cin>>n;
     for(int i=0;i<n;i++)
     {
         cin>>p>>q>>r;
     }
     if(p+q+r>1)
     {
         t++;
     }
     cout<<t;

     return 0;

}


#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
using namespace std;

int main()
{
     int n,p,q,r,t=0;
     cin>>n;
     while(n--)
     {
        cin>>n>>p>>q;
        if(n+p+q>1)
        {
            t++;
        }
        else
        {
            continue;
        }
     }
     printf("%d",t);

 return 0;

}


#include <iostream>
using namespace std;
int main()
{
	int n,x[999][999],ans;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int c=0;
		ans=0;
		for(int j=0;j<2;j++)
		{
			cin>>x[i][j];
			if(x[i][j]==1) c++;
		}
		if(c>=2) ans++;
	}
	cout<<ans;
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int n,x[999][999];
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int c=0,ans=0;
		for(int j=0;j<2;j++)
		{
			cin>>x[i][j];
			if(x[i][j]==1) c++;
		}
		if(c>=2) ans++;
	}
	cout<<ans;
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int n,x[999][999],ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int c=0;
		for(int j=0;j<2;j++)
		{
			cin>>x[i][j];
			if(x[i][j]==1) c++;
		}
		if(c>=2) ans++;
	}
	cout<<ans;
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int n,x[999][999],ans;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int c=0
		ans=0;
		for(int j=0;j<2;j++)
		{
			cin>>x[i][j];
			if(x[i][j]==1) c++;
		}
		if(c>=2) ans++;
	}
	cout<<ans;
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int n,x[999][999],ans=0,c;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		c=0;
		for(int j=0;j<2;j++)
		{
			cin>>x[i][j];
			if(x[i][j]==1) c++;
		}
		if(c>=2) ans++;
	}
	cout<<ans;
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int n,x[999][999],c=0,ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<2;j++)
		{
			cin>>x[i][j];
			if(x[i][j]==1) c++;
		}
		if(c>=2) ans++;
		c=0;
	}
	cout<<ans;
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int n,x[999][999],ans;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int c=0;
		for(int j=0;j<2;j++)
		{
			cin>>x[i][j];
			if(x[i][j]==1) c++;
		}
		if(c>=2) ans++;
	}
	cout<<ans;
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int n,x[999][999],ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int c=0;
		for(int j=0;j<3;j++)
		{
			cin>>x[i][j];
			if(x[i][j]==1) c++;
		}
		if(c>=2) ans++;
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f0(n) for(size_t i=0;i<n;i++)
#define f1(n) for(size_t i=1;i<=n;i++)
const double pi= acos(-1);
int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t;

        cin>>t;
        ll a[t];
        ll cnt = 0;
            while(t--)
            {
                f0(3)
                {
                    cin>>a[i];
                    if(a[i] == a[i+1] or a[i] == a[i+2])
                    {
                        cnt++;
                    }
                }
            }
            cout<<cnt<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f0(n) for(size_t i=0;i<n;i++)
#define f1(n) for(size_t i=1;i<=n;i++)
const double pi= acos(-1);
int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t;

        cin>>t;
        ll a[t];
        ll cnt = 0;
            while(t--)
            {
                f0(3)
                {
                    cin>>a[i];
                    if(a[i] == a[i+1] or a[i+2] == a[i])
                    {
                        cnt++;
                    }
                }
            }
            cout<<cnt<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f0(n) for(size_t i=0;i<n;i++)
#define f1(n) for(size_t i=1;i<=n;i++)
const double pi= acos(-1);
int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int  t;
    cin>>t;
        int a[t];
        int cnt = 0;
            f0(t)
            {
                f0(3)
                {
                    cin>>a[i];
                    if(a[i] == a[i+1] or a[i+2] == a[i])
                    {
                        cnt++;
                    }
                }
            }
            cout<<cnt<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f0(n) for(size_t i=0;i<n;i++)
#define f1(n) for(size_t i=1;i<=n;i++)
const double pi= acos(-1);
int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int  t;
    cin>>t;
        int a[t];
        int cnt = 0;
            while(t--)
            {
                f0(3)
                {
                    cin>>a[i];
                    if(a[i] == a[i+1] or a[i+2] == a[i])
                    {
                        cnt++;
                    }
                }
            }
            cout<<cnt<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f0(n) for(size_t i=0;i<n;i++)
#define f1(n) for(size_t i=1;i<=n;i++)
const double pi= acos(-1);
int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int  t;
    cin>>t;
    int cnt = 0;
        f0(t)
        {
            int a,b,c,d;
            cin>>a>>b>>c;
            if(a+b+c >1) cnt++;
        }
        cout<<cnt<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f0(n) for(size_t i=0;i<n;i++)
#define f1(n) for(size_t i=1;i<=n;i++)
const double pi= acos(-1);
int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int  t;
    cin>>t;
        int a[t+1];
        int cnt = 0;
            f0(t)
            {
                f0(t)
                {
                    cin>>a[i];
                    if(a[i] == a[i+1] or a[i+2] == a[i])
                    {
                        cnt++;
                    }
                }
            }
            cout<<cnt<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f0(n) for(size_t i=0;i<n;i++)
#define f1(n) for(size_t i=1;i<=n;i++)
const double pi= acos(-1);
int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int  t;
    cin>>t;
        int a[1000];
        int cnt = 0;
            f0(t)
            {
                f0(t)
                {
                    cin>>a[i];
                    if(a[i] == a[i+1] or a[i+2] == a[i])
                    {
                        cnt++;
                    }
                }
            }
            cout<<cnt<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f0(n) for(size_t i=0;i<n;i++)
#define f1(n) for(size_t i=1;i<=n;i++)
const double pi= acos(-1);
int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int  t;
    cin>>t;
        int a[t];
        int cnt = 0;
            f0(t)
            {
                f0(t)
                {
                    cin>>a[i];
                    if(a[i] == a[i+1] or a[i+2] == a[i])
                    {
                        cnt++;
                    }
                }
            }
            cout<<cnt<<endl;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n, k, d, c,s ;
    cin >> n;

    for(int i=0; i<n; i++){
            s=0;
        for(int i=0; i<3; i++{
           cin >> k;
           if(k==1)
            s++;
        }

        if(s>=2)
            d++;
    }

    cout << d;

    return 0;
}


#include <iostream>
using namespace std;
int main()
{

    int n,s= 0;

    int a[n][3];
    for(int i = 0; i < n; i++)
    {

        for(int j = 0; j < n; j++)
        {

            cin >>a[i][j];
        }
    }
    for(int k = 0; k < n; k++)
    {

        if(a[k][0] + a[k][1] + a[k][2] >= 2)
            s += 1;
    }
    cout << s << endl;
//return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n, k, d, c,s ;
    cin >> n;

    for(int i=0; i<n; i++){
            s=0;
        for(int i=0; i<3; i++){
           cin >> k;
           if(k==1)
            s++;
        }

        if(s>=2)
            d++;
    }

    cout << d;

    return 0;
}


#include <iostream>
#define N 3
using namespace std;
int main()
{
    int n;
    int i, j, a, b = 0;
    cin >> n;
    int nmass[N];
    for(i = 0; i < n; i++){
            a = 0;
        for(j = 0; j < N; j++){
            cin >> nmass[j];
            if(nmass[j] == 1){
                a++;
            }
        }
        if(a == 2){
            b++;
        }

    }

    cout << b;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n, k, d, c,s ;
    cin >> n;
d=0;
    for(int i=0; i<n; i++){
            s=0;
        for(int i=0; i<3; i++){
           cin >> k;
           if(k==1)
            s++;
        }

        if(s>=2)
            d++;
    }

    cout << d;

    return 0;
}


#include<iostream>
using namespace std;
int main() {

int n, j, d, s, k=0;
cin >> n;

	for (int i = 0; i < n; i++) {
		s=0;
	for (int i = 0; i < 3; i++){
		cin >> j;
	if (j == 1)
		s++;
	}
	if (s >= 2)
		k++;
	}

cout << k << endl;

return 0;
}


#include<iostream>
using namespace std;
int main(){
int n,k,s=0;
int a[n][3];
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j)
cin>>a[i][j];
for(int i=1;i<=n; i++){
k=0;
for(int j=1;j<=3;j++){
if(a[i][j]==1)
k++;}
if(k>=2)
s++;}
cout<<s;
}


#include <iostream>
using namespace std;
int main()
{

    int n,s= 0;

    int a[n][3];
    for(int i = 0; i < n; i++)
    {

        for(int j = 0; j < 3; j++)
        {

            cin >>a[i][j];
        }
    }
    for(int k = 0; k < n; k++)
    {

        if(a[k][0] + a[k][1] + a[k][2] >= 2)
            s += 1;
    }
    cout << s << endl;
//return 0;
}


#include <iostream>
using namespace std;

int main()
{
int w{0};
int n;
int a[3];
cin>>n;
while(n--){
for (int i= 0 ; i<3;i++){
    cin>>  a[i];

}
 if ((a[0]+a[1]+a[2])>=2)
    w++;

}
cout<<w;
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
int w{0};
int n;
cin>>n;
int a[2]{0,0,0};
while(n--){
for (int i= 0 ; i<n;i++){
    cin>>  a[i];
    if ((a[0]+a[1]+a[2])>=2){

    w++;}
}

}
cout<<w;
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
int w{0};
int n;
cin>>n;
int a[2];
while(n>0){
for (int i= 0 ; i<n;i++){
    cin>>  a[i];
    if ((a[0]+a[1]+a[2])>=2)
    w++;
}
n--;

}
cout<<w;
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
int w{0};
int n;
int a[3];
cin>>n;
while(n--){
for (int i= 0 ; i<n;i++){
    cin>>  a[i];}
    if ((a[0]+a[1]+a[2])>=2){
    w++;}

}
cout<<w;
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
int w{0};
int n;
int a[3];
cin>>n;
while(n>0){
for (int i= 0 ; i<n;i++){
    cin>>  a[i];
    if ((a[0]+a[1]+a[2])>=2)
    w++;
}
n--;

}
cout<<w;
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
int w{0};
int n;
cin>>n;
int a[n];
for (int i= 0 ; i<n;i++){
    cin>>a[i];
    if ((a[0]+a[1]+a[2])>=2)
    w++;
}
cout<<w;
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
int w{0};
int n;
cin>>n;
while(n>0){
for (int i= 0 ; i<n;i++){
    cin>> int a[i];
    if ((a[0]+a[1]+a[2])>=2)
    w++;
}
n--;

}
cout<<w;
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
int w{0};
int n;
int a[3];
cin>>n;
while(n>0){
for (int i= 0 ; i<n;i++){
    cin>>  a[i];
    if (a[0]+a[1]+a[2]>=2)
    w++;
}
n--;

}
cout<<w;
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
int w{0};
int n;
cin>>n;
int a[3];
while(n>0){
for (int i= 0 ; i<n;i++){
    cin>> a[i];
    if ((a[0]+a[1]+a[2])>=2)
    w++;
}
n--;

}
cout<<w;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
int w{0};
int n;
cin>>n;
while(n>0){
for (int i= 0 ; i<n;i++){
    cin>> int a[i];
    if ((a[0]+a[1]+a[2])>=2)
    w++;
}
n--;

}
cout<<w;
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
int w{0};
int n;
cin<<n;
int a[n];
for (int i= 0 ; i<n;i++){
    cin<<a[i];
    if ((a[0]+a[1]+a[2])>=2)
    w++;
}
cout<<w;
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
int w{0};
int n;
int a[3];
cin>>n;
while(n>0){
for (int i= 0 ; i<3;i++){
    cin>>  a[i];
    if ((a[0]+a[1]+a[2])>=2)
    w++;
}
n--;

}
cout<<w;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main()
{

int a[50][50],r_count= 0,c_count=0,i,j,n;

cin>>n;

for(i=0;i<n;i++)
{
 for(j=0;j<3;j++)
  {
  cin>>a[i][j];
  }
 }

for(i=0;i<n;i++)
{
 for(j=0;j<3;j++)
  {
  if(a[i][j]==1)
  r_count++;
  else
  continue;
  }
  if(r_count>=2)
  c_count++;
  else
  continue;
  r_count=0;
 }

  cout<<c_count;

return 0;

}


#include<bits/stdc++.h>

using namespace std;

int main()
{

int a[50][50],r_count= 0,c_count=0,i,j,n;

cin>>n;

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

for(i=0;i<n;i++)
{
 for(j=0;j<n;j++)
  {
  if(a[i][j]==1)
  r_count++;
  else
  continue;
  }
  if(r_count>=2)
  c_count++;
  else
  continue;
  r_count=0;
 }

  cout<<c_count;

return 0;

}


#include<bits/stdc++.h>

using namespace std;

int main()
{

int a[50][50],r_count= 0,c_count=0,i,j,n;

cin>>n;

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

for(i=0;i<n;i++)
{
 for(j=0;j<n;j++)
  {
  if(a[i][j]==1)
  r_count++;
  }
  if(r_count>=2)
  c_count++;
 }

  cout<<c_count;

return 0;

}


#include<bits/stdc++.h>

using namespace std;

int main()
{

int n,a[n][3],r_count= 0,c_count=0,i,j;

cin>>n;

for(i=0;i<n;i++)
{
 for(j=0;j<3;j++)
  {
  cin>>a[i][j];
  }
 }

for(i=0;i<n;i++)
{
r_count=0;
 for(j=0;j<3;j++)
  {

  if(a[i][j]==1)
  r_count++;
  else
  continue;
  }
  if(r_count>=2)
  c_count++;
  else
  continue;
 }

  cout<<c_count;

return 0;

}


#include<bits/stdc++.h>

using namespace std;

int main()
{

int n,a[5],r_count= 0,c_count=0,i,j;

cin>>n;

while(n--)
{
for(i=0;i<3;i++)
{
cin>>a[i];
}
r_count=0;
for(i=0;i<3;i++)
{
 if(a[i]==1)
  r_count++;
   }
    if(r_count>=2)
    c_count++;
    }
     cout<<c_count;
      return 0;
      }


#include<bits/stdc++.h>

using namespace std;

int main()
{

int a[500][3],r_count= 0,c_count=0,i,j,n;

cin>>n;

for(i=0;i<n;i++)
{
 for(j=0;j<3;j++)
  {
  cin>>a[i][j];
  }
 }

for(i=0;i<n;i++)
{
r_count=0;
 for(j=0;j<3;j++)
  {

  if(a[i][j]==1)
  r_count++;
  else
  continue;
  }
  if(r_count>=2)
  c_count++;
  else
  continue;
 }

  cout<<c_count;

return 0;

}


#include<bits/stdc++.h>

using namespace std;

int main()
{

int a[n][3],r_count= 0,c_count=0,i,j,n;

cin>>n;

for(i=0;i<n;i++)
{
 for(j=0;j<3;j++)
  {
  cin>>a[i][j];
  }
 }

for(i=0;i<n;i++)
{
r_count=0;
 for(j=0;j<3;j++)
  {

  if(a[i][j]==1)
  r_count++;
  else
  continue;
  }
  if(r_count>=2)
  c_count++;
  else
  continue;
 }

  cout<<c_count;

return 0;

}


#include<bits/stdc++.h>

using namespace std;

int main()
{

int a[50][50],r_count= 0,c_count=0,i,j;

cin>>n;

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

for(i=0;i<n;i++)
{
 for(j=0;j<n;j++)
  {
  if(a[i][j]==1)
  r_count++;
  }
  if(r_count>=2)
  c_count++;
 }

  cout<<c_count;

return 0;

}


#include<bits/stdc++.h>

using namespace std;

int main()
{

int a[50][50],r_count= 0,c_count=0,i,j,n;

cin>>n;

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

for(i=0;i<n;i++)
{
 for(j=0;j<n;j++)
  {
  if(a[i][j]==1)
  r_count++;
  }
  if(r_count>=2)
  c_count++;
  break;
 }

  cout<<c_count;

return 0;

}


#include<bits/stdc++.h>

using namespace std;

int main()
{

int a[50][50],r_count= 0,c_count=0,i,j,n;

cin>>n;

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

for(i=0;i<n;i++)
{
 for(j=0;j<n;j++)
  {
  if(a[i][j]==1)
  r_count++;
  else
  continue;
  }
  if(r_count>=2)
  c_count++;
  else
  continue;
 }

  cout<<c_count;

return 0;

}


#include<bits/stdc++.h>

using namespace std;

int main()
{

int a[50][50],r_count= 0,c_count=0,i,j,n;

cin>>n;

for(i=0;i<n;i++)
{
 for(j=0;j<3;j++)
  {
  cin>>a[i][j];
  }
 }

for(i=0;i<n;i++)
{
r_count=0;
 for(j=0;j<3;j++)
  {

  if(a[i][j]==1)
  r_count++;
  else
  continue;
  }
  if(r_count>=2)
  c_count++;
  else
  continue;
 }

  cout<<c_count;

return 0;

}


#include<bits/stdc++.h>

using namespace std;

int main()
{

int a[50][50],r_count= 0,c_count=0,i,j,n;

cin>>n;

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

for(i=0;i<n;i++)
{
 for(j=0;j<n;j++)
  {
  if(a[i][j]==1)
  r_count++;
  }
  if(r_count>=2)
  c_count++;
  break;
 }

  cout<<c_count+1;

return 0;

}


#include<iostream>
using namespace std;
int main()
{
    int n,k,j=0,count[]={0};
    cin>>n;
    int a[n][n];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(a[i][j]==1)
            {
                count[i]++;
            }
        }
    }
    int max=0;
    for(int i=0;i<n;i++)
    {
        if(count[i]>=2)
        {
            max++;
        }
    }
     cout<<max;
}


#include<iostream>
using namespace std;
int main()
{
    int n,j=0;
    cin>>n;
    int a[n][n],count[500]={0};
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(a[i][j]==1)
            {
                count[i]++;
            }
        }
    }
    int max=0;
    for(int i=0;i<n;i++)
    {
        if(count[i]>=2)
        {
            max++;
        }
    }
     cout<<max;
}


#include<iostream>
using namespace std;
int main()
{
    int n,k,j=0,count[1000]={0},a[1000][1000];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(a[i][j]==1)
            {
                count[i]++;
            }
        }
    }
    int max=0;
    for(int i=0;i<n;i++)
    {
        if(count[i]>=2)
        {
            max++;
        }
    }
     cout<<max;
}


#include<iostream>
using namespace std;
int main()
{
    int n,k,j=0,count[100]={0},a[300][300];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(a[i][j]==1)
            {
                count[i]++;
            }
        }
    }
    int max=0;
    for(int i=0;i<n;i++)
    {
        if(count[i]>=2)
        {
            max++;
        }
    }
     cout<<max;
}


#include<iostream>
using namespace std;
int main()
{
    int n,k,j=0,count[300]={0},a[300][300];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(a[i][j]==1)
            {
                count[i]++;
            }
        }
    }
    int max=0;
    for(int i=0;i<n;i++)
    {
        if(count[i]>=2)
        {
            max++;
        }
    }
     cout<<max;
}


#include<iostream>
using namespace std;
int main()
{
    int n,j=0;
    cin>>n;
    int a[n][n],count[n]={0};
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(a[i][j]==1)
            {
                count[i]++;
            }
        }
    }
    int max=0;
    for(int i=0;i<n;i++)
    {
        if(count[i]>=2)
        {
            max++;
        }
    }
     cout<<max;
}


#include<iostream>
using namespace std;
int main()
{
    int n,j=0;
    cin>>n;
    int a[n][3],count[n]={0};
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(a[i][j]==1)
            {
                count[i]++;
            }
        }
    }
    int max=0;
    for(int i=0;i<n;i++)
    {
        if(count[i]>=2)
        {
            max++;
        }
    }
     cout<<max;
}


#include<iostream>
using namespace std;
int main()
{
    int n,k,j=0,count[300]={0},a[100][100];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(a[i][j]==1)
            {
                count[i]++;
            }
        }
    }
    int max=0;
    for(int i=0;i<n;i++)
    {
        if(count[i]>=2)
        {
            max++;
        }
    }
     cout<<max;
}


#include<iostream>
using namespace std;
int main()
{
    int n,k,j=0,count[500]={0},a[500][500];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(a[i][j]==1)
            {
                count[i]++;
            }
        }
    }
    int max=0;
    for(int i=0;i<n;i++)
    {
        if(count[i]>=2)
        {
            max++;
        }
    }
     cout<<max;
}


#include<iostream>
using namespace std;
int main()
{
    int n,k,j=0,count[100]={0},a[100][100];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(a[i][j]==1)
            {
                count[i]++;
            }
        }
    }
    int max=0;
    for(int i=0;i<n;i++)
    {
        if(count[i]>=2)
        {
            max++;
        }
    }
     cout<<max;
}


#include<iostream>
using namespace std;
int main()
{
    int n,k,j=0,count[10000]={0},a[10000][10000];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(a[i][j]==1)
            {
                count[i]++;
            }
        }
    }
    int max=0;
    for(int i=0;i<n;i++)
    {
        if(count[i]>=2)
        {
            max++;
        }
    }
     cout<<max;
}


#include<iostream>
using namespace std;
int main()
{
    int n,k,j=0,count[5]={0},a[100][100];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(a[i][j]==1)
            {
                count[i]++;
            }
        }
    }
    int max=0;
    for(int i=0;i<n;i++)
    {
        if(count[i]>=2)
        {
            max++;
        }
    cout<<max;
}


#include<iostream>
using namespace std;
int main()
{
    int n,k,j=0,count[5]={0},a[100][100];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(a[i][j]==1)
            {
                count[i]++;
            }
        }
    }
    int max=0;
    for(int i=0;i<n;i++)
    {
        if(count[i]>=2)
        {
            max++;
        }
    cout<<max;
    }
}


#include<iostream>
using namespace std;
int main()
{
    int n,k,j=0,count[5]={0},a[100][100];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(a[i][j]==1)
            {
                count[i]++;
            }
        }
    }
    int max=0;
    for(int i=0;i<n;i++)
    {
        if(count[i]>=2)
        {
            max++;
        }
    }
     cout<<max;
}


  #include<iostream>
 using namespace std;
 int main() {
 int p , v , t , N , sum =0;
 cin >> N ;
 for (int i = 0; i < N;i++){
 cin >> p >> v >> t;
 if (p == v == t) {
 sum++;
 } else if (p == v != t) {
 sum++;
 } else if (p != v == t) {
 sum++;
 } else if (p != v != t)
  sum;
 }
 return 0
 }


#include<iostream>
 #include<conio.h>
 using namespace std;
 int main() {
 int n , p , v , t , sum = 0;
 cin >> n ; {
 for(int i = 0 ; i < n ; i++) }
 cin >> p , v , t ; {
 if (p == v && v == t && t == p)
 sum++;
  }{else if (p!=v && v == t && t==p)
 sum++;
 }{else if (p==v && v != t && t==p)
 sum++;
 } else (p==v && v ==t && t!=p) {
 sum++; }

 cout << sum;
 return 0 ;
 }


#include<iostream>
 using namespace std;
 int main() {
 int p , v , t , N , sum =0;
 cin >> N ;
 for (int i = 0; i < N;i++){
 cin >> p >> v >> t;
 if (p == v && v == t && p == t) {
 sum++;
 } else if (p == v && v != t && p == t) {
 sum++;
 } else if (p != v && v == t && p == t) {
 sum++;
 } else if ( p != v && v != t && p == t ) {
  sum = 0;
 } else if ( p != v && v == t && p != t ) {
  sum = 0;
 } else if ( p != v && v != t && p == t ) {
  sum = 0;
 } else if ( p == v && v == t && p != t ) {
  sum++;
 } else if ( p != v && v != t && p != t ) {
  sum = 0;
 }
 }
 cout << sum;
 return 0;
 }


#include<iostream>
 using namespace std;
 int main() {
 int n , p , v , t , sum = 0;
 cin >> n ;
 for(int i = 0 ; i < n ; i++) {
 cin >> p , v , t ; {
 if (p == v && v == t && t == p) {
 sum++;
  }{else if (p!=v && v == t && t==p){
 sum++;
  }else if (p==v && v != t && t==p) {
 sum++;
 } else (p==v && v ==t && t!=p) {
 sum++; }
 }

 cout << sum;
 return 0;
 }


 #include<iostream>

 using namespace std;
 int main() {
 int p , v , t , N , sum =0;
 cin >> N ;
 for (int i = 0; i < N;i++){
 cin >> p >> v >> t;
 if (p+v+t >= 2) {
    sum++;
 }
 }
    cout << sum;
 return 0;
 }


#include<iostream>
 using namespace std;
 int main() {
 int n , p , v , t , sum = 0;
 cin >> n ; {
 for(int i = 0 ; i < n ; i++) }
 cin >> p , v , t ; {
 if (p == v && v == t && t == p)
 sum++;
  }{else if (p!=v && v == t && t==p)
 sum++;
 }{else if (p==v && v != t && t==p)
 sum++;
 } else (p==v && v ==t && t!=p) {
 sum++; }

 cout << sum;
 return 0;
 }


#include<iostream>
 using namespace std;
 int main() {
 int n , p , v , t , sum = 0;
 cin >> n ;
 for(int i = 0 ; i < n ; i++) {
 cin >> p , v , t ;
  } if (p == v && v == t && t == p) {
 sum++;
   } else if (p!=v && v == t && t==p) {
 sum++;
  } else if (p==v && v != t && t==p) {
 sum++;
 } else (p==v && v ==t && t!=p) {
 sum++;
 }

 cout << sum;
 return 0 ;
 }


#include<iostream>
 #include<conio.h>
 using namespace std;
 int main() {
 int p , v , t , N , sum =0;
 cin >> N ;
 for (int i = 0; i < N;i++){
 cin >> p >> v >> t;
 if (p == v && v == t && p == t) {
 sum++;
 } else if (p == v && v != t && p == t) {
 sum++;
 } else if (p != v && v == t && p == t) {
 sum++;
 } else if ( p != v && v != t && p == t ) {
  sum = 0;
 } else if ( p != v && v == t && p != t ) {
  sum = 0;
 } else if ( p != v && v != t && p == t ) {
  sum = 0;
 } else if ( p == v && v == t && p != t ) {
  sum++;
 } else if ( p != v && v != t && p != t ) {
  sum = 0;
 }
 }
 cout << sum;
 getch();
 }


#include<iostream>
 using namespace std;
 int main() {
 int p , v , t , N , sum =0;
 cin >> N ;
 for (int i = 0; i < N;i++){
 cin >> p >> v >> t;
 if (p == v && v == t && p == t) {
 sum++;
 } else if (p == v && v != t && p == t) {
 sum++;
 } else if (p != v && v == t && p == t) {
 sum++;
 } else if ( p != v && v != t && p == t ) {
  sum++;
  sum--;
 } else if ( p != v && v == t && p != t ) {
  sum++;
  sum--;
 } else if ( p != v && v != t && p == t ) {
  sum++;
  sum--;
 } else if ( p == v && v == t && p != t ) {
  sum++;
 } else if ( p != v && v != t && p != t ) {
  sum++;
  sum--;
 }
 }
 cout << sum;
 return 0;
 }


            #include <iostream>

            using namespace std;

            int main()
            {
                int n, j=0, a, b, c; cin>>n;
                for(int i=1; i<=n; i++)
                {
                      cin>>a, b, c;
                      if (a+b+c>=2)
                      {
                                j++;
                      }
                }
                cout<<j<<endl; return 0;
            }


        #include <iostream>

        using namespace std;

        int main()
        {
            int n, j, a, b, c, d, e, f, g, h, i; cin>>n;
            cin>>a, b, c;
            cin>>d, e, f;
            cin>>g, h, i;
            while(true)
            {
            if (a+b+c>=n-(a+b+c)/2)
            {
                      j++;
            }
            if (d+e+f>=n-(d+e+f)/2)
            {
                      j++;
            }
            if (g+h+i>=n-(g+h+i)/2)
            {
                      j++;
            }
            else
            {
              break;
            }
            }
            cout<<j<<endl; return 0;
        }


            #include <iostream>

            using namespace std;

            int main()
            {
                int n, j=0, a, b, c; cin>>n;
                for(int i=1; i<=n; i++)
                {
                      cin>>a>>b>>c;
                      if (a+b+c>=2)
                      {
                                j++
                      }
                }
                cout<<j<<endl; return 0;
            }


            #include <iostream>

            using namespace std;

            int main()
            {
                int n, j=0, a, b, c; cin>>n;
                for(int i=1; i<=n; i++)
                {
                      cin>>a>>b>>c;
                      if (a+b+c>=2)
                      {
                                j++;
                      }
                }
                cout<<j<<endl; return 0;
            }


#include<iostream>
using namespace std;
long long b[1000];
int main()
{
    long long n, i, j, dem=0, x;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {
            cin>>x;
            if(x==1)
                b[i]=1;
            else
            if(x==2)
                b[j]=1;
            else
            if(x==3)
            {
                b[i]=1;
                b[j]=1;
            }
        }
    }
    for(i=1; i<=n; i++)
    {
        if(b[i]==0)
            dem++;
    }
    cout<<dem<<endl;
    for(i=1; i<=n; i++)
    {
        if(b[i]==0)
            cout<<i<<" ";
    }
}


#include<bits/stdc++.h>
using namespace std;
int a[105][105];
int main()
{
    int n;
    int cnt=0;
    vector<int>g;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        for(int j=n; j>=1; j--)
        {
            cin>>a[i][j];
            if(a[i][j]==1)
            {
                g.push_back(j);
                cnt++;
            }
            else if(a[i][j]==2)
            {
                g.push_back(i);
                cnt++;
            }
        }
    }
    sort(g.begin(),g.end());
    cout<<cnt<<endl;
    for(int i=0; i<g.size(); i++)
        cout<<g[i]<<" ";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[105][105];
int main()
{
    int n;
    int cnt=0;
    vector<int>g;
    cin>>n;
    for(int j=1; j<=n; j++)
    {
        for(int i=1; i<=n; i++)
        {
            cin>>a[j][i];
            if(a[j][i]==1)
            {
                g.push_back(j);
                cnt++;
            }
            else if(a[j][i]==2)
            {
                g.push_back(j);
                cnt++;
            }
        }
    }
    sort(g.begin(),g.end());
    cout<<cnt<<endl;
    for(int i=0; i<g.size(); i++)
        cout<<g[i]<<" ";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int vis[105];
int a[105][105];
int main()
{
    int n;
    int cnt=0;
    vector<int>g;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            cin>>a[i][j];
            if(a[i][j]==1)
            {
                vis[i]=1;
            }
            else if(a[i][j]==2)
            {
                vis[j]=1;
            }
            else if(a[i][j]==3)
            {
                vis[i]=1;
                vis[j]=1;
            }
        }
    }
    //cout<<n-cnt<<endl;
    for(int i=1;i<=n;i++)
        if(!vis[i])cnt++;
    cout<<cnt<<endl;
    for(int i=1;i<=n;i++)
        if(!vis[i])cout<<i<<" ";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int vis[105];
int a[105][105];
int main()
{
    int n;
    int cnt=0;
    vector<int>g;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            cin>>a[i][j];
            if(a[i][j]==1&&!vis[i])
            {
                vis[i]=1;
                cnt++;
            }
            else if(a[i][j]==2&&!vis[j])
            {
                cnt++;
                vis[j]=1;
            }
        }
    }
    cout<<n-cnt<<endl;
    for(int i=1;i<=n;i++)
        if(!vis[i])cout<<i<<" ";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int vis[105];
int a[105][105];
int main()
{
    int n;
    int cnt=0;
    vector<int>g;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            cin>>a[i][j];
            if(a[i][j]==1&&!vis[i])
            {
                vis[i]=1;
            }
            else if(a[i][j]==2&&!vis[j])
            {
                vis[j]=1;
            }
            else if(a[i][j]==3&&!vis[i]&&!vis[j])
            {
                vis[i]=1;
                vis[j]=1;
            }
        }
    }
    //cout<<n-cnt<<endl;
    for(int i=1;i<=n;i++)
        if(!vis[i])cnt++;
    cout<<cnt<<endl;
    for(int i=1;i<=n;i++)
        if(!vis[i])cout<<i<<" ";

    return 0;
}


/*
 ***********Good LUCK**********
 * Author:  why
 * Created Time:  2015/5/21 17:48:44
 * File Name: \cf\a.cpp
 */
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <vector>
#include <string>
#include <time.h>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define Zero(x)  memset((x),0, sizeof(x))
#define Neg(x) memset((x), -1, sizeof(x))
#define dg(x) cout << #x << " = " << x << endl
#define pk(x)   push_back(x)
#define pok()   pop_back()
#define eps 1e-8
#define pii pair<int, int>
#define pi acos(-1.0)
using namespace std;
typedef long long ll;
bool debug = true;
int OK = 1;
int main(){
    //freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    //cin.sync_with_stdio(false);
    int n;
    int a[105][105];
    cin>>n;
    for (int i=0;i<n;++i){
        for (int j=0;j<n;++j)
            cin>>a[i][j];
    }
    int tag[105] = {0};
    int cnt = 0;
    for (int i=0;i<n;++i){
        if (tag[i]) continue;
        for (int j=i+1;j<n;++j){
            if (a[i][j]==0) continue;
            if (a[i][j]==1) tag[i] = 1;
            else if (a[i][j]==2) tag[j] = 1;
            else tag[i] = tag[j] = 1;
            cnt += tag[i]+tag[j];
            break;
        }
    }
    cnt = n -cnt;
    cout<<cnt<<endl;
    int i=0;
    while (tag[i] && i<n) ++i;
    if (i<n) cout<<i+1;
    for (++i;i<n;++i)
       if (!tag[i]) cout<<" "<<i+1;
    if (cnt) cout<<endl;
    return 0;
}


/*
 ***********Good LUCK**********
 * Author:  why
 * Created Time:  2015/5/21 17:48:44
 * File Name: \cf\a.cpp
 */
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <vector>
#include <string>
#include <time.h>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define Zero(x)  memset((x),0, sizeof(x))
#define Neg(x) memset((x), -1, sizeof(x))
#define dg(x) cout << #x << " = " << x << endl
#define pk(x)   push_back(x)
#define pok()   pop_back()
#define eps 1e-8
#define pii pair<int, int>
#define pi acos(-1.0)
using namespace std;
typedef long long ll;
bool debug = true;
int OK = 1;
int main(){
    //freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    //cin.sync_with_stdio(false);
    int n;
    int a[105][105];
    cin>>n;
    for (int i=0;i<n;++i){
        for (int j=0;j<n;++j)
            cin>>a[i][j];
    }
    int tag[105] = {0};
    int cnt = 0;
    for (int i=0;i<n;++i){
        if (tag[i]) continue;
        for (int j=i+1;j<n;++j){
            if (a[i][j]==0) continue;
            if (a[i][j]==1) tag[i] = 1;
            else if (a[i][j]==2) tag[j] = 1;
            else tag[i] = tag[j] = 1;
            cnt += tag[i]+tag[j];
            break;
        }
    }
    cnt = n -cnt;
    cout<<cnt<<endl;
    int i=0;
    while (tag[i] && i<n) ++i;
    cout<<i+1;
    for (++i;i<n;++i)
       if (!tag[i]) cout<<" "<<i+1;
    if (cnt) cout<<endl;
    return 0;
}


/*
 ***********Good LUCK**********
 * Author:  why
 * Created Time:  2015/5/21 17:48:44
 * File Name: \cf\a.cpp
 */
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <vector>
#include <string>
#include <time.h>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define Zero(x)  memset((x),0, sizeof(x))
#define Neg(x) memset((x), -1, sizeof(x))
#define dg(x) cout << #x << " = " << x << endl
#define pk(x)   push_back(x)
#define pok()   pop_back()
#define eps 1e-8
#define pii pair<int, int>
#define pi acos(-1.0)
using namespace std;
typedef long long ll;
bool debug = true;
int OK = 1;
int main(){
    //freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    //cin.sync_with_stdio(false);
    int n;
    int a[105][105];
    cin>>n;
    for (int i=0;i<n;++i){
        for (int j=0;j<n;++j)
            cin>>a[i][j];
    }
    int tag[105] = {0};
    int cnt = 0;
    for (int i=0;i<n;++i){
        for (int j=0;j<n;++j){
            if (a[i][j]==0 || a[i][j]==-1) continue;
            if (a[i][j]==1) tag[i] = 1;
            else if (a[i][j]==2) tag[j] = 1;
            else if (a[i][j]==3) tag[i] = tag[j] = 1;
            break;
        }
    }
    for (int i=0;i<n;++i) if(!tag[i]) ++cnt;
    cout<<cnt<<endl;
    int i=0;
    while (tag[i] && i<n) ++i;
    if (i<n) cout<<i+1;
    for (++i;i<n;++i)
       if (!tag[i]) cout<<" "<<i+1;
    if (cnt) cout<<endl;
    return 0;
}


/*
 ***********Good LUCK**********
 * Author:  why
 * Created Time:  2015/5/21 17:48:44
 * File Name: \cf\a.cpp
 */
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <vector>
#include <string>
#include <time.h>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define Zero(x)  memset((x),0, sizeof(x))
#define Neg(x) memset((x), -1, sizeof(x))
#define dg(x) cout << #x << " = " << x << endl
#define pk(x)   push_back(x)
#define pok()   pop_back()
#define eps 1e-8
#define pii pair<int, int>
#define pi acos(-1.0)
using namespace std;
typedef long long ll;
bool debug = true;
int OK = 1;
int main(){
    //freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    //cin.sync_with_stdio(false);
   	int n;
  	int a[105][105];
	cin>>n;
	for (int i=0;i<n;++i){
		for (int j=0;j<n;++j)
			cin>>a[i][j];
	}
	int tag[105] = {0};
	int cnt = 0;
	for (int i=0;i<n;++i){
		if (tag[i]) continue;
		for (int j=0;j<n;++j){
			if (a[i][j]==0) continue;
			if (a[i][j]==1) tag[i] = 1;
			else if (a[i][j]==2) tag[j] = 1;
			else if (a[i][j]==3) tag[i] = tag[j] = 1;
			break;
		}
	}
	for (int i=0;i<n;++i) if(!tag[i]) ++cnt;
	cout<<cnt<<endl;
	int i=0;
	while (tag[i] && i<n) ++i;
	if (i<n) cout<<i+1;
	for (++i;i<n;++i)
	   if (!tag[i])	cout<<" "<<i+1;
	if (cnt) cout<<endl;
    return 0;
}


/*
 ***********Good LUCK**********
 * Author:  why
 * Created Time:  2015/5/21 17:48:44
 * File Name: \cf\a.cpp
 */
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <vector>
#include <string>
#include <time.h>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define Zero(x)  memset((x),0, sizeof(x))
#define Neg(x) memset((x), -1, sizeof(x))
#define dg(x) cout << #x << " = " << x << endl
#define pk(x)   push_back(x)
#define pok()   pop_back()
#define eps 1e-8
#define pii pair<int, int>
#define pi acos(-1.0)
using namespace std;
typedef long long ll;
bool debug = true;
int OK = 1;
int main(){
    //freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    //cin.sync_with_stdio(false);
    int n;
    int a[105][105];
    cin>>n;
    for (int i=0;i<n;++i){
        for (int j=0;j<n;++j)
            cin>>a[i][j];
    }
    int tag[105] = {0};
    int cnt = 0;
    for (int i=0;i<n;++i){
        for (int j=0;j<n;++j){
            if (a[i][j]==0 || a[i][j]==-1) continue;
            if (a[i][j]==1) tag[i] = 1;
            else if (a[i][j]==2) tag[j] = 1;
            else if (a[i][j]==3) tag[i] = tag[j] = 1;
        }
    }
    for (int i=0;i<n;++i) if(!tag[i]) ++cnt;
    cout<<cnt<<endl;
    int i=0;
    while (tag[i] && i<n) ++i;
    if (i<n) cout<<i+1;
    for (++i;i<n;++i)
       if (!tag[i]) cout<<" "<<i+1;
    if (cnt) cout<<endl;
    return 0;
}


/*
 ***********Good LUCK**********
 * Author:  why
 * Created Time:  2015/5/21 17:48:44
 * File Name: \cf\a.cpp
 */
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <vector>
#include <string>
#include <time.h>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define Zero(x)  memset((x),0, sizeof(x))
#define Neg(x) memset((x), -1, sizeof(x))
#define dg(x) cout << #x << " = " << x << endl
#define pk(x)   push_back(x)
#define pok()   pop_back()
#define eps 1e-8
#define pii pair<int, int>
#define pi acos(-1.0)
using namespace std;
typedef long long ll;
bool debug = true;
int OK = 1;
int main(){
    //freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    //cin.sync_with_stdio(false);
    int n;
    int a[105][105];
    cin>>n;
    for (int i=0;i<n;++i){
        for (int j=0;j<n;++j)
            cin>>a[i][j];
    }
    int tag[105];
    Zero(tag);
    int cnt = 0;
    for (int i=0;i<n;++i){
        if (tag[i]==1) continue;
        for (int j=i+1;j<n;++j){
            if (a[i][j]==0) continue;
            if (a[i][j]==1) tag[i] = 1;
            else if (a[i][j]==2) tag[j] = 1;
            else if (a[i][j]==3) tag[i] = tag[j] = 1;
            break;
        }
    }
    for (int i=0;i<n;++i) if(tag[i]==0) ++cnt;
    cout<<cnt<<endl;
    int i=0;
    while (tag[i] && i<n) ++i;
    if (i<n) cout<<i+1;
    for (++i;i<n;++i)
       if (!tag[i]) cout<<" "<<i+1;
    if (cnt) cout<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define FILEIO 0
using namespace std;

int main() {
#if FILEIO
    freopen("input.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    int mat[n][n];
    int rs[n];
    for (int i=0; i<n; i++) rs[i] = 1;
    for (int i=0; i<n; i++)
        for (int j=0; j<n; j++){
            cin >> mat[i][j];
            if (mat[i][j] == 1) rs[i]--;
            if (mat[i][j] == 2) rs[j]--;
            if (mat[i][j] == 3) {
                rs[i] --;
                rs[j] --;
            }
        }
    int r = 0;
    for (int i=0; i<n; i++)
        if (rs[i] > 0) r++;
    cout << r;

    return 0;
}


#include <bits/stdc++.h>
#define FILEIO 0
using namespace std;

int main() {
#if FILEIO
    freopen("input.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    int mat[n][n];
    int rs[n];
    for (int i=0; i<n; i++) rs[i] = 1;
    for (int i=0; i<n; i++)
        for (int j=0; j<n; j++){
            cin >> mat[i][j];
            if (mat[i][j] == 1) rs[i]--;
            if (mat[i][j] == 2) rs[j]--;
            if (mat[i][j] == 3) {
                rs[i] --;
                rs[j] --;
            }
        }
    int r = 0;
    for (int i=0; i<n; i++)
        if (rs[i] > 0) r++;
    cout << r << 'n';
    for (int i=0; i<n; i++)
        if (rs[i] > 0)
            cout << i+1 << (i == n-1?"":' ');
    return 0;
}


#include <bits/stdc++.h>
#define FILEIO true
using namespace std;

int main() {
#if FILEIO
    freopen("input.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    int mat[n][n];
    int rs[n];
    for (int i=0; i<n; i++) rs[i] = 1;
    for (int i=0; i<n; i++)
        for (int j=0; j<n; j++){
            cin >> mat[i][j];
            if (mat[i][j] == 1) rs[i]--;
            if (mat[i][j] == 2) rs[j]--;
            if (mat[i][j] == 3) {
                rs[i] --;
                rs[j] --;
            }
        }
    int r = 0;
    for (int i=0; i<n; i++)
        if (rs[i] > 0) r++;
    cout << r;

    return 0;
}


#include <bits/stdc++.h>
#define FILEIO 0
using namespace std;

int main() {
#if FILEIO
    freopen("input.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    int mat[n][n];
    int rs[n];
    for (int i=0; i<n; i++) rs[i] = 1;
    for (int i=0; i<n; i++)
        for (int j=0; j<n; j++){
            cin >> mat[i][j];
            if (mat[i][j] == 1) rs[i]--;
            if (mat[i][j] == 2) rs[j]--;
            if (mat[i][j] == 3) {
                rs[i] --;
                rs[j] --;
            }
        }
    int r = 0;
    for (int i=0; i<n; i++)
        if (rs[i] > 0) r++;
    cout << r << 'n';
    for (int i=0; i<n; i++)
        if (rs[i] > 0)
            cout << i+1 << (i == n-1?'':' ');
    return 0;
}


#include <bits/stdc++.h>
#define FILEIO 0
using namespace std;

int main() {
#if FILEIO
    freopen("input.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    int mat[n][n];
    int rs[n];
    for (int i=0; i<n; i++) rs[i] = 1;
    for (int i=0; i<n; i++)
        for (int j=0; j<n; j++){
            cin >> mat[i][j];
            if (mat[i][j] == 1) rs[i]--;
            if (mat[i][j] == 2) rs[j]--;
            if (mat[i][j] == 3) {
                rs[i] --;
                rs[j] --;
            }
        }
    int r = 0;
    for (int i=0; i<n; i++)
        if (rs[i] > 0) r++;
    cout << r << '\n';
    for (int i=0; i<n; i++)
        if (rs[i] > 0)
            cout << i+1 << ((i == n-1)?"":" ");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
 int main()
 {
   int mat[100][100];
   int i,j;
   int n;
   vector<int> vec;
   cin>>n;
   for(i=0;i<n;i++)
   {
     for(j=0;j<n;j++)
        cin>>mat[i][j];
   }
   for(i=0;i<n;i++)
   {
    int flag=1;
      for(j=0;j<n;j++)
      {
          if(mat[i][j]==1||mat[i][j]==3)
          {
             flag=0;
             break;
           }
      }
      if(flag)
        vec.push_back(i+1);
   }
   cout<<vec.size()<<endl;

   for(i=0;i<vec.size();i++)
       cout<<vec[i]<<" ";
   return 0;
 }


#include<bits/stdc++.h>
using namespace std;
 int main()
 {
   int mat[100][100];
   int n;
   cin>>n;
   for(i=0;i<n;i++)
   {
     for(j=0;j<n;j++)
        cin>>mat[i][j];
        }
        for(i=0;i<n;i++)
        {
           for(j=0;j<n;j++)
           {
                if(mat[i][j]==2||mat[i][j]==3)
                [
               {
                   vec.push_back(i);
                   break;
                   }
                   }}
                   cout<<vec.size<<endl;
                   for(i=vec.begin();i!=vec.end();i++)
                      cout<<vec[i]<<" ";
                      return 0;
                      }


#include<bits/stdc++.h>
using namespace std;
 int main()
 {
   int mat[100][100];
   int i,j;
   int n;
   vector<int> vec;
   cin>>n;
   for(i=0;i<n;i++)
   {
     for(j=0;j<n;j++)
        cin>>mat[i][j];
   }
   for(i=0;i<n;i++)
   {
    int flag=1;
      for(j=0;j<n;j++)
      {
          if(mat[i][j]==1||mat[i][j]==3)
          {
             flag=0;
             break;
           }
      }
      if(flag)
        vec.push_back(i+1);
   }
   cout<<vec.size()<<endl;
   vector<int>::iterator it;
   for(it=vec.begin();it!=vec.end();it++)
       cout<<vec[*it]<<" ";
   return 0;
 }


#include<bits/stdc++.h>
using namespace std;
 int main()
 {
   int mat[100][100];
   int i,j;
   int n;
   vector<int>vec;
   cin>>n;
   for(i=0;i<n;i++)
   {
     for(j=0;j<n;j++)
        cin>>mat[i][j];
   }
   for(i=0;i<n;i++)
   {
      for(j=0;j<n;j++)
      {
          if(mat[i][j]==2||mat[i][j]==0)
          {
             vec.push_back(i+1);
             break;
           }
      }
   }
   cout<<vec.size()<<endl;
   vector<int>::iterator it;
   for(it=vec.begin();it!=vec.end();it++)
       cout<<vec[it]<<" ";
   return 0;
 }


#include<bits/stdc++.h>
using namespace std;
 int main()
 {
   int mat[100][100];
   int i,j;
   int n;
   vector<int>vec;
   cin>>n;
   for(i=0;i<n;i++)
   {
     for(j=0;j<n;j++)
        cin>>mat[i][j];
   }
   for(i=0;i<n;i++)
   {
      for(j=0;j<n;j++)
      {
          if(mat[i][j]==2||mat[i][j]==0)
          {
             vec.push_back(i+1);
             break;
           }
      }
   }
   cout<<vec.size()<<endl;
   vector<int>::iterator it;
   for(it=vec.begin();it!=vec.end();it++)
       cout<<vec[*it]<<" ";
   return 0;
 }


#include<bits/stdc++.h>
using namespace std;
 int main()
 {
   int mat[100][100];
   int i,j;
   int n;
   vector<int>vec;
   cin>>n;
   for(i=0;i<n;i++)
   {
     for(j=0;j<n;j++)
        cin>>mat[i][j];
   }
   for(i=0;i<n;i++)
   {
    int flag=1;
      for(j=0;j<n;j++)
      {
          if(mat[i][j]==1||mat[i][j]==3)
          {
             flag=0;
             break;
           }
      }
      if(flag)
        vec.push_back(i+1);
   }
   cout<<vec.size()<<endl;
   vector<int>::iterator it;
   for(it=vec.begin();it!=vec.end();it++)
       cout<<vec[*it]<<" ";
   return 0;
 }


#include<bits/stdc++.h>
using namespace std;
 int main()
 {
   int mat[100][100];
   int i,j;
   int n;
   vector<int>vec;
   cin>>n;
   for(i=0;i<n;i++)
   {
     for(j=0;j<n;j++)
        cin>>mat[i][j];
   }
   for(i=0;i<n;i++)
   {
      for(j=0;j<n;j++)
      {
          if(mat[i][j]==2||mat[i][j]==0)
          {
             vec.push_back(i+1);
             break;
           }
      }
   }
   cout<<vec.size<<endl;
   for(i=vec.begin();i!=vec.end();i++)
       cout<<vec[i]<<" ";
   return 0;
 }


#include<bits/stdc++.h>
using namespace std;
 int main()
 {
   int mat[100][100];
   int i,j;
   int n;
   vector<int>vec;
   cin>>n;
   for(i=0;i<n;i++)
   {
     for(j=0;j<n;j++)
        cin>>mat[i][j];
   }
   for(i=0;i<n;i++)
   {
    int flag=1;
      for(j=0;j<n;j++)
      {
          if(mat[i][j]==1||mat[i][j]==3)
          {
             flag=0;
             //break;
           }
      }
      if(flag)
        vec.push_back(i+1);
   }
   cout<<vec.size()<<endl;
   vector<int>::iterator it;
   for(it=vec.begin();it!=vec.end();it++)
       cout<<vec[*it]<<" ";
   return 0;
 }


#include<bits/stdc++.h>
using namespace std;
 int main()
 {
   int mat[100][100];
   int i,j;
   int n;
   vector<int>vec;
   cin>>n;
   for(i=0;i<n;i++)
   {
     for(j=0;j<n;j++)
        cin>>mat[i][j];
   }
   for(i=0;i<n;i++)
   {
      for(j=0;j<n;j++)
      {
          if(mat[i][j]==1||mat[i][j]==3)
          {

             break;
           }
      }
      if(j==n)
        vec.push_back(i+1);
   }
   cout<<vec.size()<<endl;
   vector<int>::iterator it;
   for(it=vec.begin();it!=vec.end();it++)
       cout<<vec[*it]<<" ";
   return 0;
 }


#include<bits/stdc++.h>
using namespace std;
 int main()
 {
   int mat[100][100];
   int i,j;
   int n;
   vector<int>vec;
   cin>>n;
   for(i=0;i<n;i++)
   {
     for(j=0;j<n;j++)
        cin>>mat[i][j];
   }
   for(i=0;i<n;i++)
   {
      for(j=0;j<n;j++)
      {
          if(mat[i][j]==2||mat[i][j]==0)
          {
             vec.push_back(i+1);
             break;
           }
      }
   }
   cout<<vec.size()<<endl;
   for(i=vec.begin();i!=vec.end();i++)
       cout<<vec[i]<<" ";
   return 0;
 }


#include <bits/stdc++.h>
using namespace std;

int main()
 {
   int n, sum=0;
   cin >> n;
   int c[n][n];
   int g[n];

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

   for (int i=1; i<=n; i++)
    for (int j=1; j<=n; j++)
	   cin >> c[i][j];

	 for (int i=1; i<=n; i++)
      for (int j=1; j<=n; j++)
	   if ((i==1) && (j==1) && (n==1))
	     g[i] = 1;
	   else if (i==j)
         continue;
	   else
	    if ((c[i][j] == 0) || (c[i][j] == 2))
	      g[i] = 1;
	    else
        g[i] = 0;

     for (int i=1; i<=n; i++)
      sum = sum + g[i];

   cout << sum << endl;
   for (int i=1; i<=n; i++)
    if (g[i]==1)
	 cout << i << " ";

   return 0;
 }


#include <bits/stdc++.h>
using namespace std;

int main()
 {
   int n, sum=0;
   cin >> n;
   int c[n][n];
   int g[n];

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

   for (int i=1; i<=n; i++)
    for (int j=1; j<=n; j++)
	   cin >> c[i][j];

	for (int i=1; i<=n; i++)
     for (int j=1; j<=n; j++)
	  if (i==j) continue;
	   else if ((c[i][j] == 0) || (c[i][j] == 2))
	     g[i] = 1;
	   else
         g[i] = 0;

     for (int i=1; i<=n; i++)
      sum = sum + g[i];

   cout << sum << endl;
   for (int i=1; i<=n; i++)
    if (g[i]==1)
	 cout << i << " ";

   return 0;
 }


#include <iostream>
using namespace std;

int main() {
 int n, count=0, flag=0;
 cin >> n;
 int cars[n][n];
 bool good[n][n];
 int row[n];

 for (int i=1; i<=n; i++)
 {
     row[i] = 0;
	 for (int j=1; j<=n; j++)
	 {
         cars[i][j] =0;
		 good[i][j] = false;
	 }
 }

 for (int i=1; i<=n; i++)
 {
   for (int j=1; j<=n; j++)
   {
		cin >> cars[i][j];
     	if ((i==j) && (cars[i][j]==-1))
			good[i][j] = true;
		else
		 if (cars[i][j]==0 || cars[i][j]==2)
			good[i][j] = true;
   }
 }

 for (int i=1; i<=n; i++)
 {
   for (int j=1; j<=n; j++)
   {
      if (good[i][j] == true)
		  flag = 1;
	  else
	   {
		  flag = 0;
		  break;
	   }
   }
   if (flag==1)
   {
	   count++;
	   row[i] = i;
   }
 }
 cout << count << endl;
 for (int i=1; i<=n; i++)
	 if (row[i]!=0)
		 cout << row[i] << " ";
 return(0);
}


#include <bits/stdc++.h>
using namespace std;

int main()
 {
   int n, sum=0;
   cin >> n;
   int c[n][n];
   int g[n];

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

   for (int i=1; i<=n; i++)
    for (int j=1; j<=n; j++)
	   cin >> c[i][j];

	 for (int i=1; i<=n; i++)
      for (int j=1; j<=n; j++)
	   if ((c[i][j] == 0) || (c[i][j] == 2) || c[i][j]==-1)
	      g[i] = 1;
	    else
        g[i] = 0;

     for (int i=1; i<=n; i++)
      sum = sum + g[i];

   cout << sum << endl;
   for (int i=1; i<=n; i++)
    if (g[i]==1)
	 cout << i << " ";

   return 0;
 }


#include <iostream>
using namespace std;

int main() {
 int n, count=0, flag=0;
 cin >> n;
 int cars[n][n];
 int good[n][n];
 int row[n];

 for (int i=1; i<=n; i++)
 {
     row[i] = 0;
	 for (int j=1; j<=n; j++)
         cars[i][j] =0;
 }

 for (int i=1; i<=n; i++)
 {
   for (int j=1; j<=n; j++)
   {
		cin >> cars[i][j];
     	if ((i==j) && (cars[i][j]==-1))
			good[i][j] = 1;
		else
		 if (cars[i][j]==0 || cars[i][j]==2)
			good[i][j] = 1;
   }
 }

 for (int i=1; i<=n; i++)
 {
   for (int j=1; j<=n; j++)
   {
      if (good[i][j] == 1)
		  flag = 1;
	  else
	   {
		  flag = 0;
		  break;
	   }
   }
   if (flag==1)
   {
	   count++;
	   row[i] = i;
   }
 }
 cout << count << endl;
 for (int i=1; i<=n; i++)
	 if (row[i]!=0)
		 cout << row[i] << " ";
 return(0);
}


#include <iostream>
#include <string>
using namespace std;

int main() {
 int n, count=0, flag=0;

 cin >> n;
 int cars[n][n];
 bool good[n][n];
 int row[n];

 for (int i=0; i<n; i++)
 {
	 row[i] = 0;
	 for (int j=0; j<n; j++)
	 {
         cars[i][j] =0;
		 good[i][j] = false;
	 }
 }

 for (int i=0; i<n; i++)
 {
   for (int j=0; j<n; j++)
   {
		cin >> cars[i][j];
     	if ((i==j) && (cars[i][j]==-1))
			good[i][j] = true;
		else
		 if (cars[i][j]==0 || cars[i][j]==2)
			good[i][j] = true;
   }
 }

 for (int i=0; i<n; i++)
 {
   for (int j=0; j<n; j++)
   {
      if (good[i][j] == true)
		  flag = 1;
	  else
	   {
		  flag = 0;
		  break;
	   }
   }
   if (flag==1)
   {
	   count++;
	   row[i] = i+1;
   }
 }
 cout << count << endl;
 for (int i=0; i<n; i++)
	 if (row[i] !=0)
      cout << row[i]<<" ";

 return(0);
}


#include <iostream>
using namespace std;

int main() {
 int n, count=0, flag=0;
 cin >> n;
 int cars[n][n];
 int good[n][n];
 int row[n];

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

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

 for (int i=1; i<=n; i++)
  for (int j=1; j<=n; j++)
   cin >> cars[i][j];

 for (int i=1; i<=n; i++)
 {
   for (int j=1; j<=n; j++)
   {
     	if ((i==j) && (cars[i][j]==-1))
			good[i][j] = 1;
		else if ((i!=j) && ((cars[i][j]==0 || cars[i][j]==2)))
			good[i][j] = 1;
   }
 }
 for (int i=1; i<=n; i++)
 {
   for (int j=1; j<=n; j++)
   {
      if (good[i][j] == 1)
		  flag = 1;
	  else
	   {
		  flag = 0;
		  break;
	   }
   }
   if (flag==1)
   {
	   count++;
	   row[i] = i;
   }
 }
 cout << count << endl;
 for (int i=1; i<=n; i++)
	 if (row[i]!=0)
		 cout << row[i] << " ";
 return(0);
}


#include <iostream>
using namespace std;

int main() {
 int n, count=0, flag=0;
 cin >> n;
 int cars[n][n];
 int good[n][n];
 int row[n];

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

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

 for (int i=1; i<=n; i++)
  for (int j=1; j<=n; j++)
   cin >> cars[i][j];

 for (int i=1; i<=n; i++)
 {
   for (int j=1; j<=n; j++)
   {
     	if ((i==j) && (cars[i][j]==-1))
			good[i][j] = 1;
		else
		 if (cars[i][j]==0 || cars[i][j]==2)
			good[i][j] = 1;
   }
 }

 for (int i=1; i<=n; i++)
 {
   for (int j=1; j<=n; j++)
   {
      if (good[i][j] == 1)
		  flag = 1;
	  else
	   {
		  flag = 0;
		  break;
	   }
   }
   if (flag==1)
   {
	   count++;
	   row[i] = i;
   }
 }
 cout << count << endl;
 for (int i=1; i<=n; i++)
	 if (row[i]!=0)
		 cout << row[i] << " ";
 return(0);
}


#include <bits/stdc++.h>
using namespace std;

int main()
 {
   int n, sum=0;
   cin >> n;
   int c[n][n];
   int g[n];

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

   for (int i=1; i<=n; i++)
    for (int j=1; j<=n; j++)
	   cin >> c[i][j];

	 for (int i=1; i<=n; i++)
      for (int j=1; j<=n; j++)
	   if (n==1)
	    g[i]=1;
	   else if (i==j)
	    continue;
       else if ((c[i][j] == 0) || (c[i][j] == 2))
	      g[i] = 1;
	   else
        g[i] = 0;

     for (int i=1; i<=n; i++)
      sum = sum + g[i];

   cout << sum << endl;
   for (int i=1; i<=n; i++)
    if (g[i]==1)
	 cout << i << " ";

   return 0;
 }


/**
    Author: Shuvojit
    Time: 2015-05-22-18.01
    Comment:
*/
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define ll long long
using namespace std;
int main()
{
    freopen("ip","r",stdin);
    int T,count,a[108][108],visited[108],n;
    T=1;
    while(T--)
    {
        scanf("%d",&n);
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
            scanf("%d",&a[i][j]);
        memset(visited,0,sizeof visited);
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(a[i][j]==1)
                {
                    visited[i]=1;
                }
                else if(a[i][j]==3)
                {
                    visited[i]=1;
                    visited[j]=1;
                }
                else if(a[i][j]==2)
                    visited[j]=1;
            }
        }
        count=0;
        for(int i=0;i<n;i++)
            if(visited[i]==0)
                count++;
        printf("%d\n",count);
        for(int i=0;i<n;i++)
            if(visited[i]==0)
                printf("%d ",i+1);
        printf("\n");

    }
    return 0;
}


/**
    Author: Shuvojit
    Time: 2015-05-22-18.01
    Comment:
*/
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define ll long long
using namespace std;
int main()
{
    freopen("ip","r",stdin);
    int T,count,a[108][108],visited[108],n;
    T=1;
    while(T--)
    {
        scanf("%d",&n);
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
            scanf("%d",&a[i][j]);
        memset(visited,0,sizeof visited);
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(a[i][j]==1 || a[i][j]==3)
                {
                    visited[i]=1;
                    visited[j]=1;
                }
                else if(a[i][j]==2)
                    visited[j]=1;
            }
        }
        count=0;
        for(int i=0;i<n;i++)
            if(visited[i]==0)
                count++;
        printf("%d\n",count);
        for(int i=0;i<n;i++)
            if(visited[i]==0)
                printf("%d ",i+1);
        printf("\n");

    }
    return 0;
}


/**
    Author: Shuvojit
    Time: 2015-05-22-18.01
    Comment:
*/
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define ll long long
using namespace std;
int main()
{
    freopen("ip","r",stdin);
    int T,count,a[108][108],visited[108],n;
    T=1;
    while(T--)
    {
        scanf("%d",&n);
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
            scanf("%d",&a[i][j]);
        memset(visited,0,sizeof visited);
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(a[i][j]==1)
                {
                    visited[i]=1;
                }
                else if(a[i][j]==3)
                {
                    visited[i]=1;
                    visited[j]=1;
                }
                else if(a[i][j]==2)
                    visited[j]=1;
            }
        }

        count=0;
        for(int i=0;i<n;i++)
            if(visited[i]==0)
                count++;
        printf("%d\n",count);
        for(int i=0;i<n;i++)
            if(visited[i]==0)
                printf("%d ",i+1);
        //printf("\n");

    }
    return 0;
}


/**
    Author: Shuvojit
    Time: 2015-05-22-18.01
    Comment:
*/
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define ll long long
using namespace std;
int main()
{
    //freopen("ip","r",stdin);
    int T,count,a[108][108],visited[108],n;
    T=1;
    while(T--)
    {
        scanf("%d",&n);
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
            scanf("%d",&a[i][j]);
        memset(visited,0,sizeof visited);
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(a[i][j]==1)
                {
                    visited[i]=1;
                }
                else if(a[i][j]==3)
                {
                    visited[i]=1;
                    visited[j]=1;
                }
                else if(a[i][j]==2)
                    visited[j]=1;
            }
        }

        count=0;
        for(int i=0;i<n;i++)
            if(visited[i]==0)
                count++;
        printf("%d\n",count);
        for(int i=0;i<n;i++)
            if(visited[i]==0)
                printf("%d ",i+1);
        //printf("\n");

    }
    return 0;
}


#include <iostream>
#include <vector>
//#define DEBUG
using namespace std;
struct CarInfo
{
	int num,state;
};
int main()
{
	int Nmax = 100;
	int n;
	int a[Nmax][Nmax];
	cin>>n;
	vector<CarInfo> cars(n);
	for(int i = 0; i < n; i++)
	{
		cars[i].state = 1;
		for(int j = 0; j < n; j++)
		{
			cin>>a[i][j];
			if(a[i][j] == 1) cars[i].state = 0;
			if(a[i][j] == 3) cars[i].state = cars[j].state = 0;
		}
	}
	int count = 0;
	for(int i = 0; i < n; i++)
		if(cars[i].state)count++;
	cout<<count<<endl;
	for(int i = 0; i < n; i++)
		if(cars[i].state)cout<<i+1<<" ";
#ifdef DEBUG
	system("pause");
#endif
	cars.clear();
	return 0;
}