Թաքցված խնդիր
|Այս խնդիրը թաքցված է խմբագրական խրհրդի անդամի կողմից քանի որ կամ այն ոչ ճիշտ լեզվով է գրված,|կամ թեստային տվյալներն են սխալ, կամ խնդրի ձևակերպումը պարզ չէ։|

ACM_0036 - ENCRYPTION

   Alice thinks it is very inconvenient to have to keep one of her keys in a public–private key pair secret. Therefore she invented a public–public key encryption scheme called the Really Secure Algorithm (RSA). The algorithm works as follows:

   A word is a sequence of between one and ten capital letters (A–Z). A sentence is a sequence of words, separated by spaces. The first public key is a sentence in which each word is used at most once. The second public key is a sentence formed by applying a permutation σ to the words in the first public key. The plaintext (the unencrypted message) is a sentence that has exactly as many words as the public keys. (Unlike for the public keys, these words are not necessarily unique.) The ciphertext (the encrypted message) is the sentence formed by applying the permutation σ to the plaintext.

   Given the two public keys and the ciphertext, recover the plaintext.

Input

   On the first line one positive number: the number of test cases, at most 100. After that per test case:

  • one line with an integer n (1 n 1 000): the number of words in each sentence.
  • one line with a sentence: the first public key.
  • one line with a sentence: the second public key.
  • one line with a sentence: the ciphertext.

   All words consist of at least 1 and at most 10 uppercase letters.

Output

   Per test case:

  • one line with a sentence: the plaintext.

Examples

stdin

stdout

1

2

4

A B C D

D A B C

C B A P

3

SECURITY THROUGH OBSCURITY

OBSCURITY THROUGH SECURITY

TOMORROW ATTACK WE

B A P C

WE ATTACK TOMORROW



Ավելացրեց.Հրանտ Հովհաննիսյան
Ամսաթիվ.2013-12-21
Ժամանակի սահմանափակումը.1s
Ծրագրի տեքստի սահմանափակումը.50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Լեզուներ.Բոլորը բացի ASM32 ASM64 GAWK CLPS CLOJURE D ERL FSHARP FORTRAN GOSU HASK ICON ICK NEM NIM OBJC-CLANG PICO PIKE PYPY PYPY3 PY_NBC RUST SCM guile CHICKEN SED TCL WHITESPACE
Աղբյուրը.Benelux Preliminary (BAPC) 2013.E

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.