7584: Hexagon

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:5 通过:1

题目描述

It is preferrable to read the pdf statment.

If the world is a hexagon, I will take as many turns as possible before reaching the end.

Cuber QQ has constructed a hexagon grid with radius n. This will be better if explained in a picture. For example, this is a hexagon grid with radius 3:



He challenges you take a perfect tour over the hexagon, that is to visit each cell exactly once. Starting from any point in the grid, you can move to any adjacent cell in each step. There are six different directions you can choose from:



Of course, if you are on the boundary, you cannot move outside of the hexagon.

Let D(x,y) denote the direction from cell x to y, and sequence A denotes your route, in which Ai denotes the i-th cell you visit. For index i (1<i<|A|), if D(Ai−1,Ai)≠D(Ai,Ai+1), we say there is a turning on cell i.

Maximize the number of turning while ensuring that each cell is visited exactly once. Print your route. If there are multiple solution, print any.

输入格式

The first line of the input contains a single integer T (1≤T≤104), denoting the number of test cases.
Each of the next T cases:
The first line contains an integer n (2≤n≤500).
It is guaranteed that the sum of n doesn't exceed 2⋅104.

输出格式

For each test case, output one line contains a string with 3(n−1)n characters. The i-th character is D(Ai,Ai+1).

输入样例 复制

1
2

输出样例 复制

313456

分类标签