#include <stdio.h>
#include<string.h>
#include<stdlib.h>

char str[10];
double a[10005];
int cnt;

//处理输出的数小数位最后为非0数
void Output( double s ){
char sa[10015];
int i,len;
sprintf( sa, "%lf",s );
len = strlen(sa);
for( i=len-1; i>=0 ; i– ){
if(sa[i] == '.')
break;
if( sa[i] == '0' )
sa[i] = '\0';
else
break;
}
if( sa[ i ] == '.')
sa[i] = '\0';
if( sa[0] == '\0' )
printf("0\n");
printf( "%s\n",sa );
}
//用二分查找当前要操作的数该插入或者在当前数中的位置
int Search(double s,int k){
int l=0,r=cnt-1,m=(l+r)/2;
while( l <= r ){
if( a[m] > s )
r = m – 1;
else
l=m + 1;
m = (l+r)/2;
}
if( k )
return l;
return r;
}
//添加一个数，并求中位数
int k = Search( s,1 );
int i;
for(i=cnt-1; i>=k; i–)
a[i+1]=a[i];
a[k] = s;
cnt++;
if( cnt%2 != 0 )
Output( a[cnt/2] );
else
Output( (a[cnt/2]+a[(cnt-1)/2])/2 );
}
//删除一个数，并求中位数
void Remove( double s ){
int k = Search(s,0);
int i;
if( k<0 || a[k]!=s )
printf( "Wrong!\n" );
else{
for( i=k; i<cnt-1; i++ )
a[i]=a[i+1];
cnt –;
if(cnt == 0 )
printf("Empty!\n");
else{
if( cnt%2 != 0 )
Output( a[cnt/2] );
else
Output( (a[cnt/2]+a[(cnt-1)/2])/2 );
}
}
}

int main(){
int T,n;
double m;
scanf( "%d",&T );
while( T– ){
cnt = 0;
scanf( "%d",&n );
while( n — ){
scanf( "%s%lf",str,&m );