#P5981. [PA 2019] Iloczyny Fibonacciego
[PA 2019] Iloczyny Fibonacciego
Description
Define the Fibonacci sequence as .
For any positive integer , we can always write in a unique Fibonacci representation that satisfies:
- .
- For any , we have or ; and for , we have .
- For any , we have .
For example, , , , .
Given two positive integers and in Fibonacci representation, output the Fibonacci representation of .
Input Format
The first line contains a positive integer , the number of test cases.
Each test case contains two lines, describing the Fibonacci representations of and . Each line starts with a positive integer , followed by non-negative integers .
Output Format
For each test case, output one line. Follow the input format to output the Fibonacci representation of .
2
3 1 0 1
4 0 0 0 1
2 0 1
1 1
6 0 1 0 1 0 1
2 0 1
Hint
For of the testdata, , and the input guarantees that the sum of all does not exceed .
Translated by ChatGPT 5
京公网安备 11011102002149号