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gICBPU19GTEFTSF9BTVRfQ09NTV9ST19HQkRBVEFfU0laRSAgICAgICAgfSwKK307CisKK1NJTlQzMiBHZXRCaXRPZmZzZXQoU0lOVDMyIHRlc3RJdGVtKQoreworICAgIHJldHVybiAyICogKDMgLSAodGVzdEl0ZW0gJSA0KSk7Cit9CisKKy8qKgorICogQGJyaWVmINC0bnZybworICogQHBhcmFtIGR3U3RhcnQgbnbG8Mq8tdjWt8ar0sYsMCB+IDJNLTEgYnl0ZXMKKyAqIEBwYXJhbSBkd0xlbiBudrOktsgsMSB+IDJNIGJ5dGVzCisgKiBAcGFyYW0gZnJvbSC0/dC0yOu1xMr9vt0KKyAqIEByZXR1cm4gMCCzybmmICAKKyAqIEByZXR1cm4gLTEgyqew3AorICogQG5vdGUgICAKKyAqIEB3YXJuaW5nIAorICovCit1bnNpZ25lZCBpbnQgYW10X252cm9fd3JpdGUodW5zaWduZWQgaW50IGR3U3RhcnQsIHVuc2lnbmVkIGludCBkd0xlbiwgdW5zaWduZWQgY2hhciAqZnJvbSkKK3sKKyAgICBVSU5UMzIgIHJldENvZGUgPSBDUE5WX0VSUk9SOworCisgICAgLyrV4sDvytfPyLX308PH/bavvdO/2rfFv6q21Na7tsHH+NPy0LSy2df3tcTP3tbGKi8KKwkvKmFtdMSjyr3PwqOsenRlX2FtdNOm08PG8MC01q6689LRvq250rPJv8nQtLXEwcsqLworCWlmKCFpc19hbXRfbW9kZSgpKSAKKwl7CisJICAgIHJldENvZGUgPSBjcG52X0NoYW5nZUZzUGFydGl0aW9uQXR0cihGU19OVlJPRlMsIDEpOworCSAgICBpZihDUE5WX09LICE9IHJldENvZGUpCisJICAgIHsKKwkgICAgICAgIHJldHVybiByZXRDb2RlOworCSAgICB9CisJfQorCisgICAgcmV0Q29kZSA9IGNwbnZfTnZJdGVtV3JpdGVOdnJvKGR3U3RhcnQsIGZyb20sIGR3TGVuKTsKKyAgICBpZihDUE5WX09LICE9IHJldENvZGUpCisgICAgeworICAgICAgICByZXR1c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ICAgCisgICAgaWYocmV0ID09ICBDUE5WX0VSUk9SKQorICAgIHsKKyAgICAgICAgcmV0dXJuIC0xOworICAgIH0KKyAgICBlbHNlCisgICAgeworICAgICAgICByZXR1cm4gMDsKKyAgICB9CisKK30KKworLyoqCisgKiBAYnJpZWYg0LTSu8/uTlZST8r9vt0KKyAqIEBwYXJhbSBudlBhcmFtILjDTlbP7sDg0M0KKyAqIEBwYXJhbSBOdkl0ZW1EYXRhILT90LTI68r9vt21xLXY1rcKKyAqIEBwYXJhbSBOdkl0ZW1MZW4gyv2+3bOktsgKKyAqIEByZXR1cm4gMCCzybmmICAKKyAqIEByZXR1cm4gLTEgyqew3AorICogQG5vdGUgICAKKyAqIEB3YXJuaW5nIAorICovCitpbnQgIGFtdF93cml0ZV9udl9pdGVtKE52UGFyYW1fQU1UIG52UGFyYW0sIFVJTlQ4ICpOdkl0ZW1EYXRhLCBVSU5UMzIgTnZJdGVtTGVuKQoreworICAgIFVJTlQzMiAgcmV0Q29kZSA9IENQTlZfRVJST1I7CisgICAgVUlOVDMyICBpID0gMDsKKworICAgIGlmIChudlBhcmFtID49IE1BWEFCTlZQQVJBTV9OVlBBUkFNIHx8IE5VTEwgPT0gTnZJdGVtRGF0YSB8fCBOdkl0ZW1MZW4gPT0gMCkKKyAgICB7CisgICAgICAgIHJldHVybiAgLTE7CisgICAgfQorCisgICAgZm9yIChpID0gMDsgaSA8IChzaXplb2YoZ19hbXRDb21tTnZDZmcpIC8gc2l6ZW9mIChnX2FtdENvbW1OdkNmZ1swXSkpOyBpKyspCisgICAgeworICAgICAgICBpZiAoIG52UGFyYW0gPT0gZ19hbXRDb21tTnZDZmdbaV0uZHdNc2dJRCApCisgICAgICAgIHsKKyAgICAgICAgICAgIGlmIChOdkl0ZW1MZW4gPiBnX2FtdENvbW1OdkNmZ1tpXS5kd1NpemUpCisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgTnZJdGVtTGVuID0gZ19hbXRDb21tTnZDZmdbaV0uZHdTaXplOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICByZXRDb2RlID0gYW10X252cm9fd3JpdGUoZ19hbXRDb21tTnZDZmdbaV0uZHdBZGRyZXNzLCBOdkl0ZW1MZW4sIE52SXRlbURhdGEpOworCisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgIH0KKyAgICAgICAgICAgIAorICAgIGlmIChyZXRDb2RlICE9IENQTlZfT0spCisgICAgeworICAgICAgICBhc3NlcnQoMCk7CisgICAgfQorICAgIHJldHVybiAgMDsKK30KKworLyoqCisgKiBAYnJpZWYgtsGz9tK7z+5OVlJPyv2+3QorICogQHBhcmFtIG52UGFyYW0gILjDTlbP7sDg0M0KKyAqIEBwYXJhbSBOdkl0ZW1EYXRhILbBs/a1xMr9vt0KKyAqIEBwYXJhbSBOdkl0ZW1MZW4gIMr9vt2zpLbICisgKiBAcmV0dXJuIDAgs8m5piAgCisgKiBAcmV0dXJuIC0xIMqnsNwKKyAqIEBub3RlICAgCisgKiBAd2FybmluZyAKKyAqLworaW50IGFtdF9yZWFkX252X2l0ZW0oTnZQYXJhbV9BTVQgbnZQYXJhbSxVSU5UOCAqTnZJdGVtRGF0YSwgVUlOVDMyIE52SXRlbUxlbikKK3sKKyAgICBVSU5UMzIgIHJldENvZGUgPSBDUE5WX0VSUk9SOworICAgIFVJTlQzMiAgaSA9IDA7CisKKyAgICAvLyAgek9zc19QcmludGYoMHg3ZiwgMHgyLCJbelBTX052QU1USXRlbVJlYWRdbnZQYXJhbSBpcyAlZCBhbmQgTnZJdGVtTGVuIGlzICVkXG4iLG52UGFyYW0sTnZJdGVtTGVuKTsKKyAgICBpZiAobnZQYXJhbSA+PSBNQVhBQk5WUEFSQU1fTlZQQVJBTSB8fCBOVUxMID09IE52SXRlbURhdGEgfHwgTnZJdGVtTGVuID09IDApCisgICAgeworICAgICAgICByZXR1cm4gIC0xOworICAgIH0KKworICAgLyogaWYgKEFCQkFOREJJVE1BUF9OVlBBUkFNID09IG52UGFyYW0pCisgICAgeworICAgICAgICBCWVRFIGJhbmRfYml0X21hcF9mbGFnID0gMDsKKyAgICAgICAgelBTX052QU1GbGFnc1RJdGVtUmVhZChCQU5EX0JJVF9NQVBfRkxBRywgJmJhbmRfYml0X21hcF9mbGFnKTsKKworICAgICAgICBpZiAoYmFuZF9iaXRfbWFwX2ZsYWcgIT0gJzEnKQorICAgICAgICB7CisgICAgICAgICAgICByZXRDb2RlID0gelBzX052Q2hlY2tCYW5kQml0bWFwKE52SXRlbURhdGEsIE52SXRlbUxlbik7CisKKyAgICAgICAgICAgIHJldHVybiByZXRDb2RlOworICAgICAgICB9CisgICAgfSovCisgICAgZm9yIChpID0gMDsgaSA8IChzaXplb2YoZ19hbXRDb21tTnZDZmcpIC8gc2l6ZW9mIChnX2FtdENvbW1OdkNmZ1swXSkpOyBpKyspCisgICAgeworICAgICAgICBpZiAoIG52UGFyYW0gPT0gZ19hbXRDb21tTnZDZmdbaV0uZHdNc2dJRCApCisgICAgICAgIHsKKyAgICAgICAgICAgIGlmIChOdkl0ZW1MZW4gPiBnX2FtdENvbW1OdkNmZ1tpXS5kd1NpemUpCisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgTnZJdGVtTGVuID0gZ19hbXRDb21tTnZDZmdbaV0uZHdTaXplOworICAgICAgICAgICAgfQorICAgICAgICAgICAgcmV0Q29kZSA9IGNwbnZfTnZJdGVtUmVhZChnX2FtdENvbW1OdkNmZ1tpXS5kd0FkZHJlc3MsIE52SXRlbURhdGEsIE52SXRlbUxlbik7CisgICAgICAgICAgICBicmVhazsgICAgICAgIAorICAgICAgICB9CisgICAgfQorICAgIGlmKHJldENvZGUgPT0gQ1BOVl9FUlJPUikKKyAgICB7CisgICAgICAgICByZXR1cm4gIC0xOworICAgIH0KKyAgICBlbHNlCisgICAgeworICAgICAgICAgcmV0dXJuICAwOworICAgIH0KK30KKworLyoqCisgKiBAYnJpZWYg0LTJ+rL6suLK1LHq1r7OuworICogQHBhcmFtIG52UGFyYW0g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CisgKiBAcGFyYW0gZHdTdGFydCBudsbwyry12Na3xqvSxiwwIH4gMTAyMworICogQHBhcmFtIGR3TGVuIG52s6S2yCwxIH4gMTAyNCBieXRlcworICogQHBhcmFtIGZyb20gtsGz9rXEyv2+3QorICogQHJldHVybiAwILPJuaYgIAorICogQHJldHVybiAtMSDKp7DcCisgKiBAbm90ZSAgIAorICogQHdhcm5pbmcgCisgKi8KK2ludCBhbXRfbnZyb191c2VyX3JlYWQoVUlOVDMyIGR3U3RhcnQsIFVJTlQzMiBkd0xlbiwgVUlOVDgqIHRvKQoreworICAgIHVuc2lnbmVkIGludCByZXQgPSBDUE5WX0VSUk9SOworICAgIAorICAgIGlmIChkd1N0YXJ0ID49IE9TX0ZMQVNIX0FNVF9DT01NX1JPX1VTRVJfREVGSU5FX1NJWkUgfHwgZHdMZW4gPiBPU19GTEFTSF9BTVRfQ09NTV9ST19VU0VSX0RFRklORV9TSVpFIHx8IChkd1N0YXJ0ICsgZHdMZW4pID4gT1NfRkxBU0hfQU1UX0NPTU1fUk9fVVNFUl9ERUZJTkVfU0laRSkKKyAgICB7CisgICAgICAgIHJldHVybiAtMTsKKyAgICB9CisgICAgCisgICAgcmV0ID0gY3Budl9Odkl0ZW1SZWFkKGR3U3RhcnQgKyBPU19GTEFTSF9BTVRfQ09NTV9ST19VU0VSX0RFRklORV9BRERSRVNTLCB0byxkd0xlbik7CisgICAgCisgICAgaWYocmV0ID09ICBDUE5WX0VSUk9SKQorICAgIHsKKyAgICAgICAgcmV0dXJuIC0xOworICAgIH0KKyAgICBlbHNlCisgICAgeworICAgICAgICByZXR1cm4gMDsKKyAgICB9Cit9CisKKy8qKgorICogQGJyaWVmIE5WUk+yzr+8yei8xtfUtqjS5cf40/LQtLqvyv0KKyAqIEBwYXJhbSBkd1N0YXJ0IG52xvDKvLXY1rfGq9LGLDAgfiAxMDIzCisgKiBAcGFyYW0gZHdMZW4gbnazpLbILDEgfiAxMDI0IGJ5dGVzCisgKiBAcGFyYW0gZ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CBhbXRfbnZyb19yZWZfcmVhZChVSU5UMzIgZHdTdGFydCwgVUlOVDMyIGR3TGVuLCBVSU5UOCogdG8pCit7CisgICAgdW5zaWduZWQgaW50ICByZXQgPSBDUE5WX0VSUk9SOworICAgIAorICAgIGlmIChkd1N0YXJ0ID49IE9TX0ZMQVNIX0FNVF9DT01NX1JPX1JFRl9ERUZJTkVfU0laRSB8fCBkd0xlbiA+IE9TX0ZMQVNIX0FNVF9DT01NX1JPX1JFRl9ERUZJTkVfU0laRSB8fCAoZHdTdGFydCArIGR3TGVuKSA+IE9TX0ZMQVNIX0FNVF9DT01NX1JPX1JFRl9ERUZJTkVfU0laRSkKKyAgICB7CisgICAgICAgIHJldHVybiAtMTsKKyAgICB9CisgICAgCisgICAgcmV0ID0gY3Budl9Odkl0ZW1SZWFkKGR3U3RhcnQgKyBPU19GTEFTSF9BTVRfQ09NTV9ST19SRUZfREVGSU5FX0FERFJFU1MsIHRvLGR3TGVuKTsKKyAgICAKKyAgICBpZihyZXQgPT0gIENQTlZfRVJST1IpCisgICAgeworICAgICAgICByZXR1cm4gLTE7CisgICAgfQorICAgIGVsc2UKKyAgICB7CisgICAgICAgIHJldHVybiAwOworICAgIH0KK30KKworCisgLyoqCisgKiBAYnJpZWYg06bTw7LjxdC2z7Wxx7DKx7fxysdhbXTEo8q9CisgKiBAcGFyYW0gCisgKiBAcmV0dXJuIDEgYW10xKPKvQorICogQHJldHVybiAwIG5vcm1hbMSjyr0KKyAqIEBub3RlICAgCisgKiBAd2FybmluZyAKKyAqLworaW50IGlzX2FtdF9tb2RlKHZvaWQpCit7CisgICAgY2hhciB2ZXJNb2RlWzRdID0gezB9OworICAgIGludCByZXQgPSAwOworCisgICAgcmV0ID0gc2NfY2ZnX2dldCgidmVyX21vZGUiLCB2ZXJNb2RlLCBzaXplb2YodmVyTW9kZSkpOworICAgIGlmKCFzdHJuY21wKHZlck1vZGUsICIwIiwgc3RybGVuKCIwIikpKQorICAgIHsKKyAgICAgICAgcmV0ID0gMTsKKyAgICB9CisgICAgZWxzZQorICAgIHsKKyAgICAgICAgcmV0ID0gMDsKKyAgICB9CisJCisJcmV0dXJuIHJldDsKK30KKworLyoqCisgKiBAYnJpZWYgyejWw2Jvb3TG9LavxKPKvQorICogQHBhcmFtIGJvb3Rtb2RlIDK49tfWvdq1xLHqyrY6IAorICogICAgICAgICAgICAgIHsweDU0LDB4MDB9IDogdXNlciwKKyAqICAgICAgICAgICAgICB7MHg1NCwweDAxfSA6IGRlYnVnLAorICogICAgICAgICAgICAgIHsweDU0LDB4MDJ9IDogZmFjdG9yeSwKKyAqICAgICAgICAgICAgICB7MHg1NCwweDREfSA6IGFtdCwKKyAqIEByZXR1cm4gMCCzybmmICAKKyAqIEByZXR1cm4gLTEgyqew3AorICogQG5vdGUgICAKKyAqIEB3YXJuaW5nIAorICovCit1bnNpZ25lZCBpbnQgYW10X3NldF9ib290bW9kZSh1bnNpZ25lZCBjaGFyICBib290bW9kZVtdKQoreworICAgIHVuc2lnbmVkIGludCAgcmV0ID0gQ1BOVl9PSzsKKworICAgIGlmKENQTlZfRVJST1IgPT0gY3Budl9DaGFuZ2VGc1BhcnRpdGlvbkF0dHIoRlNfSU1BR0VGUywgMSkpCisgICAgeworICAgICAgICBwcmludGYoImNwbnZfQ2hhbmdlRnNQYXJ0aXRpb25BdHRyIGZhaWxlZFxyXG4iKTsKKyAgICAgICAgcmV0dXJuIC0xOworICAgIH0KKyAgICByZXQgPSBjcG52X052SXRlbVdyaXRlKE9TX0ZMQVNIX1RTUF9SV19OT05GQUNfT0ZGU0VUX0ZST01fTlYsIGJvb3Rtb2RlLCAyKTsKKyAgICBpZihDUE5WX0VSUk9SID09IHJldCkKKyAgICB7CisgICAgICAgIHByaW50ZigiY3Budl9Odkl0ZW1Xcml0ZSBib290bW9kZSBmYWlsICFcbiIpOworICAgICAgICByZXR1cm4gcmV0OworICAgIH0KKyAgICAKKyAgICBjcG52X052SXRlbVdyaXRlRmFjdG9yeShPU19GTEFTSF9UU1BfUldfTk9ORkFDX09GRlNFVF9GUk9NX05WLCBib290bW9kZSwgMik7CisgICAgcmV0ID0gY3Budl9OdnJhbUZsdXNoKCk7CisgICAgaWYoQ1BOVl9FUlJPUiA9PSByZXQpCisgICAgeworICAgICAgICBwcmludGYoImNwbnZfTnZyYW1GbHVzaCBib290bW9kZSBmYWlsICFcbiIpOworICAgIH0KKyAgICAKKyAgICBjcG52X0ZzR2NXYWl0KEZTX0lNQUdFRlMpOworICAgIGlmKENQTlZfRVJST1IgPT0gY3Budl9DaGFuZ2VGc1BhcnRpdGlvbkF0dHIoRlNfSU1BR0VGUywgMCkpCisgICAgeworICAgICAgICBwcmludGYoImNwbnZfQ2hhbmdlRnNQYXJ0aXRpb25BdHRyIGZhaWxlZFxyXG4iKTsKKyAgICAgICAgcmV0dXJuIC0xOworICAgIH0KKworICAgIHJldHVybiByZXQ7Cit9CisKK3Vuc2lnbmVkIGludCBhbXRfc2V0X2JhdGRldF9mbGFnKGludCBiYXRkZXRfdmFsdWUpCit7CisJdW5zaWduZWQgaW50ICByZXQgPSBDUE5WX09LOworCisgICAgaWYoQ1BOVl9FUlJPUiA9PSBjcG52X0NoYW5nZUZzUGFydGl0aW9uQXR0cihGU19JTUFHRUZTLCAxKSkKKyAgICB7CisgICAgICAgIHByaW50ZigiY3Budl9DaGFuZ2VGc1BhcnRpdGlvbkF0dHIgZmFpbGVkXHJcbiIpOworICAgICAgICByZXR1cm4gLTE7CisgICAgfQorICAgIHJldCA9IGNwbnZfTnZJdGVtV3JpdGUoRFJWX1BFUklfTlZfQUREUiwodW5zaWduZWQgY2hhciopJmJhdGRldF92YWx1ZSwxKTsKKyAgICBpZihDUE5WX0VSUk9SID09IHJldCkKKyAgICB7CisgICAgICAgIHByaW50ZigiY3Budl9Odkl0ZW1Xcml0ZSBiYXRkZXRfdmFsdWUgZmFpbCAhXG4iKTsKKyAgICAgICAgcmV0dXJuIHJldDsKKyAgICB9CisgICAgCisgICAgY3Budl9Odkl0ZW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bmdlRnNQYXJ0aXRpb25BdHRyIGZhaWxlZFxyXG4iKTsKKyAgICAgICAgcmV0dXJuIC0xOworICAgIH0KKyAgICByZXQgPSBjcG52X052SXRlbVdyaXRlKE9TX0ZMQVNIX1RTUF9SV19OT05GQUNfT0ZGU0VUX0ZST01fTlYsIGJvb3Rtb2RlLCAyKTsKKyAgICBpZihDUE5WX0VSUk9SID09IHJldCkKKyAgICB7CisgICAgICAgIHByaW50ZigiY3Budl9Odkl0ZW1Xcml0ZSBib290bW9kZSBmYWlsICFcbiIpOworICAgICAgICByZXR1cm4gcmV0OworICAgIH0KKyAgICBjcG52X052SXRlbVdyaXRlRmFjdG9yeShPU19GTEFTSF9UU1BfUldfTk9ORkFDX09GRlNFVF9GUk9NX05WLCBib290bW9kZSwgMik7CisJCisgICAgcmV0ID0gY3Budl9Odkl0ZW1Xcml0ZShPU19GTEFTSF9UU1BfUldfTk9ORkFDX0FUX01PREVfQUREUiwgYXRtb2RlLCAyKTsKKyAgICBpZihDUE5WX0VSUk9SID09IHJldCkKKyAgICB7CisgICAgICAgIHByaW50ZigiY3Budl9Odkl0ZW1Xcml0ZSBhdCBtb2RlIGZhaWwgIVxuIik7CisgICAgICAgIHJldHVybiByZXQ7CisgICAgfQorICAgIGNwbnZfTnZJdGVtV3JpdGVGYWN0b3J5KE9TX0ZMQVNIX1RTUF9SV19OT05GQUNfQVRfTU9ERV9BRERSLCBhdG1vZGUsIDIpOworICAgIHJldCA9IGNwbnZfTnZyYW1GbHVzaCgpOworICAgIGlmKENQTlZfRVJST1IgPT0gcmV0KQorICAgIHsKKyAgICAgICAgcHJpbnRmKCJjcG52X052cmFtRmx1c2ggZmFpbCAhXG4iKTsKKyAgICB9CisgICAgCisgICAgY3Budl9Gc0djV2FpdChGU19JTUFHRUZTKTsKKyAgICBpZihDUE5WX0VSUk9SID09IGNwbnZfQ2hhbmdlRnNQYXJ0aXRpb25BdHRyKEZTX0lNQUdFRlMsIDApKQorICAgIHsKKyAgICAgICAgcHJpbnRmKCJjcG52X0NoYW5nZUZzUGFydGl0aW9uQXR0ciBmYWlsZWRcclxuIik7CisgICAgICAgIHJldHVybiAtMTsKKyAgICB9CisKKyAgICByZXR1cm4gcmV0OworCit9CisKK3Vuc2lnbmVkIGludCBpc19hbXRfYXRtb2RlKCkKK3sKKwl1bnNpZ25lZCBpbnQgIHJldCA9IENQTlZfT0s7CisJdW5zaWduZWQgY2hhciAgbW9kZVs0XSA9IHswfTsKKworICAgIHJldCA9IGNwbnZfTnZJdGVtUmVhZChPU19GTEFTSF9UU1BfUldfTk9ORkFDX0JBU0VfQUREUiwgbW9kZSwgMik7CisgICAgaWYoQ1BOVl9FUlJPUiA9PSByZXQpCisgICAgeworICAgICAgICBwcmludGYoImNwbnZfTnZJdGVtUmVhZCBhdCBtb2RlIGZhaWwgIVxuIik7CisgICAgICAgIHJldHVybiByZXQ7CisgICAgfQorCQorCXJldCA9IGNwbnZfTnZJdGVtUmVhZChPU19GTEFTSF9UU1BfUldfTk9ORkFDX0FUX01PREVfQUREUiwgbW9kZSsyLCAyKTsKKyAgICBpZihDUE5WX0VSUk9SID09IHJldCkKKyAgICB7CisgICAgICAgIHByaW50ZigiY3Budl9Odkl0ZW1SZWFkIGF0IG1vZGUgZmFpbCAhXG4iKTsKKyAgICAgICAgcmV0dXJuIHJldDsKKyAgICB9CisKKwlwcmludGYoIm1vZGVbMF0gPSAleCxtb2RlWzFdID0gJXgsbW9kZVsyXSA9ICV4LG1vZGVbM10gPSAleCFcbiIsbW9kZVswXSxtb2RlWzFdLG1vZGVbMl0sbW9kZVszXSk7CisKKwlpZigobW9kZVswXSA9PSAweDU0KSYmKG1vZGVbMV0gPT0gMHg0RCkmJihtb2RlWzJdID09IDB4NDEpJiYobW9kZVszXSA9PSAweDU0KSkKKwl7CisJICAgIHByaW50ZigibW9kZSA9IDFcbiIpOworCQlyZXR1cm4gMTsKKwl9CisJZWxzZQorCXsKKwkgICAgcHJpbnRmKCJtb2RlID0gMFxuIik7CisJCXJldHVybiAwOworCX0KKworfQorCisKKworCisK