let i = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n').slice(0, -1) let s = i[0] for (let x = 2; x < i.length; x++) { if (i[x].indexOf(s) > -1) { for (let c of i[x].split(' ')) { if (c !== s) { s = c break } } } } console.log(s)