Creating a 5-axis robot

Hello! I tried to write kinematics for such a case, but it didn’t work out. Can you help me? I will be very grateful.
image


image