var t,l,i,n,m,k,lx:longint; a,f:array[0..200050] of longint; ans:int64; begin readln(t); for l:=1 to t do begin fillchar(a,sizeof(a),0); fillchar(f,sizeof(f),0); readln(n,m,k); for i:=1 to n do begin read(a[i]); if (a[i]>=m) then f[i]:=f[i-1]+1 else f[i]:=f[i-1]; end; readln; ans:=0; i:=1; while (i<=n) and (f[i]=k) do inc(lx); ans:=ans+lx; inc(i); end; writeln(ans); end; end.