/***********Template Starts Here***********/
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long vlong;
typedef pair < int, int > pii;
typedef vector<pii> vii;
typedef vector<int> vi;
/***********Template Ends Here***********/
vector<pii> p;
int main () {
#ifdef forthright48
freopen ( "input.txt", "r", stdin );
//freopen ( "output.txt", "w", stdout );
#endif // forthright48
int kase;
scanf ( "%d", &kase );
int cnt = 0;
while ( kase-- ) {
int l, w;
scanf ( "%d %d", &l, &w );
int n;
scanf ( "%d", &n );
p.clear();
vi height; ///Will list all possible heights for top and bottom boundary
FOR(i,0,n-1) {
int a, b;
scanf ( "%d %d", &a, &b );
p.pb ( MP(a,b) ); ///Insert point
height.pb ( b ); ///Insert possible boundary
}
height.pb ( 0 ); ///Don't forget the Sand Kingdom Boundaries
height.pb ( w );
sort ( ALL(height) ); ///Make the heights sorted and unique
UNIQUE(height);
int m = height.size();
p.pb ( MP(0,0) ); ///Add dummy points to indicate left and right wall of sand kingdom
p.pb ( MP(l,0) );
n = p.size(); ///Update N
sort ( ALL(p) ); ///Sort all points
vlong res = 0;
FOR(i,0,m-1) { ///Set lower boundary of rectangle
FOR(j,i+1,m-1) { ///Set upper boundary of rectangle
int d = height[i], u = height[j];
int cur = 0; ///Current point which is acting as left boundary of rectangle
p[0].ss = d; ///Make sure first and last point, which are Sand Kingdom's wall don't get ignored.
p[n-1].ss = d;
FOR ( k, 1, n - 1 ) {
if ( p[k].ss < d || p[k].ss > u ) continue; ///Not inside rectangle
int width = p[k].ff - p[cur].ff; ///Inside rectangle. Calculate width
res = MAX(res,width*(u-d)); ///Update result
if ( p[k].ss > d && p[k].ss < u ) { ///If strictly inside, update left wall.
cur = k;
}
}
}
}
printf ("Case %d: %lld\n", ++cnt, res );
}
return 0;
}
LyoqKioqKioqKioqVGVtcGxhdGUgU3RhcnRzIEhlcmUqKioqKioqKioqKi8KI2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CgojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIGZmIGZpcnN0CiNkZWZpbmUgc3Mgc2Vjb25kCiNkZWZpbmUgTVAgbWFrZV9wYWlyCiNkZWZpbmUgRk9SKGkseCx5KSBmb3IodmxvbmcgaSA9ICh4KSA7IGkgPD0gKHkpIDsgKytpKQojZGVmaW5lIFJPRihpLHgseSkgZm9yKHZsb25nIGkgPSAoeSkgOyBpID49ICh4KSA7IC0taSkKI2RlZmluZSBVTklRVUUoVikgKFYpLmVyYXNlKHVuaXF1ZSgoVikuYmVnaW4oKSwoVikuZW5kKCkpLChWKS5lbmQoKSkKI2RlZmluZSBNSU4oYSxiKSAoKGEpPChiKT8oYSk6KGIpKQojZGVmaW5lIE1BWChhLGIpICgoYSk+KGIpPyhhKTooYikpCiNkZWZpbmUgQUxMKHgpICh4KS5iZWdpbigpLCh4KS5lbmQoKQoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnR5cGVkZWYgbG9uZyBsb25nIHZsb25nOwp0eXBlZGVmIHBhaXIgPCBpbnQsIGludCA+IHBpaTsKdHlwZWRlZiB2ZWN0b3I8cGlpPiB2aWk7CnR5cGVkZWYgdmVjdG9yPGludD4gdmk7CgovKioqKioqKioqKipUZW1wbGF0ZSBFbmRzIEhlcmUqKioqKioqKioqKi8KCnZlY3RvcjxwaWk+IHA7CgppbnQgbWFpbiAoKSB7CiAgICAjaWZkZWYgZm9ydGhyaWdodDQ4CiAgICBmcmVvcGVuICggImlucHV0LnR4dCIsICJyIiwgc3RkaW4gKTsKICAgIC8vZnJlb3BlbiAoICJvdXRwdXQudHh0IiwgInciLCBzdGRvdXQgKTsKICAgICNlbmRpZiAvLyBmb3J0aHJpZ2h0NDgKCiAgICBpbnQga2FzZTsKICAgIHNjYW5mICggIiVkIiwgJmthc2UgKTsKCiAgICBpbnQgY250ID0gMDsKCiAgICB3aGlsZSAoIGthc2UtLSApIHsKICAgICAgICBpbnQgbCwgdzsKICAgICAgICBzY2FuZiAoICIlZCAlZCIsICZsLCAmdyApOwoKICAgICAgICBpbnQgbjsKICAgICAgICBzY2FuZiAoICIlZCIsICZuICk7CgogICAgICAgIHAuY2xlYXIoKTsKCiAgICAgICAgdmkgaGVpZ2h0OyAvLy9XaWxsIGxpc3QgYWxsIHBvc3NpYmxlIGhlaWdodHMgZm9yIHRvcCBhbmQgYm90dG9tIGJvdW5kYXJ5CgogICAgICAgIEZPUihpLDAsbi0xKSB7CiAgICAgICAgICAgIGludCBhLCBiOwogICAgICAgICAgICBzY2FuZiAoICIlZCAlZCIsICZhLCAmYiApOwogICAgICAgICAgICBwLnBiICggTVAoYSxiKSApOyAvLy9JbnNlcnQgcG9pbnQKICAgICAgICAgICAgaGVpZ2h0LnBiICggYiApOyAvLy9JbnNlcnQgcG9zc2libGUgYm91bmRhcnkKICAgICAgICB9CgogICAgICAgIGhlaWdodC5wYiAoIDAgKTsgLy8vRG9uJ3QgZm9yZ2V0IHRoZSBTYW5kIEtpbmdkb20gQm91bmRhcmllcwogICAgICAgIGhlaWdodC5wYiAoIHcgKTsKCiAgICAgICAgc29ydCAoIEFMTChoZWlnaHQpICk7IC8vL01ha2UgdGhlIGhlaWdodHMgc29ydGVkIGFuZCB1bmlxdWUKICAgICAgICBVTklRVUUoaGVpZ2h0KTsKCiAgICAgICAgaW50IG0gPSBoZWlnaHQuc2l6ZSgpOwoKICAgICAgICBwLnBiICggTVAoMCwwKSApOyAvLy9BZGQgZHVtbXkgcG9pbnRzIHRvIGluZGljYXRlIGxlZnQgYW5kIHJpZ2h0IHdhbGwgb2Ygc2FuZCBraW5nZG9tCiAgICAgICAgcC5wYiAoIE1QKGwsMCkgKTs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QgJiYgcFtrXS5zcyA8IHUgKSB7IC8vL0lmIHN0cmljdGx5IGluc2lkZSwgdXBkYXRlIGxlZnQgd2FsbC4KICAgICAgICAgICAgICAgICAgICAgICAgY3VyID0gazsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHByaW50ZiAoIkNhc2UgJWQ6ICVsbGRcbiIsICsrY250LCByZXMgKTsKCiAgICB9CgogICAgcmV0dXJuIDA7Cn0K