9102 - Reorder   

Description

Given a positive integer sequence a1, a2... an, whose elements are initially put in a queue Q in the given order. Determine that if it is possible, using a stack S and two operations:

(1) pop the first element in Q and push it into S, and

(2) pop the top element in S,

to obtain the other given sequence b1, b2bn, where bi represents the i-th element popped from S. Note that “pop the first element in Q and push it into S” is considered as a single operation.

Input

The first line of the input contains an integer indicating the total number of test cases to follow. Each test case is composed of three lines. The first line contains a single integer n (n ≤ 1000), and each of the next two lines contains n integers, which respectively represents a1, a2an, and b1, b2bn. The numbers in the sequence are distinct integers from 1 to n.

Output

For each test case, print the sequence number “Case i:” and then “Yes” or “No” following a single space character to indicate if it is possible or not, in a line.

Sample Input  Download

Sample Output  Download

Tags




Discuss