#C9122. Replace All Occurrences in a Document

    ID: 53181 Type: Default 1000ms 256MiB

Replace All Occurrences in a Document

Replace All Occurrences in a Document

Given a document (a string), and two other strings S and T, your task is to replace all occurrences of S in the document with T.

Formally, if the document is denoted as $D$, you need to produce a new string $R$ such that every occurrence of $S$ in $D$ is replaced with $T$. For example, given $D = \texttt{hello world}$, $S = \texttt{world}$ and $T = \texttt{earth}$, the result will be hello earth.

Please note that if S does not occur in the document, the document should remain unchanged.

inputFormat

The input is given from standard input (stdin) and consists of three lines:

  1. The first line contains the document string.
  2. The second line contains the string S (the substring to be replaced).
  3. The third line contains the string T (the substring to replace with).

Note: The document or any of the strings may be empty.

outputFormat

Output to standard output (stdout) a single line containing the modified document after replacing all occurrences of S with T.

## sample
hello world
world
earth
hello earth