'''Author- Akshit Monga'''
import sys,os,io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
def back(arr,ind,taken,s_taken):
global ans
if ind==n:
ans=[]
for i in range(n):
ans.append((arr[i]+1,s_taken[i]+1))
return True
for i in range(n):
if i not in taken:
for j in childToSweet[i]:
if j in s_taken:
continue
if not j:
return False
if back(arr+[i],ind+1,taken.union({i}),s_taken+[j]):
return True
break
return False
t=int(input())
for _ in range(t):
print("Case #{}:".format(_+1),end=" ")
n=int(input())
children=[]
for i in range(n):
x,y=map(int,input().split())
children.append((x,y))
sweets=[]
for i in range(n+1):
x, y = map(int, input().split())
sweets.append((x, y))
childToSweet=[[i for i in range(n+1)] for j in range(n)]
for i in range(n):
childToSweet[i].sort(key=lambda x:((children[i][0]-sweets[x][0])**2+(children[i][1]-sweets[x][1])**2,-x))
ans=None
back([],0,set(),[])
if not ans:
print("IMPOSSIBLE")
else:
print("POSSIBLE")
for i,j in ans:
sys.stdout.write(str(i)+" "+str(j)+"\n")
JycnQXV0aG9yLSBBa3NoaXQgTW9uZ2EnJycKaW1wb3J0IHN5cyxvcyxpbwppbnB1dCA9IGlvLkJ5dGVzSU8ob3MucmVhZCgwLCBvcy5mc3RhdCgwKS5zdF9zaXplKSkucmVhZGxpbmUKCgpkZWYgYmFjayhhcnIsaW5kLHRha2VuLHNfdGFrZW4pOgogICAgZ2xvYmFsIGFucwogICAgaWYgaW5kPT1uOgogICAgICAgIGFucz1bXQogICAgICAgIGZvciBpIGluIHJhbmdlKG4pOgogICAgICAgICAgICBhbnMuYXBwZW5kKChhcnJbaV0rMSxzX3Rha2VuW2ldKzEpKQogICAgICAgIHJldHVybiBUcnVlCiAgICBmb3IgaSBpbiByYW5nZShuKToKICAgICAgICBpZiBpIG5vdCBpbiB0YWtlbjoKICAgICAgICAgICAgZm9yIGogaW4gY2hpbGRUb1N3ZWV0W2ldOgogICAgICAgICAgICAgICAgaWYgaiBpbiBzX3Rha2VuOgogICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlCiAgICAgICAgICAgICAgICBpZiBub3QgajoKICAgICAgICAgICAgICAgICAgICByZXR1cm4gRmFsc2UKICAgICAgICAgICAgICAgIGlmIGJhY2soYXJyK1tpXSxpbmQrMSx0YWtlbi51bmlvbih7aX0pLHNfdGFrZW4rW2pdKToKICAgICAgICAgICAgICAgICAgICByZXR1cm4gVHJ1ZQogICAgICAgICAgICAgICAgYnJlYWsKICAgIHJldHVybiBGYWxzZQoKCgp0PWludChpbnB1dCgpKQpmb3IgXyBpbiByYW5nZSh0KToKICAgIHByaW50KCJDYXNlICN7fToiLmZvcm1hdChfKzEpLGVuZD0iICIpCiAgICBuPWludChpbnB1dCgpKQogICAgY2hpbGRyZW49W10KICAgIGZvciBpIGluIHJhbmdlKG4pOgogICAgICAgIHgseT1tYXAoaW50LGlucHV0KCkuc3BsaXQoKSkKICAgICAgICBjaGlsZHJlbi5hcHBlbmQoKHgseSkpCiAgICBzd2VldHM9W10KICAgIGZvciBpIGluIHJhbmdlKG4rMSk6CiAgICAgICAgeCwgeSA9IG1hcChpbnQsIGlucHV0KCkuc3BsaXQoKSkKICAgICAgICBzd2VldHMuYXBwZW5kKCh4LCB5KSkKICAgIGNoaWxkVG9Td2VldD1bW2kgZm9yIGkgaW4gcmFuZ2UobisxKV0gZm9yIGogaW4gcmFuZ2UobildCiAgICBmb3IgaSBpbiByYW5nZShuKToKICAgICAgICBjaGlsZFRvU3dlZXRbaV0uc29ydChrZXk9bGFtYmRhIHg6KChjaGlsZHJlbltpXVswXS1zd2VldHNbeF1bMF0pKioyKyhjaGlsZHJlbltpXVsxXS1zd2VldHNbeF1bMV0pKioyLC14KSkKICAgIGFucz1Ob25lCiAgICBiYWNrKFtdLDAsc2V0KCksW10pCiAgICBpZiBub3QgYW5zOgogICAgICAgIHByaW50KCJJTVBPU1NJQkxFIikKICAgIGVsc2U6CiAgICAgICAgcHJpbnQoIlBPU1NJQkxFIikKICAgICAgICBmb3IgaSxqIGluIGFuczoKICAgICAgICAgICAgc3lzLnN0ZG91dC53cml0ZShzdHIoaSkrIiAiK3N0cihqKSsiXG4iKQ==