Running with Obstacles

A sportsman starts from point x start = 0 and runs to point with coordinate x finish = m (on a straight line). Also, the sportsman can jump — to jump, he should first take a run of length of not less than s meters (in this case for these s meters his path should have no obstacles), and after that he can jump over a length of not more than d meters. Running and jumping is permitted only in the direction from left to right. He can start andfinish a jump only at the points with integer coordinates in which there are no obstacles. To overcome some obstacle, it is necessary to land at a point which is strictly to the right of this obstacle.

On the way of an athlete are n obstacles at coordinates x 1, x 2, …, x n. He cannot go over the obstacles, he can only jump over them. Your task is to determine whether the athlete will be able to get to the finish point.

Input

The first line of the input containsd four integers nms and d (1 ≤ n ≤ 200 000, 2 ≤ m ≤ 109, 1 ≤ s, d ≤ 109) — the number of obstacles on the runner’s way, the coordinate of the finishing point, the length of running before the jump and the maximum length of the jump, correspondingly.

The second line contains a sequence of n integers a 1, a 2, …, a n (1 ≤ a i ≤ m - 1) — the coordinates of the obstacles. It is guaranteed that the starting and finishing point have no obstacles, also no point can have more than one obstacle, The coordinates of the obstacles are given in an arbitrary order.

Output

If the runner cannot reach the finishing point, print in the first line of the output “IMPOSSIBLE” (without the quotes).

If the athlete can get from start to finish, print any way to do this in the following format:

  • print a line of form “RUN X>” (where “X” should be a positive integer), if the athlete should run for “X” more meters;
  • print a line of form “JUMP Y” (where “Y” should be a positive integer), if the sportsman starts a jump and should remain in air for “Y” more meters.

All commands “RUN” and “JUMP” should strictly alternate, starting with “RUN”, besides, they should be printed chronologically. It is not allowed to jump over the finishing point but it is allowed to land there after a jump. The athlete should stop as soon as he reaches finish.Examplesinput

3 10 1 3
3 4 7

output

RUN 2
JUMP 3
RUN 1
JUMP 2
RUN 2

input

2 9 2 3
6 4

output

IMPOSSIBLE

Solution:

#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),a.end()
#define pw(x) (1LL<<(x))

using namespace std;

typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef pair<int, int> pi;

const int inf = (int)1.01e9;
const dbl eps = 1e-9;

/* --- main part --- */

#define TASK "1"

const int N = 1000111;

int n, m, s, d;

int a[N];
int pr[N];

int main()
{
#ifdef home
assert(freopen(TASK".in", "r", stdin));
assert(freopen(TASK".out", "w", stdout));
#endif
ios::sync_with_stdio(false);
cin >> n >> m >> s >> d;
for (int i = 0; i < n; i++) cin >> a[i];
a[n++] = -1;
sort(a, a + n);
int gr = 0;
int fr = -1;

for (int i = 0; i < n; i++) {
        if (a[i] >= gr) {
puts("IMPOSSIBLE");
return 0;
}
pr[i] = fr;
if (i + 1 == n) break;
if (a[i + 1] - a[i] - 2 >= s) {
gr = a[i + 1] - 1 + d;
fr = i;
}
}
vector<pair<string, int> > out;
if (m > a[n - 1] + 1) out.pb(mp("RUN", m - a[n - 1] - 1));
int x = n - 1;
while (x > 0) {
int jp = a[pr[x] + 1] - 1;
out.pb(mp("JUMP", a[x] + 1 - jp));
out.pb(mp("RUN", jp - (a[pr[x]] + 1)));
x = pr[x];
}
reverse(out.begin(), out.end());
for (int i = 0; i < out.size(); i++) {  
        cout << out[i].F << " " << out[i].S << endl;
    }

    #ifdef home
        eprintf("time = %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
    return 0;
}