# optimize output length

Q=[]
A=->*x{Q<<[?+,*x]*" "}
C=->*x{Q<<[?<,*x]*" "}

C[2,0,4]
0.upto(30){|i|
 A[4+i,4+i,5+i]
}

s=36
31.downto(0){|i|
 A[4+i,s+33,3]
 C[0,3,s+i]
 C[s+i,4,3]
 i.times{A[3,3,3]}
 A[3,s+33,s+33]
}

s=66
A[1,4,1]
31.downto(0){|i|
 A[4+i,s+33,3]
 C[3,1,s+i]
 C[2,s+i,3]
 i.times{A[3,3,3]}
 A[3,s+33,s+33]
}

58.downto(0){|k|
 [k-29,0].max.upto([k,29].min){|i|
  j=k-i
  C[36+i,66+j,3]
  A[2,3,2]
 }
 A[2,2,2] if k>0
}

puts Q.size,Q