In test cases worth 60% of total points, it will hold:
- N, K ≤ 500.
- The sum of all L values and the sum of all R values won’t exceed 500.
Clarification of the first test case:
There are 2 reactions.
The first reaction transforms substance set {1, 2} into substance set {3}.
The second reaction transforms substance set {1, 3} into substance set {4}.
Joško initially has substances from the set {1, 2}.
Using the first reaction, Joško can obtain substance 3, after which he has substances from the set {1, 2, 3}.
After that, using the second reaction, he can also obtain substance 4.
Clarification of the second test case:
Joško initially has substances from the set {1, 4, 5}.
Using the second reaction, it is possible to obtain substance 6, after which it is possible to apply the third reaction, giving substance 2.
The first reaction is impossible to apply because Joško doesn’t have substance 3.