When they looked at it, they were thinking deeply what to do.
They were deep in thought, thinking what to do when they looked at it.
彼ら – they
それ – it
見て - look
どうするか – what to do
考えこんでいた – think deeply, deep in thought.
山積みのごみを見てどうしようかと考え込んでいるシーンです。
It was a scene when looking at a pile of garbage and thinking what to do.