Universal Cup Judging System

Universal Cup

Time Limit: 1.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

SSerxhs 有两个骰子,分别有 $n$ 个面和 $m$ 个面,面上的数字分别为 $1, 2, 3, \dots, n$ 和 $1, 2, 3, \dots, m$。他对比这两个骰子点数之和的概率分布很感兴趣。请帮他找到另一对不同的骰子,使得它们点数之和的概率分布与原先的骰子相同。

由于制造面数过多的骰子很困难,你应该使两个骰子的面数之和最小。

假设每个骰子的每个面被掷到的概率相等。

当且仅当其中一对骰子中的某个骰子与另一对中的任何一个骰子不同时,这两对骰子被视为不同。

当且仅当存在一个数字 $x$,使得两个骰子上 $x$ 出现的次数不同时,这两个骰子被视为不同。

两个随机变量 $X$ 和 $Y$ 服从相同的概率分布,当且仅当 $\forall k, P(X = k) = P(Y = k)$。

输入格式

每个测试点包含多个测试用例。第一行包含一个整数 $t$ ($1 \le t \le 4000$),表示测试用例的数量。

对于每个测试用例,唯一的一行包含两个整数 $n$ 和 $m$ ($1 \le n, m \le 10^6$),表示两个骰子的面数。

保证所有测试用例中 $\max\{n, m\}$ 的总和不超过 $10^6$。

输出格式

对于每个测试用例,输出两行,包含若干整数来描述这两个骰子。

对于第 $i$ 行,第一个整数 $f_i$ 表示第 $i$ 个骰子的面数。该行剩余的 $f_i$ 个整数 $a_1, a_2, \dots, a_{f_i}$ ($1 \le a_j < n + m$) 表示对应骰子每个面上的数字。骰子面上的数字可以重复。

如果存在多种解,你可以输出其中任意一种。

特别地,如果没有解,则在两行中均输出 “0”。

保证所有测试用例中 $f_i$ 的总和不超过 $3 \cdot 10^6$。

样例中添加了额外的空行以分隔不同的测试用例。你可以自由选择是否在输出中打印这些空行。

样例

样例输入 1

3
2 8
1 9
2 9

样例输出 1

4 1 2 3 4
4 1 2 5 6
3 1 2 3
3 1 4 7
6 1 2 4 5 7 8
3 1 2 3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.