#!/usr/bin/env python
# -*- coding: utf-8 -*-

import fileinput

# ['S', 'H', 'C', 'D']
number = range(1, 52)
m_number = range(1, 4)
card = (m_number, number)

if __name__ == '__main__':
    line = fileinput.input()
    count = int(line)

    for i in range(1, count):
        line = fileinput.input()
        tokens = line.strip().split()
        a, b = tokens[0], int(tokens[1])
        print '%S %d' % (a, b)