13692 - Aftermath's Ideology   

Description

Katex

Given a string \(s\) that consists of only lowercase Latin characters, there are \(Q\) operations to apply on this string.

There are 3 types of operations, with the following 3 forms:

  • \(1\) \(A\) \(B\)
  • \(2\) \(id\) \(C\)
  • \(3\) \(id_a\) \(id_b\)

For operation of type \(1\), you have to turn every \(A\) in the given string to \(B\).

For operation of type \(2\), you have to set the \(id\)th character to \(C\).

For operation of type \(3\), you have to swap the \(id_a\)th character and the \(id_b\)th character.

After the \(Q\) operations, you should print the resulting string in one line(remember to print a new line character).

Input

Katex

The first line contains a string s, which consists of only lowercase Latin characters.

The second line contains an integer \(Q\).

The next \(Q\) lines, each contains an operation

    Constraints

  • \(1 \le |s| \le 10^6\)
  • \(1 \le Q \le 10^5\)
  • \(0 \le id, id_a, id_b \le |s|-1\)
  • \(A, B, C \in \{a \dots z\}\)

Output

Katex

Print your answer in one line and end with a newline character.

Sample Input  Download

Sample Output  Download

Tags

LoseLightLight



Discuss