#P10293. Detecting the Faulty Keyboard Key

    ID: 12294 Type: Default 1000ms 256MiB

Detecting the Faulty Keyboard Key

Detecting the Faulty Keyboard Key

Alex has a strange keyboard with two problematic keys. One key, which Alex calls the foolish key, when pressed always outputs a different, erroneous letter. Interestingly, Alex has never intentionally pressed that erroneous letter. The other key, called the quiet key, produces no output when pressed.

It is known that Alex pressed the foolish key at least once, but may not have pressed the quiet key. Moreover, Alex never pressed the foolish key immediately before or after the quiet key.

Your task is to determine the faulty key (i.e. the key that was pressed which should have produced its own letter but instead produced an error) and the wrong letter that is displayed when it is pressed.

The input consists of two lines:

  1. The first line is the intended sequence of key presses (the characters Alex meant to type).
  2. The second line is the actual output from the keyboard.

For each press of the foolish key, instead of showing its intended letter, the keyboard shows a wrong letter. The following relation holds for the foolish key: if the intended letter is \( c_f \) and the erroneous output letter is \( e \), then \[ \text{count}_{\text{intended}}(c_f) = \text{count}_{\text{output}}(e) > 0 \] and \( e \) does not occur anywhere in the intended sequence. Note that other non-problematic keys print their intended letters, and the quiet key (if pressed) produces no output at all.

It is guaranteed that the input is generated so that the foolish key can be uniquely determined.

inputFormat

The input contains two lines:

  • The first line is a non-empty string representing the intended sequence of characters.
  • The second line is a non-empty string representing the actual output produced by the keyboard.

Both strings consist of visible characters. It is guaranteed that the foolish key was pressed at least once.

outputFormat

Output two characters separated by a space:

  • The first character is the key that is faulty (the intended character that was replaced).
  • The second character is the erroneous letter that was displayed.

sample

abcde
aXcde
b X