#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <sstream>
#include <cassert>
using namespace std;
typedef long long ll;
const ll INF=1000000000LL*1000000000LL;
struct point
{
ll x,y;
point(ll x=0, ll y=0):x(x),y(y){}
point operator+(const point& p) const
{
return point(x+p.x, y+p.y);
}
point operator-(const point& p) const
{
return point(x-p.x, y-p.y);
}
point rot() const
{
return point(y,-x);
}
ll inner(const point& p) const
{
return x*p.x + y*p.y;
}
ll cross(const point& p) const
{
return x*p.y - y*p.x;
}
ll norm2() const
{
return x*x+y*y;
}
//lexicographical
bool cmp(const point& p) const
{
if(y!=p.y) return y<p.y;
return x<p.x;
}
//polar
bool operator<(const point& p) const
{
bool down1=this->cmp(point(0,0));
bool down2=p.cmp(point(0,0));
if(down1!=down2)
return down1>down2;
return this->cross(p)>0;
}
bool operator==(const point& p) const
{
return this->cross(p)==0 && this->inner(p)>0;
}
bool operator!=(const point& p) const
{
return !((*this)==p);
}
};
struct Event
{
point p;
// 0 - add
// 1 - query
// 2 - rem
int type;
Event(point p=point(), int type=0):
p(p),
type(type)
{}
bool operator<(const Event& ev) const
{
if(p!=ev.p)
return p<ev.p;
return type<ev.type;
}
};
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n;
scanf("%d",&n);
vector<point> p(n);
set<pair<int,int> > used;
for(int i=0;i<n;i++)
scanf("%lld%lld",&p[i].x, &p[i].y);
ll res=ll(n)*(n-1)*(n-2)/6;
ll bad=0;
vector<point> v;
vector<Event> ev;
for(int i=0;i<n;i++)
{
v.clear();
ev.clear();
for(int j=0;j<n;j++)
if(i!=j)
v.push_back(p[j]-p[i]);
point sample(-2000000001,1);
int cnt=0;
for(int j=0;j+1<n;j++)
{
point c=v[j];
ev.push_back(Event(c, 1));
point A, B;
A=c.rot();
B=A.rot().rot();
if(B<A)
swap(A,B);
bool present=v[j].inner(sample)<=0;
if(present)
{
cnt++;
ev.push_back(Event(A,2));
ev.push_back(Event(B,0));
}
else
{
ev.push_back(Event(A,0));
ev.push_back(Event(B,2));
}
}
sort(ev.begin(), ev.end());
for(const Event & e: ev)
{
if(e.type==1)
bad+=cnt;
else if(e.type==0)
cnt++;
else
cnt--;
}
}
res-=bad/2;
cout<<res<<endl;
}
return 0;
}
I2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPG1hcD4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8Y3N0ZGlvPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8cXVldWU+CiNpbmNsdWRlIDxzc3RyZWFtPgojaW5jbHVkZSA8Y2Fzc2VydD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnR5cGVkZWYgbG9uZyBsb25nIGxsOwoKY29uc3QgbGwgSU5GPTEwMDAwMDAwMDBMTCoxMDAwMDAwMDAwTEw7CgpzdHJ1Y3QgcG9pbnQKewoJbGwgeCx5OwoJcG9pbnQobGwgeD0wLCBsbCB5PTApOngoeCkseSh5KXt9Cglwb2ludCBvcGVyYXRvcisoY29uc3QgcG9pbnQmIHApIGNvbnN0Cgl7CgkJcmV0dXJuIHBvaW50KHgrcC54LCB5K3AueSk7Cgl9Cglwb2ludCBvcGVyYXRvci0oY29uc3QgcG9pbnQmIHApIGNvbnN0Cgl7CgkJcmV0dXJuIHBvaW50KHgtcC54LCB5LXAueSk7Cgl9Cglwb2ludCByb3QoKSBjb25zdAoJewoJCXJldHVybiBwb2ludCh5LC14KTsKCX0KCWxsIGlubmVyKGNvbnN0IHBvaW50JiBwKSBjb25zdAoJewoJCXJldHVybiB4KnAueCArIHkqcC55OwoJfQoJbGwgY3Jvc3MoY29uc3QgcG9pbnQmIHApIGNvbnN0Cgl7CgkJcmV0dXJuIHgqcC55IC0geSpwLng7Cgl9CglsbCBub3JtMigpIGNvb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