#P8156. 「PMOI-5」奇怪的方程
「PMOI-5」奇怪的方程
Problem Description
Given an integer , there are unknowns .
You are given equations. There are two types of equations, and each type has equations.
The -th equation of the first type is .
The -th equation of the second type is .
But this is too easy. You are also given constraints, and you need to ensure .
Please output any valid solution. If there is no solution, output No Solution. Otherwise, first output OK, then output the solution, where for all , and is an integer.
Input Format
This problem contains multiple test cases.
The first line contains an integer , the number of test cases.
For each test case:
The first line contains two integers and .
The second line contains integers, where the -th integer represents .
The third line contains integers, where the -th integer represents .
Then follow lines, each with two integers, representing .
Output Format
For each test case:
The first line contains a string indicating whether a solution exists.
If a solution exists, the next line contains integers, where the -th integer represents .
1
5 17
8 10 12 8 45
16 17 18 18 14
3 2
4 3
6 3
7 2
8 2
10 2
11 2
12 4
13 2
14 3
18 3
19 2
21 9
22 9
23 9
24 9
25 9
OK
1 1 2 3 1 3 2 2 1 2 2 4 2 3 1 1 1 3 2 1 9 9 9 9 9
Hint
This problem uses bundled testdata.
- Subtask 1 (1 pts): .
- Subtask 2 (4 pts): .
- Subtask 3 (10 pts): .
- Subtask 4 (15 pts): .
- Subtask 5 (20 pts): .
- Subtask 6 (10 pts): .
- Subtask 7 (20 pts): , .
- Subtask 8 (20 pts): no special constraints.
For of the testdata, , , , , , , . It is guaranteed that all are pairwise distinct.
Translated by ChatGPT 5