#include #include #include #include #include #include using namespace std; typedef long long ll; typedef complex bod; bod nacitaj() { ll o, p; scanf(" (%lld,%lld)", &o, &p); return bod(2*o, 2*p); } ll vs(bod a, bod b) { return imag(conj(a)*b); } ll ss(bod a, bod b) { return real(conj(a)*b); } bool lezi(bod a, bod b, bod c) { return vs(c-a, c-b) == 0 && ss(c-a, c-b) <= 0; } bool pret(bod a, bod b, bod c, bod d) { if (lezi(a, b, c) || lezi(a, b, d) || lezi(c, d, a) || lezi(c, d, b)) return true; return vs(c-a, b-a)*vs(d-a, b-a)<0 && vs(a-c, d-c)*vs(b-c, d-c)<0; } int main() { char t[2000], n[200]; while (scanf("%s", t) == 1) { if (t[0] == '.') break; vector a[26]; for (int i=0; i<26; i++) a[i].clear(); do { scanf(" %s", n); string s(n); vector tmp; if (s == "square") { bod a = nacitaj(); bod b = nacitaj(); bod S = bod((real(a)+real(b))/2, (imag(a)+imag(b))/2); bod V = bod((imag(a)-imag(b))/2, (real(a)-real(b))/2); tmp.push_back(a); tmp.push_back(S+V); tmp.push_back(b); tmp.push_back(S-V); } if (s == "rectangle") { bod a = nacitaj(); bod b = nacitaj(); bod c = nacitaj(); tmp.push_back(a); tmp.push_back(b); tmp.push_back(c); tmp.push_back(a+c-b); } if (s == "triangle") { bod a = nacitaj(); bod b = nacitaj(); bod c = nacitaj(); tmp.push_back(a); tmp.push_back(b); tmp.push_back(c); } if (s == "line") { bod a = nacitaj(); bod b = nacitaj(); tmp.push_back(a); tmp.push_back(b); } if (s == "polygon") { int c; scanf("%d", &c); for (int i=0; i y; for (int j=0; j<26; j++) if (h[i][j]) y.push_back(j+'A'); printf("%c ", 'A'+i); if (y.empty()) printf("has no intersections\n"); else { printf("intersects with"); if (y.size()==1) printf(" %c\n", y[0]); if (y.size() == 2) printf(" %c and %c\n", y[0], y[1]); if (y.size() > 2) { for (unsigned j=0; j