P9951 [USACO20FEB] Swapity Swap B
Description
Farmer John’s $N$ cows ($1 \le N \le 100$) are standing in a line. For each $1 \le i \le N$, the ID of the $i$-th cow from left to right is $i$.
Farmer John has come up with a new morning exercise plan. He has them repeat the following two-step process $K$ times ($1 \le K \le 10^9$):
1. Reverse the order of the cows currently in positions $A_1 \ldots A_2$ from left to right ($1 \le A1 < A2 \le N$).
2. Then, reverse the order of the cows currently in positions $B_1 \ldots B_2$ from left to right ($1 \le B_1 < B_2 \le N$).
After the cows repeat this process $K$ times, output the ID of the $i$-th cow from left to right for each $1 \le i \le N$.
Input Format
The first line contains $N$ and $K$. The second line contains $A_1$ and $A_2$, and the third line contains $B_1$ and $B_2$.
Output Format
On the $i$-th line, output the ID of the $i$-th cow from left to right after the exercise ends.
Explanation/Hint
### Sample Explanation 1
Initially, the cows’ order from left to right is $[1,2,3,4,5,6,7]$. After the first step of this process, the order becomes $[1,5,4,3,2,6,7]$. After the second step of this process, the order becomes $[1,5,7,6,2,3,4]$. Repeating these two steps one more time produces the sample output.
### Test Point Properties
- Test points $2-3$ satisfy $K \le 100$.
- Test points $4-13$ have no additional constraints.
Translated by ChatGPT 5