#P9951. Cow Reversal

    ID: 23095 Type: Default 1000ms 256MiB

Cow Reversal

Cow Reversal

Farmer John has N cows (\(1 \le N \le 100\)) lined up from left to right with initial labels \(1, 2, \ldots, N\). He devises a new morning exercise routine which consists of repeatedly performing the following two steps for \(K\) (\(1 \le K \le 10^9\)) iterations:

  1. Reverse the order of the cows in positions \(A_1\) to \(A_2\) (with \(1 \le A_1 < A_2 \le N\)).
  2. Then reverse the order of the cows in positions \(B_1\) to \(B_2\) (with \(1 \le B_1 < B_2 \le N\)).

After the \(K\) iterations, output the final order of the cows from left to right. Note that positions are 1-indexed.

inputFormat

The input consists of three lines:

  • The first line contains two integers \(N\) and \(K\): the number of cows and the number of iterations.
  • The second line contains two integers \(A_1\) and \(A_2\), representing the range for the first reversal.
  • The third line contains two integers \(B_1\) and \(B_2\), representing the range for the second reversal.

outputFormat

Output \(N\) lines, where the \(i\)-th line contains the label of the cow at the \(i\)-th position after performing all \(K\) iterations.

sample

7 2
2 5
3 7
1

2 4 3 5 7 6

</p>