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rK10gPSBLRVJORUxET0M7CisJdmVjW2lkeCsrXSA9IERPQ0JPT0s7CisKKyAgICAgICAgLyogU3BsaXQgbGluZSB1cCBpbiBpbmRpdmlkdWFsIHBhcmFtZXRlcnMgcHJlY2VlZGVkIGJ5IEZVTkNUSU9OICovCisgICAgICAgIGZvciAoaT0wOyBsaW5lW2ldOyBpKyspIHsKKyAgICAgICAgICAgICAgICBpZiAoaXNzcGFjZShsaW5lW2ldKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgbGluZVtpXSA9ICdcMCc7CisgICAgICAgICAgICAgICAgICAgICAgICBzdGFydG9mc3ltID0gMTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBpZiAoc3RhcnRvZnN5bSkgeworICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRvZnN5bSA9IDA7CisgICAgICAgICAgICAgICAgICAgICAgICB2ZWNbaWR4KytdID0gRlVOQ1RJT047CisgICAgICAgICAgICAgICAgICAgICAgICB2ZWNbaWR4KytdID0gJmxpbmVbaV07CisgICAgICAgICAgICAgICAgfQorICAgICAgICB9CisJdmVjW2lkeCsrXSA9IGZpbGVuYW1lOworCXZlY1tpZHhdID0gTlVMTDsKKwlleGVjX2tlcm5lbF9kb2ModmVjKTsKK30KKworLyoKKyAqIFBhcnNlIGZpbGUsIGNhbGxpbmcgYWN0aW9uIHNwZWNpZmljIGZ1bmN0aW9ucyBmb3I6CisgKiAxKSBMaW5lcyBjb250YWluaW5nICFFCisgKiAyKSBMaW5lcyBjb250YWluaW5nICFJCisgKiAzKSBMaW5lcyBjb250YWluaW5nICFECisgKiA0KSBMaW5lcyBjb250YWluaW5nICFGCisgKiA1KSBEZWZhdWx0IGxpbmVzIC0gbGluZXMgbm90IG1hdGNoaW5nIHRoZSBhYm92ZQorICovCit2b2lkIHBhcnNlX2ZpbGUoRklMRSAqaW5maWxlKQoreworCWNoYXIgbGluZVtNQVhMSU5FU1pdOworCWNoYXIgKiBzOworCXdoaWxlKGZnZXRzKGxpbmUsIE1BWExJTkVTWiwgaW5maWxlKSkgeworCQlpZiAobGluZVswXSA9PSAnIScpIHsKKwkJCXMgPSBsaW5lICsgMjsKKwkJCXN3aXRjaCAobGluZVsxXSkgeworCQkJCWNhc2UgJ0UnOgorCQkJCQl3aGlsZSAoKnMgJiYgIWlzc3BhY2UoKnMpKSBzKys7CisJCQkJCSpzID0gJ1wwJzsKKwkJCQkJZXh0ZXJuYWxmdW5jdGlvbnMobGluZSsyKTsKKwkJCQkJYnJlYWs7CisJCQkJY2FzZSAnSSc6CisJCQkJCXdoaWxlICgqcyAmJiAhaXNzcGFjZSgqcykpIHMrKzsKKwkJCQkJKnMgPSAnXDAnOworCQkJCQlpbnRlcm5hbGZ1bmN0aW9ucyhsaW5lKzIpOworCQkJCQlicmVhazsKKwkJCQljYXNlICdEJzoKKwkJCQkJd2hpbGUgKCpzICYmICFpc3NwYWNlKCpzKSkgcysrOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICpzID0gJ1wwJzsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzeW1ib2xzb25seShsaW5lKzIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworCQkJCWNhc2UgJ0YnOgorCQkJCQkvKiBmaWxlbmFtZSAqLworCQkJCQl3aGlsZSAoKnMgJiYgIWlzc3BhY2UoKnMpKSBzKys7CisJCQkJCSpzKysgPSAnXDAnOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qIGZ1bmN0aW9uIG5hbWVzICovCisJCQkJCXdoaWxlIChpc3NwYWNlKCpzKSkKKwkJCQkJCXMrKzsKKwkJCQkJc2luZ2xlZnVuY3Rpb25zKGxpbmUgKzIsIHMpOworCQkJCQlicmVhazsKKwkJCQlkZWZhdWx0OgorCQkJCQlkZWZhdWx0bGluZShsaW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