# 45. 英文输入法

45

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});
rl.on('line', function(sentence) {
    rl.on('line', function(prefix) {
        sentence = sentence.replace(/[^\w\s]/g, ' ');
        const wordSet = new Set(sentence.split(' '));
        let ans = '';
        let arr = [...wordSet].sort();
        for(const word of arr) {
            if (word.startsWith(prefix)) {
                ans += word + ' ';
            }
        }
        if (ans) {
            console.log(ans);
        } else {
            console.log(prefix);
        }
    });
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23