#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
using namespace std;
struct node {
int x;
int y;
}s[1005];
int Set[1005];
int vist[1005];
int n;
double m;
bool judge(int a, int b) {
if((s[a].x-s[b].x)*(s[a].x-s[b].x) + (s[a].y-s[b].y)* (s[a].y-s[b].y) <= m*m) {
return true;
}else {
return false;
}
}
int Find(int x) {
while(x != Set[x])
x = Set[x];
return x;
}
void Union(int a, int b) {
a = Find(a);
b = Find(b);
if(a != b) {
Set[a] = b;
}
}
void work(int a) {
for(int i = 1; i <= n; i++) {
if(i != a &&vist[i]&&judge(i, a)) {
Union(a, i);
}
}
}
int main()
{
char str[3];
int a, b;
scanf("%d%lf", &n, &m);
for(int i = 1; i <= n; i++) {
scanf("%d%d", &a, &b);
s[i].x = a;
s[i].y = b;
Set[i] = i;
vist[i] = 0;
}
while(scanf("%ss", str) != EOF) {
if(str[0] == 'O') {
scanf("%d", &a);
vist[a] = 1;
work(a);
}
if(str[0] == 'S') {
scanf("%d%d", &a, &b);
if(Find(a) == Find(b)) {
printf("SUCCESS\n");
} else {
printf("FAIL\n");
}
}
}
return 0;
}
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
using namespace std;
struct node {
int x;
int y;
}s[1005];
int Set[1005];
int vist[1005];
int n;
double m;
bool judge(int a, int b) {
if((s[a].x-s[b].x)*(s[a].x-s[b].x) + (s[a].y-s[b].y)* (s[a].y-s[b].y) <= m*m) {
return true;
}else {
return false;
}
}
int Find(int x) {
while(x != Set[x])
x = Set[x];
return x;
}
void Union(int a, int b) {
a = Find(a);
b = Find(b);
if(a != b) {
Set[a] = b;
}
}
void work(int a) {
for(int i = 1; i <= n; i++) {
if(i != a &&vist[i]&&judge(i, a)) {
Union(a, i);
}
}
}
int main()
{
char str[3];
int a, b;
scanf("%d%lf", &n, &m);
for(int i = 1; i <= n; i++) {
scanf("%d%d", &a, &b);
s[i].x = a;
s[i].y = b;
Set[i] = i;
vist[i] = 0;
}
while(scanf("%ss", str) != EOF) {
if(str[0] == 'O') {
scanf("%d", &a);
vist[a] = 1;
work(a);
}
if(str[0] == 'S') {
scanf("%d%d", &a, &b);
if(Find(a) == Find(b)) {
printf("SUCCESS\n");
} else {
printf("FAIL\n");
}
}
}
return 0;
}