<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def print_pairwise(pw, median = False):
 """ print matrix of pidents to stdout """

    names = sorted(set([i for i in pw]))
    if len(names) != 0:
        if '>' in names[0]:
            yield ['#'] + [i.split('>')[1] for i in names if '>' in i]
        else:
            yield ['#'] + names
        for a in names:
            if '>' in a:
                yield [a.split('>')[1]] + [pw[a][b] for b in names]
            else:
                out = []
                for b in names:
                    if b in pw[a]:
                        if median is False:
                            out.append(max(pw[a][b]))
                        else:
                            out.append(np.median(pw[a][b]))
                    else:
                        out.append('-')
                yield [a] + out