I'm reading about surface code theory recently (Phys. Rev. A 86, 032324). When I come across the magic state distillation part, it is difficult for me to understand the circuits. In addition, I have read Bravyi and Kitaev's paper about magic state distillation(Phys. Rev. A 71, 022316). But when back to the circuits below, I still can not figure out the process how it work.