#!/usr/bin/python
import sys

n = int(sys.stdin.next())

for i in xrange(n):
    para = map(int, sys.stdin.next().strip().split(" "))
    pixel = map(int, sys.stdin.next().strip().split(" "))
    print para
    print pixel
