Added debug function print_q