r("else":t:"then":c:i@"if":l)e|e/=i&&c>i=r l t|e/=i=r l e;r l a=a:l m@main=getLine>>=putStrLn.head.foldl r[].words>>m