#include using namespace std; int T; int n,k; int tt,dd; int main(){ //freopen("00.txt","r",stdin); //freopen("00o.txt","w",stdout); cin>>T; while(T--){ cin>>n>>k; int sol=0; for(int i=0;i>tt>>dd; if(tt>k){ tt-=k; k=0; } else { k-=tt; tt=0; } sol+= tt*dd; } cout<