This page is still under construction.

Parts of this page are still being built. What you see may change.

String Decompression

Interview

Time limit1sMemory limit1024 MB

Summary
Given patterns mapped to uppercase letters and a compressed string, expand it and print characters S through E of the original string.
Level

Medium6 of 10

Topics
String, Implementation, Recursion, Simulation
Solved
No attempts yet

Problem

There is a program called SPC (String Pattern Compressor) that compresses a specific lowercase string pattern into a single uppercase letter.

For example, when compression is done as follows, “aabbaaac\text{aabbaaac}” is compressed into “ABAC\text{ABAC}”.

lowercase string patternuppercase
aa\text{aa}A\text{A}
bba\text{bba}B\text{B}
c\text{c}C\text{C}

Given a compression program and a compressed string, write a program that outputs part of the string before compression.

Input

The first line gives the number of compression methods NN. (1≤N≤261 \le N \le 26)

From the second line, NN lines follow, each containing a lowercase string pattern and the corresponding uppercase letter, separated by a space. The length of each lowercase string pattern does not exceed 1 0001\,000, and the same uppercase letter is not given more than once.

The N+1N+1-th line gives the compressed string. The length of the compressed string does not exceed 1 0001\,000.

The last line gives two integers SS and EE. (1≤S≤E≤1 \le S \le E \le (length of the string before compression))

Output

Output the SS-th character through the EE-th character of the string before compression.

Examples3

  1. Example 1

    Input
    3
    aa A
    bba B
    c C
    ABAC
    4 6
    
    Expected output
    baa
    
  2. Example 2

    Input
    5
    abcde A
    abcde B
    abcde C
    abcde D
    abcde E
    ABCDE
    1 25
    
    Expected output
    abcdeabcdeabcdeabcdeabcde
    
  3. Example 3

    Input
    4
    e E
    f F
    g G
    h H
    EEEFEEE
    4 5
    
    Expected output
    fe