#include <iostream>
#include <vector>
#include <string>
using namespace std;
/*
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
//** LUKUVÄLIEN MÄÄRÄ
int n;
scanf("%d", &n);
//**
return 0;
}
*/
bool onkoHarmoninen(string s1, string s2) {
if (s1 == s2) return false;
if (s1.length() == s2.length()) {
bool ehto_1 = false;
bool ehto_2 = false;
for (int i = 0; i < s1.length(); i++) {
for (int k = 0; k < s2.length(); k++) {
if (i == k) continue;
if (ehto_1 && ehto_2) {
return true;
}
//Ehto1
if (s1[i] == s1[k]) {
if (s2[i] == s2[k]) {
ehto_1 = true;
continue;
}
}
//Ehto 2
if (s1[i] != s1[k]) {
if (s2[i] != s2[k]) {
ehto_2 = true;
continue;
}
}
}
}
}
return false;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, harmoniset = 0;
vector<string> v, harmonisetParit;
string temp;
scanf("%d", &n);
for (int i = 0; i <= n; i++) {
getline(cin, temp);
v.push_back(temp);
}
for (string s1 : v) {
for (string s2 : v) {
if (find(harmonisetParit.begin(), harmonisetParit.end(), s2) != harmonisetParit.end()) continue;
if (onkoHarmoninen(s1, s2)) {
harmoniset++;
harmonisetParit.push_back(s1);
cout << "(" << s1 << ", " << s2 << ")\n";
}
}
}
printf("%d", harmoniset);
return 0;
}