Anagram - We need to find how many deletion we need to do to make two string anagram. But here when i included all code inside the test case for loop the output is coming wrong but when i remove that for loop its coming correct . What is the problem?

#include
#include
using namespace std;
int main()
{
int t;
cin>>t;
for( ;t>0;t–)
{
string a,b;
int c=0;
getline(cin,a);
getline(cin,b);
int a1=a.length();
int b1=b.length();
for(int i=0;i<a1;i++)
{
for(int j=0;j<b1;j++)
{
if(a[i]==b[j])
c++;
}
}
cout<<a1+b1-2*c<<endl;
return 0;
}
}