1 #include <iostream>
2 #include <algorithm>
3 using namespace std;
4 #define MAX 1002
5
6 bool comp (double a , double b)
7 {
8 return a < b;
9 }
10
11 int main()
12 {
13 double x[ MAX ] , y[ MAX ] , h[ MAX ];
14
15 bool visited[ MAX ];
16
17 int t , n , rear , i , j , index;
18
19 cin >> t;
20 while (t --)
21 {
22 memset (visited , true , sizeof (visited));
23 cin >> n;
24 for (i = 1 ; i <= n ; ++ i)
25 cin >> x[ i ] >> y[ i ];
26 sort (x + 1 , x + n + 1 , comp);
27 sort (y + 1 , y + n + 1 , comp);
28 rear = n;
29
30 x[ 0 ] = x[ 1 ];
31
32 x[n + 1] = x[ n ];
33
34 for (i = 1 ; i <= n ; ++ i)
35 {
36 double max = 0;
37 for (j = 1 ; j <= n ; ++ j)
38 {
39 if (max < x[j + 1] - x[j - 1] && visited[ j ])
40 {
41 max = x[j + 1] - x[j - 1];
42 index = j;
43 }
44 }
45 h[ index ] = y[ rear ];
46 rear --;
47 visited[ index ] = false;
48 }
49
50 double sum = 0;
51
52 for (i = 1 ; i < n ; ++ i)
53 sum += (x[i + 1] - x[ i ]) * (h[ i ] + h[i + 1]);
54
55 sum /= 2;
56
57 printf ("%.1f\n" , sum);
58 }
59 return 0;
60 }
61
62