Help me in solving SC31 problem

My issue

why am i not able to solve this question using xor operation ,why the answer is coming wrong ? please help

My code

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

int main() {
	// your code goes here
int t;
cin>>t;
while(t--){
   int n;
   cin>>n;
   string s1,s2;
   cin>>s1;
   for(int i=1;i<n;i++){
       cin>>s2;
       for(int j=0;j<10;j++){
           
          s1[j]=s1[j]^s2[j];
       }
   }
   int count=0;
   for(int i=0;i<10;i++){
       if(s1[i]=='1'){
           count++;
       }
   }
   cout<<count<<endl;
   
}
}

Problem Link: Weapon Value Practice Coding Problem

@sheftaanis
taking xor will work fine u have made implementation mistake.
plzz refer my c++ code for better understanding

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	    string s[n];
	    for(int i=0;i<n;i++)
	    {
	        cin>>s[i];
	    }
	    int ans=0;
	    for(int i=0;i<10;i++)
	    {
	       int an=0;
	        for(int j=0;j<n;j++)
	        {
	            an=an^(s[j][i]-'0');
	        }
	        ans+=an;
	    }
	    cout<< ans<<endl;
	}
	return 0;
}

i have understood your solution.thank you.

you have substracted by 0 to convert it into digit since xor opertion can only be applied on digits.am i right??

yess