why getting wrong ans plz tell me what is wrong in my logic
#include<bits/stdc++.h>
using namespace std;
long long int calculateMex(unordered_set Set)
{
long long int Mex = 0;
while (Set.find(Mex) != Set.end())
Mex++;
return (Mex);
}
long long int calculateGrundy(long long int n)
{
if (n==1)
return (0);
unordered_set<long long int> Set;
long long int i=1;
while(n%i==0&&i!=n){
Set.insert(calculateGrundy(i));
i+=1;
}
return (calculateMex(Set));
}
int main(){
int t;
cin>>t;
while(t–){
long long int n;
long long int m[1000];
cin>>n;
for(long long int i=0;i<n;i++){
cin>>m[i];
}
long long int sum=calculateGrundy(m[0]);
for(long long int i=1;i<n;i++){
sum^=calculateGrundy(m[i]);
}
if(sum!=0){
cout<<“1”<<"\n";
}
else{
cout<<"2"<<"\n";
}
}
return 0;
}