ans = '\left(\begin{array}{cccc} -\sin\left(a_{7}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)-\sin\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\cos\left(a_{7}\right)\,\left(\cos\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\sin\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)-\cos\left(a_{1}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)\right) & \sin\left(a_{7}\right)\,\left(\cos\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\sin\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)-\cos\left(a_{1}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)\right)-\cos\left(a_{7}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)-\sin\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right) & -\sin\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\cos\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)-\cos\left(a_{1}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right) & \left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)\,\left(L_{1}\,\sin\left(a_{4}\right)+W_{1}\,\left(\cos\left(a_{4}\right)-1\right)\right)-\left(\sin\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)+\cos\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)-\cos\left(a_{1}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)\right)\,\left(L_{1}+L_{2}+L_{3}\right)+\sin\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)+\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)\,\left(L_{1}+L_{2}\right)+\cos\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\left(W_{1}\,\sin\left(a_{4}\right)-L_{1}\,\left(\cos\left(a_{4}\right)-1\right)\right)+\left(\cos\left(a_{6}\right)-1\right)\,\left(\sin\left(a_{4}\right)\,\left(\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)-\cos\left(a_{1}\right)\,\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\right)-\cos\left(a_{1}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)\,\left(L_{1}+L_{2}\right)\\ \sin\left(a_{7}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)-\sin\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)+\cos\left(a_{7}\right)\,\left(\cos\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\sin\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)+\cos\left(a_{4}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\right)\right) & \cos\left(a_{7}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)-\sin\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\sin\left(a_{7}\right)\,\left(\cos\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)-\sin\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)+\cos\left(a_{4}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\right)\right) & \sin\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)+\cos\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)+\cos\left(a_{4}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\right) & \left(\sin\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)+\cos\left(a_{6}\right)\,\left(\sin\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)+\cos\left(a_{4}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\right)\right)\,\left(L_{1}+L_{2}+L_{3}\right)-\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)\,\left(L_{1}\,\sin\left(a_{4}\right)+W_{1}\,\left(\cos\left(a_{4}\right)-1\right)\right)-\sin\left(a_{6}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{1}\right)\,\cos\left(a_{3}\right)-\cos\left(a_{2}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{3}\right)\right)+\cos\left(a_{5}\right)\,\left(\cos\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)-\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)\right)\,\left(L_{1}+L_{2}\right)+\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\,\left(W_{1}\,\sin\left(a_{4}\right)-L_{1}\,\left(\cos\left(a_{4}\right)-1\right)\right)-\left(\cos\left(a_{6}\right)-1\right)\,\left(\sin\left(a_{4}\right)\,\left(\cos\left(a_{1}\right)\,\sin\left(a_{3}\right)+\cos\left(a_{2}\right)\,\cos\left(a_{3}\right)\,\sin\left(a_{1}\right)\right)+\cos\left(a_{4}\right)\,\sin\left(a_{1}\right)\,\sin\left(a_{2}\right)\right)\,\left(L_{1}+L_{2}\right)\\ \sin\left(a_{7}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{2}\right)\,\sin\left(a_{4}\right)+\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)+\cos\left(a_{5}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{3}\right)\right)-\cos\left(a_{7}\right)\,\left(\sin\left(a_{6}\right)\,\left(\cos\left(a_{2}\right)\,\cos\left(a_{4}\right)-\cos\left(a_{3}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)+\cos\left(a_{6}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{2}\right)\,\sin\left(a_{4}\right)+\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)-\sin\left(a_{2}\right)\,\sin\left(a_{3}\right)\,\sin\left(a_{5}\right)\right)\right) & \sin\left(a_{7}\right)\,\left(\sin\left(a_{6}\right)\,\left(\cos\left(a_{2}\right)\,\cos\left(a_{4}\right)-\cos\left(a_{3}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)+\cos\left(a_{6}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{2}\right)\,\sin\left(a_{4}\right)+\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)-\sin\left(a_{2}\right)\,\sin\left(a_{3}\right)\,\sin\left(a_{5}\right)\right)\right)+\cos\left(a_{7}\right)\,\left(\sin\left(a_{5}\right)\,\left(\cos\left(a_{2}\right)\,\sin\left(a_{4}\right)+\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)+\cos\left(a_{5}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{3}\right)\right) & \cos\left(a_{6}\right)\,\left(\cos\left(a_{2}\right)\,\cos\left(a_{4}\right)-\cos\left(a_{3}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)\right)-\sin\left(a_{6}\right)\,\left(\cos\left(a_{5}\right)\,\left(\cos\left(a_{2}\right)\,\sin\left(a_{4}\right)+\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)\right)-\sin\left(a_{2}\right)\,\sin\left(a_{3}\right)\,\sin\left(a_{5}\right)\right) & L_{1}\,\cos\left(a_{2}\right)+L_{2}\,\cos\left(a_{2}\right)\,\cos\left(a_{4}\right)-W_{1}\,\cos\left(a_{3}\right)\,\sin\left(a_{2}\right)+W_{1}\,\cos\left(a_{2}\right)\,\sin\left(a_{4}\right)+W_{1}\,\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\sin\left(a_{2}\right)-L_{2}\,\cos\left(a_{3}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)+L_{3}\,\cos\left(a_{2}\right)\,\cos\left(a_{4}\right)\,\cos\left(a_{6}\right)-L_{3}\,\cos\left(a_{3}\right)\,\cos\left(a_{6}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{4}\right)-L_{3}\,\cos\left(a_{2}\right)\,\cos\left(a_{5}\right)\,\sin\left(a_{4}\right)\,\sin\left(a_{6}\right)+L_{3}\,\sin\left(a_{2}\right)\,\sin\left(a_{3}\right)\,\sin\left(a_{5}\right)\,\sin\left(a_{6}\right)-L_{3}\,\cos\left(a_{3}\right)\,\cos\left(a_{4}\right)\,\cos\left(a_{5}\right)\,\sin\left(a_{2}\right)\,\sin\left(a_{6}\right)\\ 0 & 0 & 0 & 1 \end{array}\right)'