function Main(input) { const s = input.trim().split("\n"); const n = parseInt(s.shift()); let d = new Set([]); for (let i = 0; i < n; ++i) { for (let j = 0; j < n; ++j) { if (i == j) continue; d.add(s[i] + s[j]); } } console.log(d.size); } Main(require("fs").readFileSync("/dev/stdin", "utf8"));