Original: Then, thinking they are dogs, they start walking around on all fours (hands and legs) and barking.
Simplified: Then, thinking they are dogs, they start walking around (hands and legs) are barking.