3278

Before commander the army ordered all soldiers and in double linked list are given their ID’s.

The commander does not like how the soldiers lined and decided to choose two subintervals of troops and replace them in a way that soldiers are in one subinterval to accommodate the other, and vice versa.

Input: The first line is a number of soldiers. In the second row is given ID on each of the soldiers. In the third row are given two numbers, ID for the first soldier and ID of the last soldier of the first interval. In the fourth row are given two numbers, ID for the first soldier and ID of the last soldier of the second interval.

Exit: to print the new order of soldiers (their ID’s)

Note 1: Intervals never overlap and contain at least one soldier. The entire array will contain at least two soldiers.

Note 2: Pay special attention when spaces are next to each other and when one of the intervals of the first soldier starts or ends with the last soldier.

ClassName: DLLVojska

Sample input

Sample output

10
1 2 3 4 5 6 7 8 9 10
1 5
6 10

6 7 8 9 10 1 2 3 4 5

5
10 50 40 25 1
10 10
40 1

40 25 1 50 10

9
1 2 3 4 999 5 6 7 888
999 999
888 888

1 2 3 4 888 5 6 7 999

9
1 2 3 4 5 6 7 8 9
2 3
6 8

1 6 7 8 4 5 2 3 9

15
1 50 656 1321 541 461 13 15 156 2 468 46
888 111 222
1 111
222 222

222 1 50 656 1321 541 461 13 15 156 2 468
46 888 111

9
9 8 7 6 5 4 3 2 1
9 6
4 1

4 3 2 1 5 9 8 7 6

3
100 5 200
100 100
200 200

200 5 100

7
1 2 3 44 55 66 77
2 3
55 66

1 55 66 44 2 3 77

10
1561 516 13213 6515 16523 9498 54661
161561 1516 897
516 6515
9498 54661

1561 9498 54661 16523 516 13213 6515
161561 1516 897

2
20 101
20 20
101 101

101 20