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aXplOiBmdW5jdGlvbihoYW5kbGVyLCBzY2hlbWEsIHByZWZpeCkgewogICAgdmFyIHN0eWxlcyA9IHsKICAgICAgICBmaWVsZDogImJvcmRlci1zdHlsZTogc29saWQ7IGJvcmRlci13aWR0aDogMXB4OyBiYWNrZ3JvdW5kLWNvbG9yOiAjZmZmZmZmIiwKICAgICAgICBidXR0b246ICJib3JkZXItc3R5bGU6IHNvbGlkOyBib3JkZXItd2lkdGg6IDFweDsgYmFja2dyb3VuZC1jb2xvcjogI2RjZGNkYzsgcGFkZGluZzogNHB4OyBjdXJzb3I6IHBvaW50ZXIiCiAgICB9OwogICAgdmFyIGludm9rZSA9IGhhbmRsZXIubmFtZSArICIuY2FsY3VsYXRlKFwiIiArIHByZWZpeCArICJcIikiOwogICAgdmFyIGZpZWxkcyA9IHNjaGVtYS5maWVsZHM7CgogICAgdmFyIHRhYmxlID0KICAgICAgICAgICI8dGFibGUgaWQ9JyIgKyBwcmVmaXggKyAidGFibGUnIGNsYXNzPSd3aWtpdGFibGUnPjx0Ym9keT4iCiAgICAgICAgKyAiPHRyPiI7CiAgICBmaWVsZHMuZm9yRWFjaChmdW5jdGlvbihmaWVsZCkgewogICAgICBpZiAoImluaXQiIGluIGZpZWxkKSB7CiAgICAgICAgdmFyIGluaXQgPSBmaWVsZC5mb3JtYXQucmVwbGFjZSgie30iLCBmaWVsZC5pbml0KTsKICAgICAgICB0YWJsZSArPQogICAgICAgICAgICAgICI8dGQ+IgogICAgICAgICAgICArICI8bGFiZWwgZm9yPSciICsgcHJlZml4ICsgZmllbGQuaWQgKyAiJz4iICsgZmllbGQubGFiZWwgKyAiIDwvbGFiZWw+IgogICAgICAgICAgICArICI8aW5wdXQgdHlwZT0ndGV4dCcgc3R5bGU9JyIgKyBzdHlsZXMuZmllbGQgKyAiJyBzaXplPSc2JyBpZD0nIiArIHByZWZpeCArIGZpZWxkLmlkICsgIiciCiAgICAgICAgICAgICsgIiB2YWx1ZT0nIiArIGluaXQgKyAiJyBvbmNoYW5nZT0nIiArIGludm9rZSArICInPiIKICAgICAgICAgICAgKyAiPC90ZD4iOwogICAgICB9CiAgICB9KTsKICAgIHZhciBmaWVsZCA9IGZpZWxkc1tmaWVsZHMubGVuZ3RoIC0gMV07CiAgICB0YWJsZSArPQogICAgICAgICAgIjwvdHI+PHRyPiIKICAgICAgICArICI8dGQ+PGJ1dHRvbiB0eXBlPSdidXR0b24nIHN0eWxlPSciICsgc3R5bGVzLmJ1dHRvbiArICInIGlkPSciICsgcHJlZml4ICsgIiNidXR0b24nIgogICAgICAgICsgIiBvbmNsaWNrPSciICsgaW52b2tlICsgIic+Q2FsY3VsYXRlPC9idXR0b24+PC90ZD4iCiAgICAgICAgKyAiPHRkPiIKICAgICAgICArICI8bGFiZWwgZm9yPSciICsgcHJlZml4ICsgZmllbGQuaWQgKyAiJz4iICsgZmllbGQubGFiZWwgKyAiIDwvbGFiZWw+IgogICAgICAgICsgIjxpbnB1dCB0eXBlPSd0ZXh0JyBzdHlsZT0nIiArIHN0eWxlcy5maWVsZCArICInIHNpemU9JzYnIGlkPSciICsgcHJlZml4ICsgZmllbGQuaWQgKyAiJyByZWFkb25seT4iCiAgICAgICAgKyAiPC90ZD4iCiAgICAgICAgKyAiPC90cj4iCiAgICAgICAgKyAiPC90Ym9keT48L3RhYmxlPiI7CiAgICBpZiAoImxvZyIgaW4gYmhfLmNhbGNfdjEgJiYgYmhfLmNhbGNfdjEubG9nKSBjb25zb2xlLmxvZyh0YWJsZSk7CiAgICByZXR1cm4gdGFibGU7CiAgfSwKCiAgY2FsY3VsYXRlOiBmdW5jdGlvbihwcmVmaXgpIHsKICAgIHZhciBzY2hlbWEgPSBiaF8uY2FsY19nbG9iYWxbcHJlZml4XTsKICAgIHZhciBmaWVsZHMgPSBzY2hlbWEuZmllbGRzOwoKICAgIHZhciBnZXRfdmFsdWVzID0gZnVuY3Rpb24oKSB7CiAgICAgIHZhciB2YWx1ZXMgPSB7fTsKICAgICAgZmllbGRzLmZvckVh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