/* Template: By Jugal :) */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector <int> vi;
typedef vector <vi> vii;
typedef pair<int,int> pii;
typedef ll ft;
#define get getchar_unlocked
#define put putchar_unlocked
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define ln length()
#define rep(i,n) for(int i=0;i<n;i++)
#define ref(i,a,n) for(int i=a;i<=n;i++)
#define reb(i,n,a) for(int i=n;i>=a;i--)
#define all(a) a.begin(),a.end()
#define gi(n) scanf("%d",&n)
#define gii(n) scanf("%lld",&n)
#define gc(c) scanf(" %c",&c)
#define pi(n) printf("%d",n)
#define pii(n) printf("%lld",n)
#define pc(c) printf("%c",c)
#define ps printf(" ")
#define pn printf("\n")
void gl(char *str) { char c; int i=0; if((c=get())!='\n') str[i++]=c; while((c=get())!='\n') str[i++]=c;str[i]='\0'; }
void pl(char *str) { rep(i,strlen(str)) put(str[i]); }
void gfi(ft &x) {
register ft c = get(); x = 0; ft sn=1;
for(;(c<48 || c>57);c = get()) if(c=='-') sn=-1;
for(;c>47 && c<58;c = get()) {x = (x<<1) + (x<<3) + c - 48;}
x*=sn;
}
ll val[1000],wgt[1000],dp[505][1005];
ll solve(ll n,ll w) {
if(n==0 && w==0) return 0;
if(n!=0 && w==0) return 0;
if(n==0 && w!=0) return 10000000000ULL;
if(dp[n][w]!=-1) return dp[n][w];
ll ans=min(solve(n-1,w),(w-wgt[n]>=0)?(val[n]+solve(n,w-wgt[n])):solve(n-1,w));
// cout << ans << endl;
return dp[n][w]=ans;
}
int main() {
ll t;
gfi(t);
while(t--) {
ll n,e,w;
gfi(e);gfi(w);
w=w-e;
gfi(n);
ref(i,1,n) {
gfi(val[i]);gfi(wgt[i]);
}
rep(i,n+3) rep(j,w+3) dp[i][j]=-1;
ref(i,1,n) {
ref(j,1,w) {
solve(i,j);
}
}
if(dp[n][w]>=10000000000ULL) cout << "This is impossible." << endl;
else cout << "The minimum amount of money in the piggy-bank is " << dp[n][w] << "." << end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