Factoradic Numbers
In the factoradic number system, numbers are written similarly as in the standard decimal system, but the positions of digits have different meanings: The first (from the right) digit is always 0 or 1, meaning 0 × 1! or 1 × 1!, respectively. The second digit may be 0, 1 or 2, meaning 0 × 2!, 1 × 2! or 2 × 2!, and so on: the digit c_i at i-th position belongs to the set {0, 1, ..., i} and has value c_i × i!.
For example, the factoradic number 1310 is 1 × 4! + 3 × 3! + 1 × 2! + 0 × 1! = 44 in decimal system. It can be easily proven that every number has a unique factoradic representation.
Given two nonnegative numbers in factoradic system, output their product in the same system. No trailing zeros are allowed, only the number zero is written simply as 0.
Входные даные
Первая строка содержит количество тестов t. Далее следуют сами тесты.
A test case contains four lines: the first two of them describe the first factor, the last two - the other factor. Each factor is described by its length d (1 ≤ d ≤ 2000) on the first line, and d space-separated integers denoting its digits on the second line. The digits follow the format described in the statement.
Выходные даные
For each test case, your program should write a single line containing the factoradic representation of the product - output only its digits, from left to right, space-separated.