#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#define MAX 2010
#define MOD 32767
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
int t, n, m, X[MAX], Y[MAX], id[MOD + 6667], hash[MOD + 6667], counter[MOD + 6667];
int F(int i, int j){
int x = (X[i] - X[j]);
int y = (Y[i] - Y[j]);
return ((x * x) + (y * y));
}
int find(int x){
int i = x & MOD, res = 0;
while (id[i] == m && hash[i] != x) i++;
if (id[i] == m){
res = counter[i];
counter[i]++;
}
else hash[i] = x, counter[i] = 1, id[i] = m;
return res;
}
int main(){
int T = 0, i, j, k, l;
scanf("%d", &t);
while (t--){
scanf("%d", &n);
for (i = 0; i < n; i++) scanf("%d %d", &X[i], &Y[i]);
long long res = 0;
for (i = 0; i < n; i++){
m++;
for (j = 0; j < n; j++){
res += find(F(i, j));
}
}
printf("Case #%d: %lld\n", ++T, res);
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KI2luY2x1ZGUgPHN0ZGJvb2wuaD4KCiNkZWZpbmUgTUFYIDIwMTAKI2RlZmluZSBNT0QgMzI3NjcKI2RlZmluZSBjbHIoYXIpIG1lbXNldChhciwgMCwgc2l6ZW9mKGFyKSkKI2RlZmluZSByZWFkKCkgZnJlb3BlbigibG9sLnR4dCIsICJyIiwgc3RkaW4pCgppbnQgdCwgbiwgbSwgWFtNQVhdLCBZW01BWF0sIGlkW01PRCArIDY2NjddLCBoYXNoW01PRCArIDY2NjddLCBjb3VudGVyW01PRCArIDY2NjddOwoKaW50IEYoaW50IGksIGludCBqKXsKICAgIGludCB4ID0gKFhbaV0gLSBYW2pdKTsKICAgIGludCB5ID0gKFlbaV0gLSBZW2pdKTsKICAgIHJldHVybiAoKHggKiB4KSArICh5ICogeSkpOwp9CgppbnQgZmluZChpbnQgeCl7CiAgICBpbnQgaSA9IHggJiBNT0QsIHJlcyA9IDA7CiAgICB3aGlsZSAoaWRbaV0gPT0gbSAmJiBoYXNoW2ldICE9IHgpIGkrKzsKICAgIGlmIChpZFtpXSA9PSBtKXsKICAgICAgICByZXMgPSBjb3VudGVyW2ldOwogICAgICAgIGNvdW50ZXJbaV0rKzsKICAgIH0KICAgIGVsc2UgaGFzaFtpXSA9IHgsIGNvdW50ZXJbaV0gPSAxLCBpZFtpXSA9IG07CiAgICByZXR1cm4gcmVzOwp9CgppbnQgbWFpbigpewogICAgaW50IFQgPSAwLCBpLCBqLCBrLCBsOwoKICAgIHNjYW5mKCIlZCIsICZ0KTsKICAgIHdoaWxlICh0LS0pewogICAgICAgIHNjYW5mKCIlZCIsICZuKTsKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbjsgaSsrKSBzY2FuZigiJWQgJWQiLCAmWFtpXSwgJllbaV0pOwoKICAgICAgICBsb25nIGxvbmcgcmVzID0gMDsKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbjsgaSsrKXsKICAgICAgICAgICAgbSsrOwogICAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgbjsgaisrKXsKICAgICAgICAgICAgICAgIHJlcyArPSBmaW5kKEYoaSwgaikpOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwcmludGYoIkNhc2UgIyVkOiAlbGxkXG4iLCArK1QsIHJlcyk7CiAgICB9CiAgICByZXR1cm4gMDsKfQ==