Count new pairs of strings that can be obtained by swapping first characters of pairs of strings from given array

  #include using namespace std;  void countStringPairs(string a[], int n){          int ans = 0;              for (int i = 0; i < n; i++) {        for (int j = i + 1; j < n; j++) {                                      string p = a[i], q = a[j];                          if (p[0] != q[0]) {                  swap(p[0], q[0]);                int flag1 = 0;                int flag2 = 0;                                                  for (int k = 0; k < n; k++) {                      if (a[k] == p) {                        flag1 = 1;                    }                    if (a[k] == q) {                        flag2 = 1;                    }                }                                                  if (flag1 == 0 && flag2 == 0) {                                                              ans = ans + 1;                }            }        }    }          cout