This page is still under construction.

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

Bug Catcher

Time limit1sMemory limit128 MB

Summary
For each code line, repeatedly remove the first occurrence of a given bug string until no occurrence remains, then print the result.
Level

Medium6 of 10

Topics
Stack, String, Implementation
Solved
No attempts yet

Problem

Not every bug is an insect. Some bugs are a developer's nightmare — the kind people mean when they say "a bug was found in the program you wrote." And as you know, no matter how many you remove, more keep appearing.

Recently a rather handy tool called "Bug Catcher" appeared. It finds and removes every bug in your source code. Your job is to implement this "Bug Catcher": given the source code, keep deleting the string that represents a bug until none remain.

Input

The input consists of several test cases and continues until the end of the file.

Each test case begins with one line containing an integer TT (0≤T≤100 0000 \le T \le 100\,000), a single space, and a string BB that represents a bug. The next TT lines each contain one line of source code from which bugs must be removed.

Each source-code line has length between 00 and 2 000 0002\,000\,000 characters. The bug string BB consists of 11 to 10001000 uppercase English letters. Matching is case-sensitive: only substrings exactly equal to BB count as bugs.

Output

For each source-code line, repeatedly delete the first occurrence of BB until BB no longer appears, and print the resulting line.

No bug may remain in the output. Every other character, including whitespace, must be printed exactly as it appeared in the input.

Examples8

  1. Example 1

    Input
    7 BUG
    print "No bugs here..."
    
    void hello() {
    BUGBUG
      printfBUG("Hello, world!\n");
    }
    
    1 ERR
    wriERRERRtelERRn("Hello E-R-R");
    
    Expected output
    print "No bugs here..."
    
    void hello() {
    
      printf("Hello, world!\n");
    }
    
    writeln("Hello E-R-R");
  2. Example 2

    Input
    0 X
    2 A
    BANANA
    AAAA
    
    Expected output
    BNN
    
  3. Example 3

    Input
    2 AA
    AAAAA
    AAAA
    
    Expected output
    A
    
  4. Example 4

    Input
    1 BUG
    BUBUGG
    
    Expected output
  5. Example 5

    Input
    1 ABA
    ABABABA
    
    Expected output
    B
  6. Example 6

    Input
    1 XYZ
    hello, world! no bugs here.
    
    Expected output
    hello, world! no bugs here.
  7. Example 7

    Input
    1 BUG
    BUGhelloBUGworldBUG
    
    Expected output
    helloworld
  8. Example 8

    Input
    1 BUG
       BUG spaces   
    
    Expected output
        spaces