Under construction

Still being built. Things may change

Speed Typing

Interview

Memory limit1024 MB

Summary
Given strings I and P, check whether I is a subsequence of P and report how many letters to delete from P, or IMPOSSIBLE if it is not.
Level

Easy3 of 10

Topics
String, Two pointers, Greedy
Solved
No attempts yet

Problem

Barbara is a fast typist. To check her typing speed, she takes a speed test in which she must type a string II.

While she types, she may press a wrong key. She does not want to lose time fixing mistakes, so she keeps typing with the errors until the test ends. When the test ends, she has produced a string PP.

Find how many extra letters must be deleted from PP to get II. Deleting letters from PP may not be enough to get II, because she may have made a mistake that cannot be undone by deletion. She may also have skipped some letters.

Input

The first line contains the number of test cases TT. Each test case has two lines. The first line is the string II that the test gave her. The second line is the string PP that Barbara typed.

Output

For each test case, print one line in the form Case #x: y. Here xx is the test case number starting from 1, and yy is the number of extra letters to delete from PP to get II. If II cannot be obtained by deleting letters from PP, print IMPOSSIBLE as yy.

Constraints

1≤T≤1001≤T≤100.

Both strings contain only letters from a-z and A-Z.

1≤∣I∣,∣P∣≤1051≤|I|,|P|≤10^5.

Examples2

  1. Example 1

    Input
    2
    aaaa
    aaaaa
    bbbbb
    bbbbc
    
    Expected output
    Case #1: 1
    Case #2: IMPOSSIBLE
    
  2. Example 2

    Input
    2
    Ilovecoding
    IIllovecoding
    KickstartIsFun
    kkickstartiisfun
    
    Expected output
    Case #1: 2
    Case #2: IMPOSSIBLE