#!/usr/bin/env python

import sys
import re
from bisect import insort

COPY_RE = re.compile(r'COPY .*? \(.*?\) FROM stdin;\n$')

def try_float(s):
    if not s or s[0] not in '0123456789.-':
        # optimization
        return s
    try:
        return float(s)
    except ValueError:
        return s

def linecomp(l1, l2):
    p1 = l1.split('\t', 1)
    p2 = l2.split('\t', 1)
    result = cmp(try_float(p1[0]), try_float(p2[0]))
    if not result and len(p1) == len(p2) == 2:
        return linecomp(p1[1], p2[1])
    return result

if __name__ == '__main__':
    copy_lines = None
    for line in sys.stdin:
        if copy_lines is None:
            if COPY_RE.match(line):
                copy_lines = []
            sys.stdout.write(line)
        else:
            if line == '\\.\n':
                copy_lines.sort(cmp=linecomp)
                for copy_line in copy_lines:
                    sys.stdout.write(copy_line)
                sys.stdout.write(line)
                copy_lines = None
            else:
                copy_lines.append(line)