Help me in solving TEAMNAME problem

My issue

how to approach it give me some hints

My code

#include <iostream>

#include<bits/stdc++.h>

using namespace std;

bool isIn(vector<string> &arr, string s){
    
    if(find(arr.begin(), arr.end(), s)!=arr.end()){
        return true;
    }
    
    return false;
}

int main() {
    // your code goes here
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<string>arr;
        
        for (int i = 0; i < n; i++) {
            string temp;
            cin >> temp;
            arr.push_back(temp);
        }

        
        set<string> ans;
        
        for(int i=0; i<n; i++){
           for(int j=0; j<n; j++){
               if(i!=j){
                    string temp = arr[j];
                    string temp2 = arr[i];
                    
                    swap(temp[0], temp2[0]);
                    
                    if(!isIn(arr, temp) && !isIn(arr, temp2)){

                        ans.insert(temp);
                        ans.insert(temp2);
                    }
                   
               }
           }
       }
       cout<<ans.size()<<endl;
        
    }

    return 0;
}

Problem Link: Team Name Practice Coding Problem