Giving wrong answer in second test case

#include
using namespace std;
int main() {
int t;
cin>>t;
int a,b;

int ans=0;
int arr[100];
int q=1;
while(q<=t)
{

 cin>>a>>b;
 
 int ans2=ans;
 int length=0;
 
 while(a>0 || b>0)
 { int r1=a%10;
 int r2=b%10;
   ans=r1^r2;
   arr[length]=ans;
	 length++;
	 a=a/10;
	 b=b/10;
 }
for(int j=length-1;j>=0;j--)
{
	cout<<arr[j];
}
cout<<endl;

q++;

}

return 0;

}

its just like taking xor of same indexes in the strings.
if values at the indexes are same then print 0 else print 1.