QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 256 MB Points totaux : 100

#556. Knight

Statistiques

JYY, a knight of the JSOI kingdom, has returned home after defeating an evil dragon. King JS intends to marry his princess to JYY, but the young and brave JYY must first pass the princess's test.

JYY enters an $N \times M$ underground maze, starting at the top-left corner with coordinates $(1, 1)$. The exit of the maze is at the bottom-right corner with coordinates $(N, M)$.

As a true knight, JYY can only move in the maze according to the rules of a knight in international chess (an "L" shape). Furthermore, he must never visit the same cell twice, and he cannot move outside the boundaries of the maze.

To pass the princess's test, he must reach the exit of the maze in exactly $T$ steps. Please help him plan his route.

Input

The input consists of a single line containing three positive integers $N$, $M$, and $T$, describing the size of the maze and the required number of steps.

Output

Output exactly $T$ lines, each containing two integers $X_i$ and $Y_i$, representing the position reached at the $i$-th step. You may output any valid action plan. The input is guaranteed to have a solution.

Examples

Input 1

8 8 16

Output 1

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

Constraints

Test Case $N$ $M$ $T$
1 $N = 8$ $M = 8$ $T = 48$
2 $N = 9$ $M = 8$ $T = 17$
3 $N = 9$ $M = 10$ $T = 63$
4 $N = 8$ $M = 12$ $T = 20$
5 $N = 16$ $M = 16$ $T = 192$
6 $N = 500$ $M = 499$ $T = 187125$
7 $N = 500$ $M = 500$ $T = 187500$
8 $N = 500$ $M = 500$ $T = 125000$
9 $N = 499$ $M = 499$ $T = 1998$
10 $N = 499$ $M = 500$ $T = 157873$

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.