#include <bits/stdc++.h>
#include<limits.h>
#include<stdio.h>
#include<cstring>
#include<string>
using namespace  std;
typedef long long ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define fi first
#define se second
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define filla(a,k,n) memset(a,k,sizeof(a[0])*n)
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
#define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 1e5+5, MOD = 1e9+7;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
int main()
{
    ll t;
    cin>>t;
    ll h=1;
    while(h<=t)
    {
        v64 vx,vy;
        ll flag=0,k=1,r=0,i,j;
        ll n,m;
        cin>>n>>m;
        if(n>m)
        {
            swap(n,m);
            k=0;
        }
        if(n==1 or m==1)
        {
            flag=1;
        }
        else if(n<=3 and m<=3)
        {
            flag=1;
        }
        else if(m==4 and n==2)
        {
            flag=1;
        }
        else if(m==4 and n==4)
        {
            cout<<"Case #"<<h;
            cout<<": POSSIBLE";
            ln;
            for(i=1;i<=4;i++)
            {
                cout<<1<<" "<<i;
                ln;
                cout<<3<<" "<<(i%4)+1;
                ln;
            }
            for(i=4;i>1;i--)
            {
                cout<<2<<" "<<i;
                ln;
                cout<<4<<" "<<i-1;
                ln;
            }
            cout<<2<<" "<<1;
            ln;
            cout<<4<<" "<<4;
            ln;
            h++;
            continue;
        }
        if(n%2 and flag==0)
        {
            ll s=((m+1)/2);
            if(m==4)
            {
                vx.pb(2);vy.pb(2);
                vx.pb(4);vy.pb(1);
                vx.pb(1);vy.pb(3);
                vx.pb(3);vy.pb(2);
                vx.pb(1);vy.pb(1);
                vx.pb(4);vy.pb(3);
                vx.pb(2);vy.pb(1);
                vx.pb(4);vy.pb(2);
                vx.pb(2);vy.pb(3);
                vx.pb(3);vy.pb(1);
                vx.pb(1);vy.pb(2);
                vx.pb(3);vy.pb(3);
            }
            else
            {
            for(i=1;i<=(m+1)/2;i++)
            {
                vx.pb(i);
                vy.pb(1);
                if(i+s<=m)
                {
                    vx.pb(i+s);
                    vy.pb(3);
                    r=1;
                }
            }
            for(j=1;i<=m;i++,j++)
            {
                if(m%2==0)
                {
                    vx.pb(i);
                    vy.pb(1);
                    vx.pb(j);
                    vy.pb(2);
                }
                else
                {
                    vx.pb(j);
                    vy.pb(2);
                    vx.pb(i);
                    vy.pb(1);
                }
            }
            for(i=1;j<=m;j++,i++)
            {
                if(m%2==1)
                {
                    vx.pb(j);
                    vy.pb(2);
                    vx.pb(i);
                    vy.pb(3);
                }
                else
                {
                    vx.pb(i);
                    vy.pb(3);
                    vx.pb(j);
                    vy.pb(2);
                }
            }
            }
        }
        if(flag==0)
        {
            ll i,j;
            i=1;
            if(n%2)
            {
                i=i+3;
            }
            ll s=((m+1)/2);
            for(;i+1<=n;i=i+2)
            {
                for(j=1;j<=m;j++)
                {
                    vx.pb(j);
                    vy.pb(i);
                    vx.pb(((j+s-1)%m)+1);
                    vy.pb(i+1);
                }
            }
            cout<<"Case #"<<h;
            cout<<": POSSIBLE";
            ln;
            if(k==1)
            {
                for(i=0;i<vx.size();i++)
                {
                    cout<<vy[i];
                    sp;
                    cout<<vx[i];
                    ln;
                }
            }
            else
            {
                for(i=0;i<vx.size();i++)
                {
                    cout<<vx[i];
                    sp;
                    cout<<vy[i];
                    ln;
                }
            }
        }
        else if(flag==1)
        {
            cout<<"Case #"<<h;
            cout<<": IMPOSSIBLE";
            ln;
        }
        h++;

    }


}
