#!ruby -pal
def i c,d
[0,1].map{|j|d[j]?c[j]&&(i c[j],d[j]):(c[j]=nil)}
c
end
def u c,d
[0,1].map{|j|(c[j]||d[j]&&(c[j]||=[nil,nil]))&&(u c[j],d[j]||=[nil,nil])}
c
end
$_=eval($F[0]+" "+$F[1,2].map{|l|l.tr("()","[]").gsub(/(\[|,)(?=,|\])/,'\1nil')}*",").to_s.gsub(/nil| /,"").tr("[]","()")