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