#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const char *os[] = {"Others","Parallelogram","Rectangle","Diamond","Square"};
const double EPS=1e-8;

bool equal(double a,double b) { return fabs(a-b)<EPS; }

typedef LL NUM;
struct VEC {
	NUM x,y;
};
VEC operator-(VEC a,VEC b) { return (VEC){a.x-b.x,a.y-b.y}; }
NUM operator*(VEC a,VEC b) { return a.x*b.x+a.y*b.y; }


VEC wu[5],seg[4];
double len[4];
int main() {
	int T; cin>>T;//scanf("%d",&T);
	for (int tt=1;T--;tt++) {
		for (int i=0;i<4;i++) cin>>wu[i].x>>wu[i].y;//scanf("%d%d",&
		wu[4]=wu[0];
		for (int i=0;i<4;i++) {
			seg[i]=wu[i+1]-wu[i];
			len[i]=hypot(seg[i].x,seg[i].y);
		}

		printf("Case #%d: ",tt);
		if (equal(len[0],len[2]) && equal(len[1],len[3]) && equal(len[0],len[1])) {
			if (seg[0]*seg[1] == 0) //
				puts(os[4]);
			else
				puts(os[3]);
		}
		else {
			if (equal(len[0],len[2]) && equal(len[1],len[3])) {
				if (seg[0]*seg[1] == 0) //
					puts(os[2]);
				else
					puts(os[1]);
			}
			else
				puts(os[0]);
		}
	}
	return 0;
}
