# 2. 数据单元的变量替换
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.on('line', (line) => {
const tmp2 = line.split(',');
const cells = {};
for(let i=0; i<tmp2.length; i++) {
cells[String.fromCharCode(65+i)] = tmp2[i];
}
let res = '';
for(let cell of tmp2) {
let res1 = cell.indexOf('<');
let res2 = cell.indexOf('>');
if (res1 == -1 && res2 == -1) {
res += cell + ','
} else if (res1 == -1 || res2 == -1 || res1 > res2 || res2 - res1 !== 2) {
console.log(-1);
return;
} else {
res += cell.substring(0, res1) + cells[cell.charAt(res1 + 1)] + cell.substring(res2 + 1) + ',';
}
}
console.log(res.substring(0, res.length - 1));
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29