#include <cstdlib>#include <iostream>#define x first#define y secondusingnamespacestd;typedefpair<longlong,longlong>Point;intT,now;Pointa[2],O(0,0);inlinelonglongCrossProduct(constPoint&A,constPoint&B,constPoint&C,constPoint&D){constlonglongx1=B.x-A.x,y1=B.y-A.y;constlonglongx2=D.x-C.x,y2=D.y-C.y;returnx1*y2-y1*x2;}intmain(){ios::sync_with_stdio(false);cin>>T;while(T--){a[now=0]=make_pair(0,0);longlongans=0;charc;while(cin>>c,c!='5'){longlongx=a[now].x,y=a[now].y;if(c=='9'||c=='6'||c=='3')++x;if(c=='7'||c=='4'||c=='1')--x;if(c=='7'||c=='8'||c=='9')++y;if(c=='1'||c=='2'||c=='3')--y;a[now^=1]=make_pair(x,y);ans+=CrossProduct(O,a[now^1],O,a[now]);}if(ans<0)ans=-ans;if(ans&1)cout<<((ans-1)>>1)<<".5"<<endl;elsecout<<(ans>>1)<<endl;}}