/*
    如果已經知道走這些passage的順序的話,應該可以dp出來的
    但是這里不確定順序,要選擇最優,可以按照P/Q從大到小排序
    遇到匪徒幾率Q越小,出去幾率P越大,肯定是我們優先考慮的!
    Help Bill to find out the probability that he can escape from this castle if he chose the optimal strategy.

    dp[i][j]表示現在有錢j,在i個passage處,最后能夠出去的概率
    dp[n-1,j]=P[n-1]
    dp[i,j]=P[i]+Q[i]*dp[i+1,j-1]+(1-P[i]-Q[i])*dp[i+1,j]   j>0
    dp[i,j]=P[i]+(1-P[i]-Q[i])*dp[i+1,j]   j=0

    概率題期望題,一般都是表示現在離目標的值
    (因為當前接下來的方案確定了,概率也知道了,而當前從前面過來就不確定概率了,其概率跟路徑有關)
*/

#include
<cstdio>
#include
<algorithm>
using namespace std;

struct Pas
{
    
double p,q;
    
bool operator<(const Pas&B)const
    
{
        
return p/q>B.p/B.q;
    }

}
pas[1010];

double dp[1010][11];

int main()
{
    
int n,m,T,t=1;
    scanf(
"%d",&T);
    
while(T--)
    
{
        scanf(
"%d%d",&n,&m);
        
for(int i=0;i<n;i++)
            scanf(
"%lf%lf",&pas[i].p,&pas[i].q);
        sort(pas,pas
+n);
        
//mesmet(dp,0,sizeof(dp));
        for(int j=0;j<=m;j++)dp[n-1][j]=pas[n-1].p;
        
for(int i=n-2;i>=0;i--)
        
{
            dp[i][
0]=pas[i].p+(1-pas[i].p-pas[i].q)*dp[i+1][0];
            
for(int j=1;j<=m;j++)
            
{
                dp[i][j]
=pas[i].p+pas[i].q*dp[i+1][j-1]+(1-pas[i].p-pas[i].q)*dp[i+1][j];
            }

        }

        printf(
"Case %d: %.5f\n",t++,dp[0][m]);
    }

    
return 0;
}