P27680 [洛谷] [CCC 2024 J4] Troublesome Keys
普及
题目描述

Problem Description

Alex's keyboard is quite peculiar. There are two problematic letter keys:

  • One key, when pressed, always displays a different incorrect letter. Alex refers to this key as the stupid key. Interestingly, Alex has never tried to input this incorrect letter.
  • Another key, when pressed, does not display anything. Alex calls this key the quiet key.

Alex has pressed the stupid key at least once, but he may not have pressed the quiet key.

You need to determine the problematic keys and the incorrect letter displayed when the stupid key is pressed. Fortunately, this is possible because Alex has never pressed the stupid key immediately followed by the quiet key, nor has he pressed the quiet key immediately followed by the stupid key.

Input Format

The input consists of two lines. The first line contains the $N$ keys that Alex pressed. The second line contains the letters displayed on the screen.

Output Format

The output consists of two lines.

The first line should output two letters separated by a space, representing the stupid key and the incorrect letter it displays.

The second line should output a single character: if the quiet key was pressed, output the quiet key; otherwise, output a hyphen (-).

Sample Input and Output

Sample Input #1

forloops
fxrlxxps

Sample Output #1

o x
-

Sample Input #2

forloops
fxrlxxp

Sample Output #2

o x
s

Sample Input #3

forloops
frlpz

Sample Output #3

s z
o

Notes

Sample 1 Explanation:

The letter corresponding to the stupid key is o, which displays the incorrect letter x each time it is pressed. The quiet key was not pressed.

Sample 2 Explanation:

The letter corresponding to the stupid key is o, which displays the incorrect letter x each time it is pressed. The undisplayed letter corresponding to the quiet key is s.

Sample 3 Explanation:

The letter corresponding to the stupid key is s, which displays the incorrect letter z each time it is pressed. The undisplayed letter corresponding to the quiet key is o.

Data Range:

This problem uses subtask scoring.

For all data, it is guaranteed that each line in the input contains only lowercase letters, and $1 \leq N \leq 5 \times 10^5$.

The following table shows the distribution of 15 points:

Score Description Range
$3$ The quiet key was not pressed, and the number of key presses is small. $N \leq 50$
$3$ The first problematic key pressed is the stupid key, and the number of key presses is small. $N \leq 50$
$5$ The first problematic key pressed could be either the stupid key or the quiet key, and the number of key presses is small. $N \leq 50$
$4$ The first problematic key pressed could be either the stupid key or the quiet key, and the number of key presses could be large. $N \leq 5 \times 10^5$
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
forloops fxrlxxps
样例输出
o x -