#include<iostream> #include<vector> using namespace std; struct coord { int x,y; }P[1005]; int n,d; char cmd; int fa[1005],x,y; vector<int> ok; void init() { for(int i = 1;i <= n;++i) fa[i] = i; } int Find(int x) { if(x == fa[x]) return x; else return fa[x] = Find(fa[x]); } void Union(int x,int y) { x = Find(x); y = Find(y); if(x != y) fa[x] = y; } int calDis(coord a,coord b) { return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y); } void check(int x) { for(int i = 0;i < ok.size();++i) if(calDis(P[x],P[ok[i]]) <= d*d) Union(x,ok[i]); ok.push_back(x); } int main() { //freopen("in.txt","r",stdin); scanf("%d%d",&n,&d); for(int i = 1;i <= n;++i) scanf("%d%d",&P[i].x,&P[i].y); init(); while(scanf("/n%c",&cmd) != EOF) { if(cmd == 'O') { scanf("%d",&x); check(x); } else { scanf("%d%d",&x,&y); x = Find(x); y = Find(y); if(x != y) printf("FAIL/n"); else printf("SUCCESS/n"); } } return 0; }