#include #include int main() { int N; scanf("%d", &N); char strings[N][101]; // Array to store the strings for (int i = 0; i < N; i++) { scanf("%s", strings[i]); } int count = 0; // Variable to count the number of distinct concatenated strings // Iterate over each pair of adjacent strings and check if the concatenated string is distinct for (int i = 1; i < N; i++) { char concatenated[201]; // Array to store the concatenated string strcpy(concatenated, strings[i]); strcat(concatenated, strings[i-1]); // Check if the concatenated string is distinct from the previous concatenated string int distinct = 1; for (int k = 0; k < i; k++) { if (strcmp(concatenated, strings[k]) == 0) { distinct = 0; break; } } // If the concatenated string is distinct, increment the count if (distinct) { count++; } // Concatenate the strings in the reverse order and check if it's distinct strcpy(concatenated, strings[i-1]); strcat(concatenated, strings[i]); distinct = 1; for (int k = 0; k < i; k++) { if (strcmp(concatenated, strings[k]) == 0) { distinct = 0; break; } } // If the concatenated string is distinct, increment the count if (distinct) { count++; } } printf("%d\n", count); return 0; }