const input = require('fs').readFileSync('/dev/stdin', 'utf8').replace(/^w+|\n/, '') console.log(input.includes('w') && --[...new Set([...input])].length ? input.match(new RegExp(`[^w]+w{${Math.max(...input.match(/w+/g).map(v => v.length))}}`, 'g')).map(v => v.replace(/w/g, '')).join('\n') : '');