Medau Therapy Services GmbH | Schloss Hohenfels | 96450 Coburg
Medau Therapy Services GmbH | Schloss Hohenfels | 96450 Coburg
MEDAUtherapie Hygiene neu

MEDAUphysio Praxen für Physiotherapie & Krankengymnastik

Ihr Partner für die ganzheitliche physiotherapeutische Behandlung

In den MEDAUphysio Praxen werden Sie von erfahrenen Therapeuten und Therapeutinnen behandelt, die Expertinnen in ihrem jeweiligen Fachgebiet sind. In Kooperation mit der Berufsfachschule für Physiotherapie, der Medau-Schule garantieren wir Ihnen eine optimale Behandlung nach aktuellen wissenschaftlichen Leitlinien. 

OpenStreetMap

Mit dem Laden der Karte akzeptieren Sie die Datenschutzerklärung von OpenStreetMap Foundation.
Mehr erfahren

Karte laden

PGRpdiBjbGFzcz0ibGVhZmxldC1tYXAgV1BMZWFmbGV0TWFwIiBzdHlsZT0iaGVpZ2h0OjUwMHB4OyB3aWR0aDoxMDAlOyI+PC9kaXY+PHNjcmlwdD4Kd2luZG93LldQTGVhZmxldE1hcFBsdWdpbiA9IHdpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4gfHwgW107CndpbmRvdy5XUExlYWZsZXRNYXBQbHVnaW4ucHVzaChmdW5jdGlvbiBXUExlYWZsZXRNYXBTaG9ydGNvZGUoKSB7Lyo8c2NyaXB0PiovCnZhciBiYXNlVXJsID0gJ2h0dHBzOi8ve3N9LnRpbGUub3BlbnN0cmVldG1hcC5vcmcve3p9L3t4fS97eX0ucG5nJzsKdmFyIGJhc2UgPSAoIWJhc2VVcmwgJiYgd2luZG93Lk1RKSA/IAogICAgd2luZG93Lk1RLm1hcExheWVyKCkgOiBMLnRpbGVMYXllcihiYXNlVXJsLCAKICAgICAgICBMLlV0aWwuZXh0ZW5kKHt9LCB7CiAgICAgICAgICAgIGRldGVjdFJldGluYTogMCwKICAgICAgICAgICAgbWluWm9vbTogMCwKICAgICAgICAgICAgbWF4Wm9vbTogMjAsCiAgICAgICAgfSwgCiAgICAgICAgeyJzdWJkb21haW5zIjoiYWJjIi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XAgPSB3aW5kb3cuV1BMZWFmbGV0TWFwUGx1Z2luLmdldEN1cnJlbnRHcm91cCgpOwp2YXIgbWFya2VyX29wdGlvbnMgPSAoZnVuY3Rpb24gKCkgewogICAgdmFyIF9vcHRpb25zID0geyJpY29uVXJsIjoiXC93cC1jb250ZW50XC91cGxvYWRzXC8yMDE3XC8xMFwvbWFya2VyLWZtdy1waHlzaW8ucG5nIiwiaWNvblNpemUiOlsiNTEsNTEiXSwiaWNvbkFuY2hvciI6WyIyNS41LDUxIl19OwogICAgdmFyIGljb25BcnJheXMgPSBbCiAgICAgICAgJ2ljb25TaXplJywgCiAgICAgICAgJ2ljb25BbmNob3InLCAKICAgICAgICAnc2hhZG93U2l6ZScsIAogICAgICAgICdzaGFkb3dBbmNob3InLAogICAgICAgICdwb3B1cEFuY2hvcicKICAgIF07CiAgICB2YXIgZGVmYXVsdF9pY29uID0gTC5JY29uLkRlZmF1bHQucHJvdG90eXBlLm9wdGlvbnM7CiAgICBpZiAoX29wdGlvbnMuaWNvblVybCkgewogICAgICAgIC8vIGFycmF5cyBhcmUgc3RyaW5ncywgdW5mb3J0dW5hdGVseS4uLgogICAgICAgIGZvciAodmFyIGkgPSAwLCBsZW4gPSBpY29uQXJyYXlzLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgICAgIHZhciBvcHRpb25fbmFtZSA9IGljb25BcnJheXNbaV07CiAgICAgICAgICAgIHZhciBvcHRpb24gPSBfb3B0aW9uc1sgb3B0aW9uX25hbWUgXTsKICAgICAgICAgICAgLy8gY29udmVydCAiMSwyIiB0byBbMSwgMl07CiAgICAgICAgICAgIGlmIChvcHRpb24pIHsKICAgICAgICAgICAgICAgIHZhciBhcnIgPSBvcHRpb24uam9pbignJykuc3BsaXQoJywnKTsKICAgICAgICAgICAgICAgIC8vIGFycmF5Lm1hcCBmb3IgaWU8OQogICAgICAgICAgICAgICAgZm9yICh2YXIgaiA9IDAsIGxlbkogPSBhcnIubGVuZ3RoOyBqIDwgbGVuSjsgaisrKSB7CiAgICAgICAgICAgICAgICAgICAgYXJyW2pdID0gTnVtYmVyKGFycltqXSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBfb3B0aW9uc1sgb3B0aW9uX25hbWUgXSA9IGFycjsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICAvLyBkZWZhdWx0IHBvcHVwQW5jaG9yCiAgICAgICAgaWYgKCFfb3B0aW9ucy5wb3B1cEFuY2hvcikgewogICAgICAgICAgICAvLyBzZXQgKHJvdWdobHkpIHRvIHNpemUgb2YgaWNvbgogICAgICAgICAgICBfb3B0aW9ucy5wb3B1cEFuY2hvciA9IChmdW5jdGlvbiAoaV9zaXplKSB7CiAgICAgICAgICAgICAgICAvLyBjb3B5IGFycmF5CiAgICAgICAgICAgICAgICBpX3NpemUgPSBpX3NpemUuc2xpY2UoKTsKICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgLy8gaW52ZXJzZSBjb29yZGluYXRlcwogICAgICAgICAgICAgICAgaV9zaXplWzBdID0gMDsKICAgICAgICAgICAgICAgIGlfc2l6ZVsxXSAqPSAtMTsKICAgICAgICAgICAgICAgIC8vIGJvdHRvbSBwb3NpdGlvbiBvbiBwb3B1cCBpcyA3cHgKICAgICAgICAgICAgICAgIGlfc2l6ZVsxXSAtPSAzOwogICAgICAgICAgICAgICAgcmV0dXJuIGlfc2l6ZTsKICAgICAgICAgICAgfSkoX29wdGlvbnMuaWNvblNpemUgfHwgZGVmYXVsdF9pY29uLmljb25TaXplKTsKICAgICAgICB9CiAgICAgICAgX29wdGlvbnMuaWNvbiA9IG5ldyBMLkljb24oIF9vcHRpb25zICk7CiAgICB9CiAgICByZXR1cm4gX29wdGlvbnM7Cn0pKCk7CnZhciBtYXJrZXIgPSBMLm1hcmtlcigKICAgIFs1MC4yNTUwMTcsMTAuOTYyMjM2XSwgCiAgICBtYXJrZXJfb3B0aW9ucwopOwp2YXIgaXNfaW1hZ2UgPSBtY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srKSB7CiAgICAgICAgICAgIHZhciBvcHRpb25fbmFtZSA9IGljb25BcnJheXNbaV07CiAgICAgICAgICAgIHZhciBvcHRpb24gPSBfb3B0aW9uc1sgb3B0aW9uX25hbWUgXTsKICAgICAgICAgICAgLy8gY29udmVydCAiMSwyIiB0byBbMSwgMl07CiAgICAgICAgICAgIGlmIChvcHRpb24pIHsKICAgICAgICAgICAgICAgIHZhciBhcnIgPSBvcHRpb24uam9pbignJykuc3BsaXQoJywnKTsKICAgICAgICAgICAgICAgIC8vIGFycmF5Lm1hcCBmb3IgaWU8OQogICAgICAgICAgICAgICAgZm9yICh2YXIgaiA9IDAsIGxlbkogPSBhcnIubGVuZ3RoOyBqIDwgbGVuSjsgaisrKSB7CiAgICAgICAgICAgICAgICAgICAgYXJyW2pdID0gTnVtYmVyKGFycltqXSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBfb3B0aW9uc1sgb3B0aW9uX25hbWUgXSA9IGFycjsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICAvLyBkZWZhdWx0IHBvcHVwQW5jaG9yCiAgICAgICAgaWYgKCFfb3B0aW9ucy5wb3B1cEFuY2hvcikgewogICAgICAgICAgICAvLyBzZXQgKHJvdWdobHkpIHRvIHNpemUgb2YgaWNvbgogICAgICAgICAgICBfb3B0aW9ucy5wb3B1cEFuY2hvciA9IChmdW5jdGlvbiAoaV9zaXplKSB7CiAgICAgICAgICAgICAgICAvLyBjb3B5IGFycmF5CiAgICAgICAgICAgICAgICBpX3NpemUgPSBpX3NpemUuc2xpY2UoKTsKICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgLy8gaW52ZXJzZSBjb29yZGluYXRlcwogICAgICAgICAgICAgICAgaV9zaXplWzBdID0gMDsKICAgICAgICAgICAgICAgIGlfc2l6ZVsxXSAqPSAtMTsKICAgICAgICAgICAgICAgIC8vIGJvdHRvbSBwb3NpdGlvbiBvbiBwb3B1cCBpcyA3cHgKICAgICAgICAgIC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b25TaXplIjpbIjUxLDUxIl0sImljb25BbmNob3IiOlsiMjUuNSw1MSJdfTsKICAgIHZhciBpY29uQXJyYXlzID0gWwogICAgICAgICdpY29uU2l6ZScsIAogICAgICAgICdpY29uQW5jaG9yJywgCiAgICAgICAgJ3NoYWRvd1NpemUnLCAKICAgICAgICAnc2hhZG93QW5jaG9yJywKICAgICAgICAncG9wdXBBbmNob3InCiAgICBdOwogICAgdmFyIGRlZmF1bHRfaWNvbiA9IEwuSWNvbi5EZWZhdWx0LnByb3RvdHlwZS5vcHRpb25zOwogICAgaWYgKF9vcHRpb25zLmljb25VcmwpIHsKICAgICAgICAvLyBhcnJheXMgYXJlIHN0cmluZ3MsIHVuZm9ydHVuYXRlbHkuLi4KICAgICAgICBmb3IgKHZhciBpID0gMCwgbGVuID0gaWNvbkFycmF5cy5sZW5ndGg7IGkgPCBsZW47IGkrKykgewogICAgICAgICAgICB2YXIgb3B0aW9uX25hbWUgPSBpY29uQXJyYXlzW2ldOwogICAgICAgICAgICB2YXIgb3B0aW9uID0gX29wdGlvbnNbIG9wdGlvbl9uYW1lIF07CiAgICAgICAgICAgIC8vIGNvbnZlcnQgIjEsMiIgdG8gWzEsIDJdOwogICAgICAgICAgICBpZiAob3B0aW9uKSB7CiAgICAgICAgICAgICAgICB2YXIgYXJyID0gb3B0aW9uLmpvaW4oJycpLnNwbGl0KCcsJyk7CiAgICAgICAgICAgICAgICAvLyBhcnJheS5tYXAgZm9yIGllPDkKICAgICAgICAgICAgICAgIGZvciAodmFyIGogPSAwLCBsZW5KID0gYXJyLmxlbmd0aDsgaiA8IGxlbko7IGorKykgewogICAgICAgICAgICAgICAgICAgIGFycltqXSA9IE51bWJlcihhcnJbal0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgX29wdGlvbnNbIG9wdGlvbl9uYW1lIF0gPSBhcnI7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgLy8gZGVmYXVsdCBwb3B1cEFuY2hvcgogICAgICAgIGlmICghX29wdGlvbnMucG9wdXBBbmNob3IpIHsKICAgICAgICAgICAgLy8gc2V0IChyb3VnaGx5KSB0byBzaXplIG9mIGljb24KICAgICAgICAgICAgX29wdGlvbnMucG9wdXBBbmNob3IgPSAoZnVuY3Rpb24gKGlfc2l6ZSkgewogICAgICAgICAgICAgICAgLy8gY29weSBhcnJheQogICAgICAgICAgICAgICAgaV9zaXplID0gaV9zaXplLnNsaWNlKCk7CiAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIC8vIGludmVyc2UgY29vcmRpbmF0ZXMKICAgICAgICAgICAgICAgIGlfc2l6ZVswXSA9IDA7CiAgICAgICAgICAgICAgICBpX3NpemVbMV0gKj0gLTE7CiAgICAgICAgICAgICAgICAvLyBib3R0b20gcG9zaXRpb24gb24gcG9wdXAgaXMgN3B4CiAgICAgICAgICAgICAgICBpX3NpemVbMV0gLT0gMzsKICAgICAgICAgICAgICAgIHJldHVybiBpX3NpemU7CiAgICAgICAgICAgIH0pKF9vcHRpb25zLmljb25TaXplIHx8IGRlZmF1bHRfaWNvbi5pY29uU2l6ZSk7CiAgICAgICAgfQogICAgICAgIF9vcHRpb25zLmljb24gPSBuZXcgTC5JY29uKCBfb3B0aW9ucyApOwogICAgfQogICAgcmV0dXJuIF9vcHRpb25zOwp9KSgpOwp2YXIgbWFya2VyID0gTC5tYXJrZXIoCiAgICBbNTAuMjY2NTE1MDU0MzE5LDEwLjk0OTI2MzQ2NjY1Nl0sIAogICAgbWFya2VyX29wdGlvbnMKKTsKdmFyIGlzX2ltYWdlID0gbWFwLmlzX2ltYWdlX21hcDsKaWYgKG1hcmtlcl9vcHRpb25zLmRyYWdnYWJsZSkgewogICAgbWFya2VyLm9uKCdkcmFnZW5kJywgZnVuY3Rpb24gKCkgewogICAgICAgIHZhciBsYXRsbmcgPSB0aGlzLmdldExhdExuZygpOwogICAgICAgIHZhciBsYXQgPSBsYXRsbmcubGF0OwogICAgICAgIHZhciBsbmcgPSBsYXRsbmc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pb25fbmFtZSBdOwogICAgICAgICAgICAvLyBjb252ZXJ0ICIxLDIiIHRvIFsxLCAyXTsKICAgICAgICAgICAgaWYgKG9wdGlvbikgewogICAgICAgICAgICAgICAgdmFyIGFyciA9IG9wdGlvbi5qb2luKCcnKS5zcGxpdCgnLCcpOwogICAgICAgICAgICAgICAgLy8gYXJyYXkubWFwIGZvciBpZTw5CiAgICAgICAgICAgICAgICBmb3IgKHZhciBqID0gMCwgbGVuSiA9IGFyci5sZW5ndGg7IGogPCBsZW5KOyBqKyspIHsKICAgICAgICAgICAgICAgICAgICBhcnJbal0gPSBOdW1iZXIoYXJyW2pdKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIF9vcHRpb25zWyBvcHRpb25fbmFtZSBdID0gYXJyOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIC8vIGRlZmF1bHQgcG9wdXBBbmNob3IKICAgICAgICBpZiAoIV9vcHRpb25zLnBvcHVwQW5jaG9yKSB7CiAgICAgICAgICAgIC8vIHNldCAocm91Z2hseSkgdG8gc2l6ZSBvZiBpY29uCiAgICAgICAgICAgIF9vcHRpb25zLnBvcHVwQW5jaG9yID0gKGZ1bmN0aW9uIChpX3NpemUpIHsKICAgICAgICAgICAgICAgIC8vIGNvcHkgYXJyYXkKICAgICAgICAgICAgICAgIGlfc2l6ZSA9IGlfc2l6ZS5zbGljZSgpOwogICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAvLyBpbnZlcnNlIGNvb3JkaW5hdGVzCiAgICAgICAgICAgICAgICBpX3NpemVbMF0gPSAwOwogICAgICAgICAgICAgICAgaV9zaXplWzFdICo9IC0xOwogICAgICAgICAgICAgICAgLy8gYm90dG9tIHBvc2l0aW9uIG9uIHBvcHVwIGlzIDdweAogICAgICAgICAgICAgICAgaV9zaXplWzFdIC09IDM7CiAgICAgICAgICAgICAgICByZXR1cm4gaV9zaXplOwogICAgICAgICAgICB9KShfb3B0aW9ucy5pY29uU2l6ZSB8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AogICAgICAgICdwb3B1cEFuY2hvcicKICAgIF07CiAgICB2YXIgZGVmYXVsdF9pY29uID0gTC5JY29uLkRlZmF1bHQucHJvdG90eXBlLm9wdGlvbnM7CiAgICBpZiAoX29wdGlvbnMuaWNvblVybCkgewogICAgICAgIC8vIGFycmF5cyBhcmUgc3RyaW5ncywgdW5mb3J0dW5hdGVseS4uLgogICAgICAgIGZvciAodmFyIGkgPSAwLCBsZW4gPSBpY29uQXJyYXlzLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgICAgIHZhciBvcHRpb25fbmFtZSA9IGljb25BcnJheXNbaV07CiAgICAgICAgICAgIHZhciBvcHRpb24gPSBfb3B0aW9uc1sgb3B0aW9uX25hbWUgXTsKICAgICAgICAgICAgLy8gY29udmVydCAiMSwyIiB0byBbMSwgMl07CiAgICAgICAgICAgIGlmIChvcHRpb24pIHsKICAgICAgICAgICAgICAgIHZhciBhcnIgPSBvcHRpb24uam9pbignJykuc3BsaXQoJywnKTsKICAgICAgICAgICAgICAgIC8vIGFycmF5Lm1hcCBmb3IgaWU8OQogICAgICAgICAgICAgICAgZm9yICh2YXIgaiA9IDAsIGxlbkogPSBhcnIubGVuZ3RoOyBqIDwgbGVuSjsgaisrKSB7CiAgICAgICAgICAgICAgICAgICAgYXJyW2pdID0gTnVtYmVyKGFycltqXSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBfb3B0aW9uc1sgb3B0aW9uX25hbWUgXSA9IGFycjsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICAvLyBkZWZhdWx0IHBvcHVwQW5jaG9yCiAgICAgICAgaWYgKCFfb3B0aW9ucy5wb3B1cEFuY2hvcikgewogICAgICAgICAgICAvLyBzZXQgKHJvdWdobHkpIHRvIHNpemUgb2YgaWNvbgogICAgICAgICAgICBfb3B0aW9ucy5wb3B1cEFuY2hvciA9IChmdW5jdGlvbiAoaV9zaXplKSB7CiAgICAgICAgICAgICAgICAvLyBjb3B5IGFycmF5CiAgICAgICAgICAgICAgICBpX3NpemUgPSBpX3NpemUuc2xpY2UoKTsKICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgLy8gaW52ZXJzZSBjb29yZGluYXRlcwogICAgICAgICAgICAgICAgaV9zaXplWzBdID0gMDsKICAgICAgICAgICAgICAgIGlfc2l6ZVsxXSAqPSAtMTsKICAgICAgICAgICAgICAgIC8vIGJvdHRvbSBwb3NpdGlvbiBvbiBwb3B1cCBpcyA3cHgKICAgICAgICAgICAgICAgIGlfc2l6ZVsxXSAtPSAzOwogICAgICAgICAgICAgICAgcmV0dXJuIGlfc2l6ZTsKICAgICAgICAgICAgfSkoX29wdGlvbnMuaWNvblNpemUgfHwgZGVmYXVsdF9pY29uLmljb25TaXplKTsKICAgICAgICB9CiAgICAgICAgX29wdGlvbnMuaWNvbiA9IG5ldyBMLkljb24oIF9vcHRpb25zICk7CiAgICB9CiAgICByZXR1cm4gX29wdGlvbnM7Cn0pKCk7CnZhciBtYXJrZXIgPSBMLm1hcmtlcigKICAgIFs1MC4yNjYxOTMyLDEwLjk2OTgyNzldLCAKICAgIG1hcmtlcl9vcHRpb25zCik7CnZhciBpc19pbWFnZSA9IG1hcC5pc19pbWFnZV9tYXA7CmlmIChtYXJrZXJfb3B0aW9ucy5kcmFnZ2FibGUpIHsKICAgIG1hcmtlci5vbignZHJhZ2VuZCcsIGZ1bmN0aW9uICgpIHsKICAgICAgICB2YXIgbGF0bG5nID0gdGhpcy5nZXRMYXRMbmcoKTsKICAgICAgICB2YXIgbGF0ID0gbGF0bG5nLmxhdDsKICAgICAgICB2YXIgbG5nID0gbGF0bG5nLmxuZzsKICAgICAgICBpZiAoaXNfaW1hZ2UpIHsKICAgICAgICAgICAgY29uc29sZS5sb2coJ2xlYWZsZXQtbWFya2VyIHk9JyArIGxhdCArICcgeD0nICsgbG5nKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjb25zb2xlLmxvZygnbGVhZmxldC1tYXJrZX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B7Imljb25VcmwiOiJcL3dwLWNvbnRlbnRcL3VwbG9hZHNcLzIwMTdcLzEwXC9tYXJrZXItZm13LXBoeXNpby5wbmciLCJpY29uU2l6ZSI6WyI1MSw1MSJdLCJpY29uQW5jaG9yIjpbIjI1LDUxIl19OwogICAgdmFyIGljb25BcnJheXMgPSBbCiAgICAgICAgJ2ljb25TaXplJywgCiAgICAgICAgJ2ljb25BbmNob3InLCAKICAgICAgICAnc2hhZG93U2l6ZScsIAogICAgICAgICdzaGFkb3dBbmNob3InLAogICAgICAgICdwb3B1cEFuY2hvcicKICAgIF07CiAgICB2YXIgZGVmYXVsdF9pY29uID0gTC5JY29uLkRlZmF1bHQucHJvdG90eXBlLm9wdGlvbnM7CiAgICBpZiAoX29wdGlvbnMuaWNvblVybCkgewogICAgICAgIC8vIGFycmF5cyBhcmUgc3RyaW5ncywgdW5mb3J0dW5hdGVseS4uLgogICAgICAgIGZvciAodmFyIGkgPSAwLCBsZW4gPSBpY29uQXJyYXlzLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgICAgIHZhciBvcHRpb25fbmFtZSA9IGljb25BcnJheXNbaV07CiAgICAgICAgICAgIHZhciBvcHRpb24gPSBfb3B0aW9uc1sgb3B0aW9uX25hbWUgXTsKICAgICAgICAgICAgLy8gY29udmVydCAiMSwyIiB0byBbMSwgMl07CiAgICAgICAgICAgIGlmIChvcHRpb24pIHsKICAgICAgICAgICAgICAgIHZhciBhcnIgPSBvcHRpb24uam9pbignJykuc3BsaXQoJywnKTsKICAgICAgICAgICAgICAgIC8vIGFycmF5Lm1hcCBmb3IgaWU8OQogICAgICAgICAgICAgICAgZm9yICh2YXIgaiA9IDAsIGxlbkogPSBhcnIubGVuZ3RoOyBqIDwgbGVuSjsgaisrKSB7CiAgICAgICAgICAgICAgICAgICAgYXJyW2pdID0gTnVtYmVyKGFycltqXSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBfb3B0aW9uc1sgb3B0aW9uX25hbWUgXSA9IGFycjsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICAvLyBkZWZhdWx0IHBvcHVwQW5jaG9yCiAgICAgICAgaWYgKCFfb3B0aW9ucy5wb3B1cEFuY2hvcikgewogICAgICAgICAgICAvLyBzZXQgKHJvdWdobHkpIHRvIHNpemUgb2YgaWNvbgogICAgICAgICAgICBfb3B0aW9ucy5wb3B1cEFuY2hvciA9IChmdW5jdGlvbiAoaV9zaXplKSB7CiAgICAgICAgICAgICAgICAvLyBjb3B5IGFycmF5CiAgICAgICAgICAgICAgICBpX3NpemUgPSBpX3NpemUuc2xpY2UoKTsKICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgLy8gaW52ZXJzZSBjb29yZGluYXRlcwogICAgICAgICAgICAgICAgaV9zaXplWzBdID0gMDsKICAgICAgICAgICAgICAgIGlfc2l6ZVsxXSAqPSAtMTsKICAgICAgICAgICAgICAgIC8vIGJvdHRvbSBwb3NpdGlvbiBvbiBwb3B1cCBpcyA3cHgKICAgICAgICAgICAgICAgIGlfc2l6ZVsxXSAtPSAzOwogICAgICAgICAgICAgICAgcmV0dXJuIGlfc2l6ZTsKICAgICAgICAgICAgfSkoX29wdGlvbnMuaWNvblNpemUgfHwgZGVmYXVsdF9pY29uLmljb25TaXplKTsKICAgICAgICB9CiAgICAgICAgX29wdGlvbnMuaWNvbiA9IG5ldyBMLkljb24oIF9vcHRpb25zICk7CiAgICB9CiAgICByZXR1cm4gX29wdGlvbnM7Cn0pKCk7CnZhciBtYXJrZXIgPSBMLm1hcmtlcigKICAgIFs1MC4yMTc3NDgxLDExLjE0MTU5NThdLCAKICAgIG1hcmtlcl9vcHRpb25zCik7CnZhciBpc19pbWFnZSA9IG1hcC5pc19pbWFnZV9tYXA7CmlmIChtYXJrZXJfb3B0aW9ucy5kcmFnZ2FibGUpIHsKICAgIG1hcmtlci5vbignZHJhZ2VuZCcsIGZ1bmN0aW9uICgpIHsKICAgICAgICB2YXIgbGF0bG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