#include <cstdio> #include <cstring> #include <algorithm> using namespace std; #define inf 10000000 int dp[11000]; int n; int val[550],wei[550]; int main() { int cas,n; scanf("%d",&cas); while(cas--) { int w1,w2,w; int i,j; scanf("%d%d",&w1,&w2); w=w2-w1; for(i=0;i<=w;i++) dp[i]=inf; scanf("%d",&n); for(i=1;i<=n;i++) scanf("%d%d",&val[i],&wei[i]); dp[0]=0; for(i=1;i<=n;i++) for(j=wei[i];j<=w;j++) dp[j]=min(dp[j],dp[j-wei[i]]+val[i]); if(dp[w]==inf) printf("This is impossible. "); else printf("The minimum amount of money in the piggy-bank is %d. ",dp[w]); } return 0; }