merge JSJ/JJJ, split JSJSJ -> (JSJ)SJ, JJSJ -> (JJ)SJ