#include <iostream>
#include <set>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <vector>
#include <queue>
using namespace std;
#define INF 999999
#define pb push_back
#define mp make_pair
typedef pair<int, int> pi;
const int MAXV = 50005, MAXE = 10500000, oo = (1 << 25);
int E, last[MAXV], nextssss[MAXE], adj[MAXE], level[MAXV], now[MAXV], Q[MAXV], source, sink;
int cap[MAXE], flow[MAXE];
void add_edge (int u, int v, int c)
{
cap[E] = c, flow[E] = 0, adj[E] = v, nextssss[E] = last[u], last[u] = E++;
cap[E] =0, flow[E] = 0, adj[E] = u, nextssss[E] = last[v], last[v] = E++;
}
#define RES(e) (cap[e] - flow[e])
bool bfs (int s, int t)
{
memset(level, -1, sizeof level);
level[s] = 0;
Q[0] = s;
for (int ql = 0, qr = 1; ql < qr && level[t] == - 1; ++ql)
{
int u = Q[ql];
for (int e = last[u]; e != -1; e = nextssss[e])
{
int v = adj[e];
if (level[v] == -1 && RES(e) > 0)
{
level[v] = level[u] + 1;
Q[qr++] = v;
}
}
}
return level[t] != -1;
}
int dfs (int u, int curr)
{
if (u == sink)
return curr;
for (int e = now[u]; e != -1; now[u] = e = nextssss[e])
{
int v = adj[e];
if (level[v] == level[u] + 1 && RES(e) > 0)
{
int ans = dfs(v, min(curr, RES(e)));
if (ans > 0)
{
flow[e] += ans;
flow[e ^ 1] -= ans;
return ans;
}
}
}
return 0;
}
int max_flow ()
{
int ans = 0, res;
while (bfs(source, sink))
{
memcpy(now, last, sizeof now);
while ((res = dfs(source, oo)) > 0)
ans += res;
}
return ans;
}
int T;
int A[5000], B[5000];
int na, nb;
int m;
int flow_a(){
source = 1999;
sink = 2000;
E = 0;
memset(last, -1, sizeof last);
for(int i = 0 ; i < m; i++){
add_edge(601+i, sink, 1);
// add_edge(sink, 601+i, 1);
}
for(int i = na - 1, j = 0; i >= 0; i--, j++){
if(j < m){
add_edge(source, 1 + i, 1);
// add_edge(1+i, source, 1);
}
for(int k = 0; k < nb; k++){
int diff = abs(A[i] - B[k]);
if(diff < T){
add_edge(1+i, 601 + k, 1);
add_edge(601+k, 1+i, 1);
}
}
}
return max_flow();
}
int flow_b(){
source = 0;
sink = 2000;
E = 0;
memset(last, -1, sizeof last);
for(int i = 0 ; i < m; i++){
add_edge(601+i, sink, 1);
// add_edge(sink, 601+i, 1);
}
for(int i = nb - 1, j = 0; i >= 0; i--, j++){
if(j < m){
add_edge(source, 1 + i, 1);
// add_edge(1+i, source, 1);
}
for(int k = 0; k < na; k++){
int diff = abs(B[i] - A[k]);
if(diff < T){
add_edge(1+i, 601 + k, 1);
add_edge(601+k, 1+i, 1);
}
}
}
return max_flow();
}
int main()
{
scanf("%d %d %d %d", &m, &na, &nb, &T);
for(int i = 0 ; i < na; i++)
scanf("%d", &A[i]);
for(int i = 0; i < nb; i++)
scanf("%d", &B[i]);
sort(A, A+na);
sort(B, B+nb);
if( flow_a() == m || flow_b() == m)
printf("S\n");
else
printf("N\n");
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c2V0PgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8Y3N0ZGlvPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPHN0YWNrPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8cXVldWU+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBJTkYgOTk5OTk5CiNkZWZpbmUgcGIgcHVzaF9iYWNrCiNkZWZpbmUgbXAgbWFrZV9wYWlyCgp0eXBlZGVmIHBhaXI8aW50LCBpbnQ+IHBpOwoKCgoKY29uc3QgaW50IE1BWFYgPSA1MDAwNSwgTUFYRSA9IDEwNTAwMDAwLCBvbyA9ICgxIDw8IDI1KTsKaW50IEUsIGxhc3RbTUFYVl0sIG5leHRzc3NzW01BWEVdLCBhZGpbTUFYRV0sIGxldmVsW01BWFZdLCBub3dbTUFYVl0sIFFbTUFYVl0sIHNvdXJjZSwgc2luazsKaW50IGNhcFtNQVhFXSwgZmxvd1tNQVhFXTsKCgp2b2lkIGFkZF9lZGdlIChpbnQgdSwgaW50IHYsIGludCBjKQp7CgogICAgY2FwW0VdID0gYywgZmxvd1tFXSA9IDAsIGFkaltFXSA9IHYsIG5leHRzc3NzW0VdID0gbGFzdFt1XSwgbGFzdFt1XSA9IEUrKzsKICAgIGNhcFtFXSA9MCwgZmxvd1tFXSA9IDAsIGFkaltFXSA9IHUsIG5leHRzc3NzW0VdID0gbGFzdFt2XSwgbGFzdFt2XSA9IEUrKzsKfQoKI2RlZmluZSBSRVMoZSkgIChjYXBbZV0gLSBmbG93W2VdKQoKYm9vbCBiZnMgKGludCBzLCBpbnQgdCkKewogICAgbWVtc2V0KGxldmVsLCAtMSwgc2l6ZW9mIGxldmVsKTsKICAgIGxldmVsW3NdID0gMDsKICAgIFFbMF0gPSBzOwoKICAgIGZvciAoaW50IHFsID0gMCwgcXIgPSAxOyBxbCA8IHFyICYmIGxldmVsW3RdID09IC0gMTsgKytxbCkKICAgIHsKICAgICAgICBpbnQgdSA9IFFbcWxdOwoKICAgICAgICBmb3IgKGludCBlID0gbGFzdFt1XTsgZSAhPSAtMTsgZSA9IG5leHRzc3NzW2VdKQogICAgICAgIHsKICAgICAgICAgICAgaW50IHYgPSBhZGpbZV07CgogICAgICAgICAgICBpZiAobGV2ZWxbdl0gPT0gLTEgJiYgUkVTKGUpID4gMCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgbGV2ZWxbdl0gPSBsZXZlbFt1XSArIDE7CiAgICAgICAgICAgICAgICBRW3FyKytdID0gdjsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KCiAgICByZXR1cm4gbGV2ZWxbdF0gIT0gLTE7Cn0KCmludCBkZnMgKGludCB1LCBpbnQgY3VycikKewogICAgaWYgKHUgPT0gc2luaykKICAgICAgICByZXR1cm4gY3VycjsKCiAgICBmb3IgKGludCBlID0gbm93W3VdOyBlICE9IC0xOyBub3dbdV0gPSBlID0gbmV4dHNzc3NbZV0pCiAgICB7CiAgICAgICAgaW50IHYgPSBhZGpbZV07CgogICAgICAgIGlmIChsZXZlbFt2XSA9PSBsZXZlbFt1XSArIDEgJiYgUkVTKGUpID4gMCkKICAgICAgICB7CiAgICAgICAgICAgIGludCBhbnMgPSBkZnModiwgbWluKGN1cnIsIFJFUyhlKSkpOwoKICAgICAgICAgICAgaWYgKGFucyA+IDApCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGZsb3dbZV0gKz0gYW5zOwogICAgICAgICAgICAgICAgZmxvd1tlIF4gMV0gLT0gYW5zOwogICAgICAgICAgICAgICAgcmV0dXJuIGFuczsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KCiAgICByZXR1cm4gMDsKfQoKaW50IG1heF9mbG93ICgpCnsKICAgIGludCBhbnMgPSAwLCByZXM7CgogICAgd2hpbGUgKGJmcyhzb3VyY2UsIHNpbmspKQogICAgewogICAgICAgIG1lbWNweShub3csIGxhc3QsIHNpemVvZiBub3cpOwoKICAgICAgICB3aGlsZSAoKHJlcyA9IGRmcyhzb3VyY2UsIG9vKSkgPiAwKQogICAgICAgICAgICBhbnMgKz0gcmVzOwogICAgfQoKICAgIHJldHVybiBhbnM7Cn0KCmludCBUOwppbnQgQVs1MDAwXSwgQls1MDAwXTsKaW50IG5hLCBuYjsKaW50IG07CgppbnQgZmxvd19hKCl7CgogICAgc291cmNlID0gMTk5OTsKICAgIHNpbmsgPSAyMDAwOwoKCiAgICBFID0gMDsKICAgIG1lbXNldChsYXN0LCAtMSwgc2l6ZW9mIGxhc3QpOwoKICAgIGZvcihpbnQgaSA9IDAgOyBpIDwgbTsgaSsrKXsKICAgICAgICBhZGRfZWRnZSg2MDEraSwgc2luaywgMSk7CiAgICAvLyAgICBhZGRfZWRnZShzaW5rLCA2MDEraSwgMSk7CiAgICB9CgogICAgZm9yKGludCBpID0gbmEgLSAxLCBqID0gMDsgaSA+PSAwOyBpLS0sIGorKyl7CgogICAgICAgIGlmKGogPCBtKXsKICAgICAgICAgICAgYWRkX2VkZ2Uoc291cmNlLCAxICsgaSwgMSk7CiAgICAgICAgIC8vICAgYWRkX2VkZ2UoMStpLCBzb3VyY2UsIDEpOwogICAgICAgIH0KCiAgICAgICAgZm9yKGludCBrID0gMDsgayA8IG5iOyBrKyspewogICAgICAgICAgICBpbnQgZGlmZiA9IGFicyhBW2ldIC0gQltrXSk7CgogICAgICAgICAgICBpZihkaWZmIDwgVCl7CiAgICAgICAgICAgICAgICBhZGRfZWRnZSgxK2ksIDYwMSArIGssIDEpOwogICAgICAgICAgICAgICAgYWRkX2VkZ2UoNjAxK2ssIDEraSwgMSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgfQoKICAgIHJldHVybiBtYXhfZmxvdygpOwp9CgppbnQgZmxvd19iKCl7CgogICAgc291cmNlID0gMDsKICAgIHNpbmsgPSAyMDAwOwoKICAgIEUgPSAwOwogICAgbWVtc2V0KGxhc3QsIC0xLCBzaXplb2YgbGFzdCk7CgogICAgZm9yKGludCBpID0gMCA7IGkgPCBtOyBpKyspewogICAgICAgIGFkZF9lZGdlKDYwMStpLCBzaW5rLCAxKTsKICAgICAgLy8gIGFkZF9lZGdlKHNpbmssIDYwMStpLCAxKTsKICAgIH0KCiAgICBmb3IoaW50IGkgPSBuYiAtIDEsIGogPSAwOyBpID49IDA7IGktLSwgaisrKXsKCiAgICAgICAgaWYoaiA8IG0pewogICAgICAgICAgICBhZGRfZWRnZShzb3VyY2UsIDEgKyBpLCAxKTsKICAgICAgICAvLyAgICBhZGRfZWRnZSgxK2ksIHNvdXJjZSwgMSk7CiAgICAgICAgfQoKICAgICAgICBmb3IoaW50IGsgPSAwOyBrIDwgbmE7IGsrKyl7CiAgICAgICAgICAgIGludCBkaWZmID0gYWJzKEJbaV0gLSBBW2tdKTsKCiAgICAgICAgICAgIGlmKGRpZmYgPCBUKXsKICAgICAgICAgICAgICAgIGFkZF9lZGdlKDEraSwgNjAxICsgaywgMSk7CiAgICAgICAgICAgICAgICBhZGRfZWRnZSg2MDEraywgMStpLCAxKTsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICB9CgogICAgcmV0dXJuIG1heF9mbG93KCk7Cn0KCgppbnQgbWFpbigpCnsKCiAgICBzY2FuZigiJWQgJWQgJWQgJWQiLCAmbSwgJm5hLCAmbmIsICZUKTsKCiAgICBmb3IoaW50IGkgPSAwIDsgaSA8IG5hOyBpKyspCiAgICAgICAgc2NhbmYoIiVkIiwgJkFbaV0pOwoKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuYjsgaSsrKQogICAgICAgIHNjYW5mKCIlZCIsICZCW2ldKTsKCiAgICBzb3J0KEEsIEErbmEpOwogICAgc29ydChCLCBCK25iKTsKCiAgICBpZiggZmxvd19hKCkgPT0gbSB8fCBmbG93X2IoKSA9PSBtKQogICAgICAgIHByaW50ZigiU1xuIik7CiAgICBlbHNlCiAgICAgICAgcHJpbnRmKCJOXG4iKTsKCiAgICByZXR1cm4gMDsKfQ==