#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define rep(i,a,n) for (int i=a;i=a;i--) #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define se second #define SZ(x) ((int)(x).size()) #define ACCU accumulate #define TWO(x) (1<<(x)) #define TWOL(x) (1ll<<(x)) #define clr(a) memset(a,0,sizeof(a)) #define POSIN(x,y) (0<=(x)&&(x) VI; typedef vector VS; typedef vector VD; typedef long long ll; typedef long double LD; typedef pair PII; typedef pair PLL; typedef vector VL; typedef vector VPII; typedef complex CD; const int inf=0x20202020; const ll mod=1000000007; const double eps=1e-9; const double pi=3.1415926535897932384626; const int DX[]={1,0,-1,0},DY[]={0,1,0,-1}; ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;} ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;} ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;} // head const int N=1010; int _,n,tot,x[N],y[N]; PII v[N]; ll ans; int main() { for (scanf("%d",&_);_;_--) { scanf("%d",&n); ans=0; rep(i,0,n) scanf("%d%d",x+i,y+i); rep(i,0,n) { tot=0; rep(j,0,n) if (i!=j) { int dx=x[j]-x[i],dy=y[j]-y[i]; int d=gcd(dx,dy); dx/=d; dy/=d; if (dx!=0&&dy!=0) { if (dx<0) dx*=-1, dy*=-1; } else dx=max(dx,-dx),dy=max(dy,-dy); v[tot++]=mp(dx,dy); } sort(v,v+tot); int bp=0; rep(j,0,tot) { if (j==0||v[j]!=v[j-1]) bp=j; ans+=j-bp; } } printf("%I64d\n",ans/3); } }