QOJ.ac

QOJ

時間限制: 4 s 記憶體限制: 512 MB 總分: 100

#4119. Travel Plan

统计

In a country with $N$ cities, Alice wishes to start a legendary journey. She wants to start from one city, move to an adjacent city each time, and visit exactly $K$ cities without repeating any city along the way, finally ending at another city. Note that the starting city and the ending city are also considered visited cities, meaning all cities visited, including the start and end, must be distinct.

Now, Alice wants to know which pairs of cities $(u, v)$ can serve as the starting and ending cities of the journey.

Input

The first line contains a single integer $T$, representing the number of test cases.

For each test case, the first line contains three integers $N$, $M$, and $K$, representing the number of cities, the number of adjacency relationships between cities, and the number of cities that must be visited during the journey, respectively.

Following this are $M$ lines, each containing two integers $u$ and $v$, indicating that city $u$ and city $v$ are adjacent.

Output

For each test case, output $N$ lines, each containing $N$ characters.

The $j$-th character of the $i$-th line should be "Y" or "N", indicating whether there exists a valid journey starting at city $i$ and ending at city $j$.

Constraints

  • For 5% of the data, $K \le 2$.
  • For 15% of the data, $K \le 3$.
  • For 35% of the data, $K \le 4$.
  • For 55% of the data, $K \le 5$.
  • For 75% of the data, $K \le 6$.
  • For 100% of the data, $N \le 1000$, $M \le 5000$, $2 \le K \le 7$, and $T \times \lfloor K/2 \rfloor \le 60$.

Examples

Input 1

1
5 6 4
1 2
2 3
3 5
1 4
4 5
2 5

Output 1

NYYYY
YNNYY
YNNYN
YYYNY
YYNYN

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.