问题 K: Werewolves

内存限制:512 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:0

题目描述

There are n players sitting in a row and m kinds of identity cards. The players are numbered from 1∼�1n. The number is public, which means everyone knows the number of each other.

A moderator will give each player an identity card. However, the receiver isn't allowed to view their identity.

Everybody will shut their eyes. Then the moderator will call out each player in turn. All other players' identity cards, disordered, will be shown to that player. The player should guess their identity and shut their eyes afterward. All other players will remain their eyes closed during the procedure.

The players have enough time to discuss before the game starts and want to make sure that at least ⌊��⌋mn of the guesses are correct. Please help them make a strategy.

输入格式

The first line contains an integer T, denoting the number of testcases.

Each testcase contains two integers �,�n,m, separated by a space.

The input guarantees that 2≤�≤�,��≤2.1×106,∑��≤1.4×1072mn,mn2.1×106,mn1.4×107.

输出格式

For each testcase, output n lines, line p denoting the strategy of player p.

Denote a sequence s valid if and only if s is a non-descending sequence of length �−1n1 and contains integers in [1,�][1,m]. Denote the count of valid sequence c, then output c integers between 11 and m, the k-th integer representing what the player will guess when the multiset of identity cards seen is equal to the multiset of the k-th valid sequence sorted in lexicographical order.

输入样例 复制

1
2 2

输出样例 复制

1 2
2 1