#!/bin/bash

read T
for ((i=0; i<T; i++)) ; do
    read
    read N
    head -n $N  > infile
    (
      echo "#include <cstdio>"
      echo "int main() {"
      cat infile | sed -e 's/ .*/;/' -e 's/^/int /'
      echo "for (int i=0; i<$N; ++i) {"
      cat infile | sed -e 's/$/;/'
      echo "}"
      cat infile | sed -e 's/^\([^ ]*\) .*/printf("\1 = %d\\n",\1);/'
      echo "}"
    ) > outfile.cc
    g++ outfile.cc -o binary && ./binary | LC_COLLATE=C sort
done
rm infile outfile.cc binary

