const reader = require("readline").createInterface({ input: process.stdin, output: process.stdout }); let lines = []; reader.on("line", line => { lines.push(line); }); reader.on("close", () => { const check1 = lines.filter(() => { return lines[0] === lines[1] }) const check2 = lines.filter(() => { return lines[1] === lines[2] }) if (check1 && check2) { console.log(lines[0]) } else if (check1) { console.log(lines[0]) } else { console.log(lines[1]) } });