def transform_line(line):
    if line.startswith('#'):
        header_level = line.split()[0]
        line = line.replace(header_level, header_level[:(- 1)])
        if line.split()[1][0].isdigit():
            line = ('# ' + ' '.join(line.split()[2:]))
    if line.startswith('**Figure'):
        line = ''
    line = line.replace('$$', '$')
    if ('include_relative' in line):
        filename = line.split()[2]
        with open(filename, 'r') as f:
            line = ('\n' + ''.join([transform_line(line) for line in f]))
    return line
def transform_line(line):
    if line.startswith('#'):
        header_level = line.split()[0]
        line = line.replace(header_level, header_level[:(- 1)])
        if line.split()[1][0].isdigit():
            line = ('# ' + ' '.join(line.split()[2:]))
    if line.startswith('**Figure'):
        line = 
    line = line.replace('$$', '$')
    if ('include_relative' in line):
        filename = line.split()[2]
        with open(filename, 'r') as f:
            line = ('\n' + .join([transform_line(line) for line in f]))
    return line