#!/usr/bin/python

# Author: Peter Schwabe
# Date: 2009-03-19
# Public domain

import re
import sys

blankstr = ""
beginstr = "[\ \t]*#[\ \t]*BEGIN\ MACRO"
endstr   = "[\ \t]*#[\ \t]*END\ MACRO"
blankstr = "[\ \t]*"

mbegin = re.compile(beginstr)
mend   = re.compile(endstr)
mblank = re.compile(blankstr)
inside = 0

for line in sys.stdin.readlines():
    if inside == 0:
        exp = mblank.match(line)
        blankstr=exp.group()
    
    line = re.sub("^[\ \t]*", "", line)
    exp = mbegin.match(line)
    if exp:
        blankstr = blankstr+"  "
        inside += 1
    
    print blankstr+line,
    
    exp = mend.match(line)
    if exp:
        blankstr = re.sub("\ \ $","",blankstr)
        inside -= 1

