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fCAwIHwgMCB8IDEgfCAxIHwgUk5EICAgICAgfCBSb3VuZCB0byBpbnRlZ2VyICAgICAgfCBGZCA6PSBpbnQoRm0pICAgICAgICAgfAorfCAwIHwgMSB8IDAgfCAwIHwgU1FUICAgICAgfCBTcXVhcmUgcm9vdCAgICAgICAgICAgfCBGZCA6PSBzcXJ0KEZtKSAgICAgICAgfAorfCAwIHwgMSB8IDAgfCAxIHwgTE9HICAgICAgfCBMb2cgYmFzZSAxMCAgICAgICAgICAgfCBGZCA6PSBsb2cxMChGbSkgICAgICAgfAorfCAwIHwgMSB8IDEgfCAwIHwgTEdOICAgICAgfCBMb2cgYmFzZSBlICAgICAgICAgICAgfCBGZCA6PSBsbihGbSkgICAgICAgICAgfAorfCAwIHwgMSB8IDEgfCAxIHwgRVhQICAgICAgfCBFeHBvbmVudCAgICAgICAgICAgICAgfCBGZCA6PSBlIF4gRm0gICAgICAgICAgfAorfCAxIHwgMCB8IDAgfCAwIHwgU0lOICAgICAgfCBTaW5lICAgICAgICAgICAgICAgICAgfCBGZCA6PSBzaW4oRm0pICAgICAgICAgfAorfCAxIHwgMCB8IDAgfCAxIHwgQ09TICAgICAgfCBDb3NpbmUgICAgICAgICAgICAgICAgfCBGZCA6PSBjb3MoRm0pICAgICAgICAgfAorfCAxIHwgMCB8IDEgfCAwIHwgVEFOICAgICAgfCBUYW5nZW50ICAgICAgICAgICAgICAgfCBGZCA6PSB0YW4oRm0pICAgICAgICAgfAorfCAxIHwgMCB8IDEgfCAxIHwgQVNOICAgICAgfCBBcmMgU2luZSAgICAgICAgICAgICAgfCBGZCA6PSBhcmNzaW4oRm0pICAgICAgfAorfCAxIHwgMSB8IDAgfCAwIHwgQUNTICAgICAgfCBBcmMgQ29zaW5lICAgICAgICAgICAgfCBGZCA6PSBhcmNjb3MoRm0pICAgICAgfAorfCAxIHwgMSB8IDAgfCAxIHwgQVROICAgICAgfCBBcmMgVGFuZ2VudCAgICAgICAgICAgfCBGZCA6PSBhcmN0YW4oR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IGlzIHJldHVybmVkIGF0IHRoZSBsb2NhdGlvbiBwb2ludGVkIHRvIGJ5IGB6MVB0cicuKQorLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQorKi8KK0lOTElORSB2b2lkCisgc2hpZnQ2NEV4dHJhUmlnaHRKYW1taW5nKAorICAgICBiaXRzNjQgYTAsIGJpdHM2NCBhMSwgaW50MTYgY291bnQsIGJpdHM2NCAqejBQdHIsIGJpdHM2NCAqejFQdHIgKQoreworICAgIGJpdHM2NCB6MCwgejE7CisgICAgaW50OCBuZWdDb3VudCA9ICggLSBjb3VudCApICYgNjM7CisKKyAgICBpZiAoIGNvdW50ID09IDAgKSB7CisgICAgICAgIHoxID0gYTE7CisgICAgICAgIHowID0gYTA7CisgICAgfQorICAgIGVsc2UgaWYgKCBjb3VudCA8IDY0ICkgeworICAgICAgICB6MSA9ICggYTA8PG5lZ0NvdW50ICkgfCAoIGExICE9IDAgKTsKKyAgICAgICAgejAgPSBhMD4+Y291bnQ7CisgICAgfQorICAgIGVsc2UgeworICAgICAgICBpZiAoIGNvdW50ID09IDY0ICkgeworICAgICAgICAgICAgejEgPSBhMCB8ICggYTEgIT0gMCApOworICAgICAgICB9CisgICAgICAgIGVsc2UgeworICAgICAgICAgICAgejEgPSAoICggYTAgfCBhMSApICE9IDAgKTsKKyAgICAgICAgfQorICAgICAgICB6MCA9IDA7CisgICAgfQorICAgICp6MVB0ciA9IHoxOworICAgICp6MFB0ciA9IHowOworCit9CisKKy8qCistLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCitTaGlmdHMgdGhlIDEyOC1iaXQgdmFsdWUgZm9ybWVkIGJ5IGNvbmNhdGVuYXRpbmcgYGEwJyBhbmQ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OFJpZ2h0SmFtbWluZygKKyAgICAgYml0czY0IGEwLCBiaXRzNjQgYTEsIGludDE2IGNvdW50LCBiaXRzNjQgKnowUHRyLCBiaXRzNjQgKnoxUHRyICkKK3sKKyAgICBiaXRzNjQgejAsIHoxOworICAgIGludDggbmVnQ291bnQgPSAoIC0gY291bnQgKSAmIDYzOworCisgICAgaWYgKCBjb3VudCA9PSAwICkgeworICAgICAgICB6MSA9IGExOworICAgICAgICB6MCA9IGEwOworICAgIH0KKyAgICBlbHNlIGlmICggY291bnQgPCA2NCApIHsKKyAgICAgICAgejEgPSAoIGEwPDxuZWdDb3VudCApIHwgKCBhMT4+Y291bnQgKSB8ICggKCBhMTw8bmVnQ291bnQgKSAhPSAwICk7CisgICAgICAgIHowID0gYTA+PmNvdW50OworICAgIH0KKyAgICBlbHNlIHsKKyAgICAgICAgaWYgKCBjb3VudCA9PSA2NCApIHsKKyAgICAgICAgICAgIHoxID0gYTAgfCAoIGExICE9IDAgKTsKKyAgICAgICAgfQorICAgICAgICBlbHNlIGlmICggY291bnQgPCAxMjggKSB7CisgICAgICAgICAgICB6MSA9ICggYTA+PiggY291bnQgJiA2MyApICkgfCAoICggKCBhMDw8bmVnQ291bnQgKSB8IGExICkgIT0gMCApOworICAgICAgICB9CisgICAgICAgIGVsc2UgeworICAgICAgICAgICAgejEgPSAoICggYTAgfCBhMSApICE9IDAgKTsKKyAgICAgICAgfQorICAgICAgICB6MCA9IDA7CisgICAgfQorICAgICp6MVB0ciA9IHoxOworICAgICp6MFB0ciA9IHowOworCit9CisKKy8qCistLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCitTaGlmdHMgdGhlIDE5Mi1iaXQgdmFsdWUgZm9ybWVkIGJ5IGNvbmNhdGVuYXRpbmcgYGEwJywgYGExJywgYW5kIGBhMicgcmlnaHQKK2J5IDY0IF9wbHV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nQnLAorYW5kIHRoZSBpbnRlZ2VyIHBhcnQgb2YgdGhlIHJlc3VsdCBpcyByZXR1cm5lZCBhdCB0aGUgbG9jYXRpb25zIHBvaW50ZWQgdG8KK2J5IGB6MFB0cicgYW5kIGB6MVB0cicuICBUaGUgZnJhY3Rpb25hbCBwYXJ0IG9mIHRoZSByZXN1bHQgbWF5IGJlIHNsaWdodGx5Citjb3JydXB0ZWQgYXMgZGVzY3JpYmVkIGFib3ZlLCBhbmQgaXMgcmV0dXJuZWQgYXQgdGhlIGxvY2F0aW9uIHBvaW50ZWQgdG8gYnkKK2B6MlB0cicuKQorLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQorKi8KK0lOTElORSB2b2lkCisgc2hpZnQxMjhFeHRyYVJpZ2h0SmFtbWluZygKKyAgICAgYml0czY0IGEwLAorICAgICBiaXRzNjQgYTEsCisgICAgIGJpdHM2NCBhMiwKKyAgICAgaW50MTYgY291bnQsCisgICAgIGJpdHM2NCAqejBQdHIsCisgICAgIGJpdHM2NCAqejFQdHIsCisgICAgIGJpdHM2NCAqejJQdHIKKyApCit7CisgICAgYml0czY0IHowLCB6MSwgejI7CisgICAgaW50OCBuZWdDb3VudCA9ICggLSBjb3VudCApICYgNjM7CisKKyAgICBpZiAoIGNvdW50ID09IDAgKSB7CisgICAgICAgIHoyID0gYTI7CisgICAgICAgIHoxID0gYTE7CisgICAgICAgIHowID0gYTA7CisgICAgfQorICAgIGVsc2UgeworICAgICAgICBpZiAoIGNvdW50IDwgNjQgKSB7CisgICAgICAgICAgICB6MiA9IGExPDxuZWdDb3VudDsKKyAgICAgICAgICAgIHoxID0gKCBhMDw8bmVnQ291bnQgKSB8ICggYTE+PmNvdW50ICk7CisgICAgICAgICAgICB6MCA9IGEwPj5jb3VudDsKKyAgICAgICAgfQorICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgIGlmICggY291bnQgPT0gNjQgKSB7CisgICAgICAgICAgICAgICAgejIgPSBhMTsKKyAgICAgICAgICAgICAgICB6MSA9IGEwOworICAgICAgICAgICAgfQorICAgICAgICAgICAgZWxzZSB7CisgICAgICAgICAgICAgICAgYTIgfD0gYTE7CisgICAgICAgICAgICAgICAgaWYgKCBjb3VudCA8IDEyOCApIHsKKyAgICAgICAgICAgICAgICAgICAgejIgPSBhMDw8bmVnQ291bnQ7CisgICAgICAgICAgICAgICAgICAgIHoxID0gYTA+PiggY291bnQgJiA2MyApOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgejIgPSAoIGNvdW50ID09IDEyOCApID8gYTAgOiAoIGEwICE9IDAgKTsKKyAgICAgICAgICAgICAgICAgICAgejEgPSAwOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHowID0gMDsKKyAgICAgICAgfQorICAgICAgICB6MiB8PSAoIGEyICE9IDAgKTsKKyAgICB9CisgICAgKnoyUHRyID0gejI7CisgICAgKnoxUHRyID0gejE7CisgICAgKnowUHRyID0gejA7CisKK30KKworLyoKKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KK1NoaWZ0cyB0aGUgMTI4LWJpdCB2YWx1ZSBmb3JtZWQgYnkgY29uY2F0ZW5hdGluZyBgYTAnIGFuZCBgYTEnIGxlZnQgYnkgdGhlCitudW1iZXIgb2YgYml0cyBnaXZlbiBpbiBgY291bnQnLiAgQW55IGJpdHMgc2hpZnRlZCBvZmYgYXJlIGxvc3QuICBUaGUgdmFsdWUKK29mIGBjb3VudCcgbXVzdCBiZSBsZXNzIHRoYW4gNjQuICBUaGUgcmVzdWx0IGlzIGJyb2tlbiBpbnRvIHR3byA2NC1iaXQKK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tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCisqLworSU5MSU5FIHZvaWQKKyBzaG9ydFNoaWZ0MTkyTGVmdCgKKyAgICAgYml0czY0IGEwLAorICAgICBiaXRzNjQgYTEsCisgICAgIGJpdHM2NCBhMiwKKyAgICAgaW50MTYgY291bnQsCisgICAgIGJpdHM2NCAqejBQdHIsCisgICAgIGJpdHM2NCAqejFQdHIsCisgICAgIGJpdHM2NCAqejJQdHIKKyApCit7CisgICAgYml0czY0IHowLCB6MSwgejI7CisgICAgaW50OCBuZWdDb3VudDsKKworICAgIHoyID0gYTI8PGNvdW50OworICAgIHoxID0gYTE8PGNvdW50OworICAgIHowID0gYTA8PGNvdW50OworICAgIGlmICggMCA8IGNvdW50ICkgeworICAgICAgICBuZWdDb3VudCA9ICggKCAtIGNvdW50ICkgJiA2MyApOworICAgICAgICB6MSB8PSBhMj4+bmVnQ291bnQ7CisgICAgICAgIHowIHw9IGExPj5uZWdDb3VudDsKKyAgICB9CisgICAgKnoyUHRyID0gejI7CisgICAgKnoxUHRyID0gejE7CisgICAgKnowUHRyID0gejA7CisKK30KKworLyoKKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KK0FkZHMgdGhlIDEyOC1iaXQgdmFsdWUgZm9ybWVkIGJ5IGNvbmNhdGVuYXRpbmcgYGEwJyBhbmQgYGExJyB0byB0aGUgMTI4LWJpdAordmFsdWUgZm9ybWVkIGJ5IGNvbmNhdGVuYXRpbmcgYGIwJyBhbmQgYGIxJy4gIEFkZGl0aW9uIGlzIG1vZHVsbyAyXjEyOCwgc28KK2FueSBjYXJyeSBvdXQgaXMgbG9zdC4gIFRoZSByZXN1bHQgaXMgYnJva2VuIGludG8gdHdvIDY0LWJpdCBwaWVjZXMgd2hpY2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YnJva2VuIGludG8gZm91ciA2NC1iaXQgcGllY2VzIHdoaWNoIGFyZSBzdG9yZWQgYXQKK3RoZSBsb2NhdGlvbnMgcG9pbnRlZCB0byBieSBgejBQdHInLCBgejFQdHInLCBgejJQdHInLCBhbmQgYHozUHRyJy4KKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KKyovCitJTkxJTkUgdm9pZAorIG11bDEyOFRvMjU2KAorICAgICBiaXRzNjQgYTAsCisgICAgIGJpdHM2NCBhMSwKKyAgICAgYml0czY0IGIwLAorICAgICBiaXRzNjQgYjEsCisgICAgIGJpdHM2NCAqejBQdHIsCisgICAgIGJpdHM2NCAqejFQdHIsCisgICAgIGJpdHM2NCAqejJQdHIsCisgICAgIGJpdHM2NCAqejNQdHIKKyApCit7CisgICAgYml0czY0IHowLCB6MSwgejIsIHozOworICAgIGJpdHM2NCBtb3JlMSwgbW9yZTI7CisKKyAgICBtdWw2NFRvMTI4KCBhMSwgYjEsICZ6MiwgJnozICk7CisgICAgbXVsNjRUbzEyOCggYTEsIGIwLCAmejEsICZtb3JlMiApOworICAgIGFkZDEyOCggejEsIG1vcmUyLCAwLCB6MiwgJnoxLCAmejIgKTsKKyAgICBtdWw2NFRvMTI4KCBhMCwgYjAsICZ6MCwgJm1vcmUxICk7CisgICAgYWRkMTI4KCB6MCwgbW9yZTEsIDAsIHoxLCAmejAsICZ6MSApOworICAgIG11bDY0VG8xMjgoIGEwLCBiMSwgJm1vcmUxLCAmbW9yZTIgKTsKKyAgICBhZGQxMjgoIG1vcmUxLCBtb3JlMiwgMCwgejIsICZtb3JlMSwgJnoyICk7CisgICAgYWRkMTI4KCB6MCwgejEsIDAsIG1vcmUxLCAmejAsICZ6MSApOworICAgICp6M1B0ciA9IHozOworICAgICp6MlB0ciA9IHoyOworICAgICp6MVB0ciA9IHoxOworICAgICp6M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LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCisqLworc3RhdGljIGludDMyIHJvdW5kQW5kUGFja0ludDMyKCBmbGFnIHpTaWduLCBiaXRzNjQgYWJzWiApCit7CisgICAgaW50OCByb3VuZGluZ01vZGU7CisgICAgZmxhZyByb3VuZE5lYXJlc3RFdmVuOworICAgIGludDggcm91bmRJbmNyZW1lbnQsIHJvdW5kQml0czsKKyAgICBpbnQzMiB6OworCisgICAgcm91bmRpbmdNb2RlID0gZmxvYXRfcm91bmRpbmdfbW9kZTsKKyAgICByb3VuZE5lYXJlc3RFdmVuID0gKCByb3VuZGluZ01vZGUgPT0gZmxvYXRfcm91bmRfbmVhcmVzdF9ldmVuICk7CisgICAgcm91bmRJbmNyZW1lbnQgPSAweDQwOworICAgIGlmICggISByb3VuZE5lYXJlc3RFdmVuICkgeworICAgICAgICBpZiAoIHJvdW5kaW5nTW9kZSA9PSBmbG9hdF9yb3VuZF90b196ZXJvICkgeworICAgICAgICAgICAgcm91bmRJbmNyZW1lbnQgPSAwOworICAgICAgICB9CisgICAgICAgIGVsc2UgeworICAgICAgICAgICAgcm91bmRJbmNyZW1lbnQgPSAweDdGOworICAgICAgICAgICAgaWYgKCB6U2lnbiApIHsKKyAgICAgICAgICAgICAgICBpZiAoIHJvdW5kaW5nTW9kZSA9PSBmbG9hdF9yb3VuZF91cCApIHJvdW5kSW5jcmVtZW50ID0gMDsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGVsc2UgeworICAgICAgICAgICAgICAgIGlmICggcm91bmRpbmdNb2RlID09IGZsb2F0X3JvdW5kX2Rvd24gKSByb3VuZEluY3JlbWVudCA9IDA7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICB9CisgICAgcm91bmRCaXRzID0gYWJzWiAmIDB4N0Y7CisgICAgYWJzWiA9ICggYWJzWiArIHJvdW5kSW5jcmVtZW50ICk+Pjc7CisgICAgYWJzWiAmPSB+ICggKCAoIHJvdW5kQml0cyBeIDB4ND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VhcmVzdEV2ZW4gPSAoIHJvdW5kaW5nTW9kZSA9PSBmbG9hdF9yb3VuZF9uZWFyZXN0X2V2ZW4gKTsKKyAgICByb3VuZEluY3JlbWVudCA9IDB4NDA7CisgICAgaWYgKCAhIHJvdW5kTmVhcmVzdEV2ZW4gKSB7CisgICAgICAgIGlmICggcm91bmRpbmdNb2RlID09IGZsb2F0X3JvdW5kX3RvX3plcm8gKSB7CisgICAgICAgICAgICByb3VuZEluY3JlbWVudCA9IDA7CisgICAgICAgIH0KKyAgICAgICAgZWxzZSB7CisgICAgICAgICAgICByb3VuZEluY3JlbWVudCA9IDB4N0Y7CisgICAgICAgICAgICBpZiAoIHpTaWduICkgeworICAgICAgICAgICAgICAgIGlmICggcm91bmRpbmdNb2RlID09IGZsb2F0X3JvdW5kX3VwICkgcm91bmRJbmNyZW1lbnQgPSAwOworICAgICAgICAgICAgfQorICAgICAgICAgICAgZWxzZSB7CisgICAgICAgICAgICAgICAgaWYgKCByb3VuZGluZ01vZGUgPT0gZmxvYXRfcm91bmRfZG93biApIHJvdW5kSW5jcmVtZW50ID0gMDsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KKyAgICByb3VuZEJpdHMgPSB6U2lnICYgMHg3RjsKKyAgICBpZiAoIDB4RkQgPD0gKGJpdHMxNikgekV4cCApIHsKKyAgICAgICAgaWYgKCAgICAoIDB4RkQgPCB6RXhwICkKKyAgICAgICAgICAgICB8fCAoICAgICggekV4cCA9PSAweEZEICkKKyAgICAgICAgICAgICAgICAgICYmICggKHNiaXRzMzIpICggelNpZyArIHJvdW5kSW5jcmVtZW50ICkgPCAwICkgKQorICAgICAgICAgICApIHsKKyAgICAgICAgICAgIGZsb2F0X3JhaXNlKCBmbG9hdF9mbGFnX292ZXJmbG93IHwgZmxvYXRfZmxhZ19pbmV4YWN0ICk7CisgICAgICAgICAgICByZXR1cm4gcGFja0Zsb2F0MzIoIHpTaWduLCAweEZGLCAwICkgLSAoIHJvdW5kSW5jcmVtZW50ID09IDAgKTsKKyAgICAgICAgfQorICAgICAgICBpZiAoIHpFeHAgPCAwICkgeworICAgICAgICAgICAgaXNUaW55ID0KKyAgICAgICAgICAgICAgICAgICAoIGZsb2F0X2RldGVjdF90aW5pbmVzcyA9PSBmbG9hdF90aW5pbmVzc19iZWZvcmVfcm91bmRpbmcgKQorICAgICAgICAgICAgICAgIHx8ICggekV4cCA8IC0xICkKKyAgICAgICAgICAgICAgICB8fCAoIHpTaWcgKyByb3VuZEluY3JlbWVudCA8IDB4ODAwMDAwMDAgKTsKKyAgICAgICAgICAgIHNoaWZ0MzJSaWdodEphbW1pbmcoIHpTaWcsIC0gekV4cCwgJnpTaWcgKTsKKyAgICAgICAgICAgIHpFeHAgPSAwOworICAgICAgICAgICAgcm91bmRCaXRzID0gelNpZyAmIDB4N0Y7CisgICAgICAgICAgICBpZiAoIGlzVGlueSAmJiByb3VuZEJpdHMgKSBmbG9hdF9yYWlzZSggZmxvYXRfZmxhZ191bmRlcmZsb3cgKTsKKyAgICAgICAgfQorICAgIH0KKyAgICBpZiAoIHJvdW5kQml0cyApIGZsb2F0X2V4Y2VwdGlvbl9mbGFncyB8PSBmbG9hdF9mbGFnX2luZXhhY3Q7CisgICAgelNpZyA9ICggelNpZyArIHJvdW5kSW5jcmVtZW50ICk+Pjc7CisgICAgelNpZyAmPSB+ICggKCAoIHJvdW5kQml0cyBeIDB4NDAgKSA9PSAwICkgJiByb3VuZE5lYXJlc3RFdmVuICk7CisgICAgaWYgKCB6U2lnID09IDAgKSB6RXhwID0gMDsKKyAgICByZXR1cm4gcGFja0Zsb2F0MzIoIHpTaWduLCB6RXhwLCB6U2lnICk7CisKK30KKworLyoKKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KK1Rha2VzIGFuIGFic3RyYWN0IGZsb2F0aW5nLXBvaW50IHZhbH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isgICAgZmxhZyByb3VuZE5lYXJlc3RFdmVuOworICAgIGludDE2IHJvdW5kSW5jcmVtZW50LCByb3VuZEJpdHM7CisgICAgZmxhZyBpc1Rpbnk7CisKKyAgICByb3VuZGluZ01vZGUgPSBmbG9hdF9yb3VuZGluZ19tb2RlOworICAgIHJvdW5kTmVhcmVzdEV2ZW4gPSAoIHJvdW5kaW5nTW9kZSA9PSBmbG9hdF9yb3VuZF9uZWFyZXN0X2V2ZW4gKTsKKyAgICByb3VuZEluY3JlbWVudCA9IDB4MjAwOworICAgIGlmICggISByb3VuZE5lYXJlc3RFdmVuICkgeworICAgICAgICBpZiAoIHJvdW5kaW5nTW9kZSA9PSBmbG9hdF9yb3VuZF90b196ZXJvICkgeworICAgICAgICAgICAgcm91bmRJbmNyZW1lbnQgPSAwOworICAgICAgICB9CisgICAgICAgIGVsc2UgeworICAgICAgICAgICAgcm91bmRJbmNyZW1lbnQgPSAweDNGRjsKKyAgICAgICAgICAgIGlmICggelNpZ24gKSB7CisgICAgICAgICAgICAgICAgaWYgKCByb3VuZGluZ01vZGUgPT0gZmxvYXRfcm91bmRfdXAgKSByb3VuZEluY3JlbWVudCA9IDA7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICBpZiAoIHJvdW5kaW5nTW9kZSA9PSBmbG9hdF9yb3VuZF9kb3duICkgcm91bmRJbmNyZW1lbnQgPSAwOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfQorICAgIHJvdW5kQml0cyA9IHpTaWcgJiAweDNGRjsKKyAgICBpZiAoIDB4N0ZEIDw9IChiaXRzMTYpIHpFeHAgKSB7CisgICAgICAgIGlmICggICAgKCAweDdGRCA8IHpFeHAgKQorICAgICAgICAgICAgIHx8ICggICAgKCB6RXhwID09IDB4N0ZEICkKKyAgICAgICAgICAgICAgICAgICYmICggKHNiaXRzNjQpICggelNpZyArIHJvdW5kSW5jcmVtZW50ICkgPCAwICkgKQorICAgICAgICAgICApIHsKKyAgICAgICAgICAgIC8vcmVnaXN0ZXIgaW50IGxyID0gX19idWlsdGluX3JldHVybl9hZGRyZXNzKDApOworICAgICAgICAgICAgLy9wcmludGsoInJvdW5kQW5kUGFja0Zsb2F0NjQgY2FsbGVkIGZyb20gMHglMDh4XG4iLGxyKTsKKyAgICAgICAgICAgIGZsb2F0X3JhaXNlKCBmbG9hdF9mbGFnX292ZXJmbG93IHwgZmxvYXRfZmxhZ19pbmV4YWN0ICk7CisgICAgICAgICAgICByZXR1cm4gcGFja0Zsb2F0NjQoIHpTaWduLCAweDdGRiwgMCApIC0gKCByb3VuZEluY3JlbWVudCA9PSAwICk7CisgICAgICAgIH0KKyAgICAgICAgaWYgKCB6RXhwIDwgMCApIHsKKyAgICAgICAgICAgIGlzVGlueSA9CisgICAgICAgICAgICAgICAgICAgKCBmbG9hdF9kZXRlY3RfdGluaW5lc3MgPT0gZmxvYXRfdGluaW5lc3NfYmVmb3JlX3JvdW5kaW5nICkKKyAgICAgICAgICAgICAgICB8fCAoIHpFeHAgPCAtMSApCisgICAgICAgICAgICAgICAgfHwgKCB6U2lnICsgcm91bmRJbmNyZW1lbnQgPCBMSVQ2NCggMHg4MDAwMDAwMDAwMDAwMDAwICkgKTsKKyAgICAgICAgICAgIHNoaWZ0NjRSaWdodEphbW1pbmcoIHpTaWcsIC0gekV4cCwgJnpTaWcgKTsKKyAgICAgICAgICAgIHpFeHAgPSAwOworICAgICAgICAgICAgcm91bmRCaXRzID0gelNpZyAmIDB4M0ZGOworICAgICAgICAgICAgaWYgKCBpc1RpbnkgJiYgcm91bmRCaXRzICkgZmxvYXRfcmFpc2UoIGZsb2F0X2ZsYWdfdW5kZXJmbG93ICk7CisgICAgICAgIH0KKyAgICB9CisgICAgaWYgKCByb3VuZEJpdHMgKSBmbG9hdF9leGNlcHRpb25fZmxhZ3MgfD0gZmxvYXRfZmxhZ19pbmV4YWN0OworICAgIHpTaWcgPSAoIHpTaWcgKyByb3VuZEluY3JlbWVudC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TaWcxCisgKQoreworICAgIGludDggcm91bmRpbmdNb2RlOworICAgIGZsYWcgcm91bmROZWFyZXN0RXZlbiwgaW5jcmVtZW50LCBpc1Rpbnk7CisgICAgaW50NjQgcm91bmRJbmNyZW1lbnQsIHJvdW5kTWFzaywgcm91bmRCaXRzOworCisgICAgcm91bmRpbmdNb2RlID0gZmxvYXRfcm91bmRpbmdfbW9kZTsKKyAgICByb3VuZE5lYXJlc3RFdmVuID0gKCByb3VuZGluZ01vZGUgPT0gZmxvYXRfcm91bmRfbmVhcmVzdF9ldmVuICk7CisgICAgaWYgKCByb3VuZGluZ1ByZWNpc2lvbiA9PSA4MCApIGdvdG8gcHJlY2lzaW9uODA7CisgICAgaWYgKCByb3VuZGluZ1ByZWNpc2lvbiA9PSA2NCApIHsKKyAgICAgICAgcm91bmRJbmNyZW1lbnQgPSBMSVQ2NCggMHgwMDAwMDAwMDAwMDAwNDAwICk7CisgICAgICAgIHJvdW5kTWFzayA9IExJVDY0KCAweDAwMDAwMDAwMDAwMDA3RkYgKTsKKyAgICB9CisgICAgZWxzZSBpZiAoIHJvdW5kaW5nUHJlY2lzaW9uID09IDMyICkgeworICAgICAgICByb3VuZEluY3JlbWVudCA9IExJVDY0KCAweDAwMDAwMDgwMDAwMDAwMDAgKTsKKyAgICAgICAgcm91bmRNYXNrID0gTElUNjQoIDB4MDAwMDAwRkZGRkZGRkZGRiApOworICAgIH0KKyAgICBlbHNlIHsKKyAgICAgICAgZ290byBwcmVjaXNpb244MDsKKyAgICB9CisgICAgelNpZzAgfD0gKCB6U2lnMSAhPSAwICk7CisgICAgaWYgKCAhIHJvdW5kTmVhcmVzdEV2ZW4gKSB7CisgICAgICAgIGlmICggcm91bmRpbmdNb2RlID09IGZsb2F0X3JvdW5kX3RvX3plcm8gKSB7CisgICAgICAgICAgICByb3VuZEluY3JlbWVudCA9IDA7CisgICAgICAgIH0KKyAgICAgICAgZWxzZSB7CisgICAgICAgICAgICByb3VuZEluY3JlbWVudCA9IHJvdW5kTWFzazsKKyAgICAgICAgICAgIGlmICggelNpZ24gKSB7CisgICAgICAgICAgICAgICAgaWYgKCByb3VuZGluZ01vZGUgPT0gZmxvYXRfcm91bmRfdXAgKSByb3VuZEluY3JlbWVudCA9IDA7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICBpZiAoIHJvdW5kaW5nTW9kZSA9PSBmbG9hdF9yb3VuZF9kb3duICkgcm91bmRJbmNyZW1lbnQgPSAwOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfQorICAgIHJvdW5kQml0cyA9IHpTaWcwICYgcm91bmRNYXNrOworICAgIGlmICggMHg3RkZEIDw9IChiaXRzMzIpICggekV4cCAtIDEgKSApIHsKKyAgICAgICAgaWYgKCAgICAoIDB4N0ZGRSA8IHpFeHAgKQorICAgICAgICAgICAgIHx8ICggKCB6RXhwID09IDB4N0ZGRSApICYmICggelNpZzAgKyByb3VuZEluY3JlbWVudCA8IHpTaWcwICkgKQorICAgICAgICAgICApIHsKKyAgICAgICAgICAgIGdvdG8gb3ZlcmZsb3c7CisgICAgICAgIH0KKyAgICAgICAgaWYgKCB6RXhwIDw9IDAgKSB7CisgICAgICAgICAgICBpc1RpbnkgPQorICAgICAgICAgICAgICAgICAgICggZmxvYXRfZGV0ZWN0X3RpbmluZXNzID09IGZsb2F0X3RpbmluZXNzX2JlZm9yZV9yb3VuZGluZyApCisgICAgICAgICAgICAgICAgfHwgKCB6RXhwIDwgMCApCisgICAgICAgICAgICAgICAgfHwgKCB6U2lnMCA8PSB6U2lnMCArIHJvdW5kSW5jcmVtZW50ICk7CisgICAgICAgICAgICBzaGlmdDY0UmlnaHRKYW1taW5nKCB6U2lnMCwgMSAtIHpFeHAsICZ6U2lnMCApOworICAgICAgICAgICAgekV4cCA9IDA7CisgICAgICAgICAgICByb3VuZEJpdHMgPSB6U2lnMCAmIHJvdW5kTWFzazsKKyAgICAgICAgICAgIGlmICggaXNUaW55ICYmIHJvdW5kQml0cyApIGZsb2F0X3JhaXNlKCBmbG9hdF9mbGFnX3VuZGVyZmxvdyApOworICAgICAgICAgICAgaWYgKCByb3VuZEJpdHMgKSBmbG9hdF9leGNlcHRpb25fZmxhZ3MgfD0gZmxvYXRfZmxhZ19pbmV4YWN0OworICAgICAgICAgICAgelNpZzAgKz0gcm91bmRJbmNyZW1lbnQ7CisgICAgICAgICAgICBpZiAoIChzYml0czY0KSB6U2lnMCA8IDAgKSB6RXhwID0gMTsKKyAgICAgICAgICAgIHJvdW5kSW5jcmVtZW50ID0gcm91bmRNYXNrICsgMTsKKyAgICAgICAgICAgIGlmICggcm91bmROZWFyZXN0RXZlbiAmJiAoIHJvdW5kQml0czw8MSA9PSByb3VuZEluY3JlbWVudCApICkgeworICAgICAgICAgICAgICAgIHJvdW5kTWFzayB8PSByb3VuZEluY3JlbWVudDsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHpTaWcwICY9IH4gcm91bmRNYXNrOworICAgICAgICAgICAgcmV0dXJuIHBhY2tGbG9hdHg4MCggelNpZ24sIHpFeHAsIHpTaWcwICk7CisgICAgICAgIH0KKyAgICB9CisgICAgaWYgKCByb3VuZEJpdHMgKSBmbG9hdF9leGNlcHRpb25fZmxhZ3MgfD0gZmxvYXRfZmxhZ19pbmV4YWN0OworICAgIHpTaWcwICs9IHJvdW5kSW5jcmVtZW50OworICAgIGlmICggelNpZzAgPCByb3VuZEluY3JlbWVudCApIHsKKyAgICAgICAgKyt6RXhwOworICAgICAgICB6U2lnMCA9IExJVDY0KCAweDgwMDAwMDAwMDAwMDAwMDAgKTsKKyAgICB9CisgICAgcm91bmRJbmNyZW1lbnQgPSByb3VuZE1hc2sgKyAxOworICAgIGlmICggcm91bmROZWFyZXN0RXZlbiAmJiAoIHJvdW5kQml0czw8MSA9PSByb3VuZEluY3JlbWVudCApICkgeworICAgICAgICByb3VuZE1hc2sgfD0gcm91bmRJbmNyZW1lbnQ7CisgICAgfQorICAgIHpTaWcwICY9IH4gcm91bmRNYXNrOworICAgIGlmICggelNpZzAgPT0gMCApIHpFeHAgPSAwOworICAgIHJldHVybiBwYWNrRmxvYXR4ODAoIHpTaWduLCB6RXhwLCB6U2lnMCApOworIHByZWNpc2lvbjgwOgorICAgIGluY3JlbWVudCA9ICggKHNiaXRzNjQpIHpTaWcxIDwgMCApOworICAgIGlmICggISByb3VuZE5lYXJlc3RFdmVuICkgeworICAgICAgICBpZiAoIHJvdW5kaW5nTW9kZSA9PSBmbG9hdF9yb3VuZF90b196ZXJvICkgeworICAgICAgICAgICAgaW5jcmVtZW50ID0gMDsKKyAgICAgICAgfQorICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgIGlmICggelNpZ24gKSB7CisgICAgICAgICAgICAgICAgaW5jcmVtZW50ID0gKCByb3VuZGluZ01vZGUgPT0gZmxvYXRfcm91bmRfZG93biApICYmIHpTaWcxOworICAgICAgICAgICAgfQorICAgICAgICAgICAgZWxzZSB7CisgICAgICAgICAgICAgICAgaW5jcmVtZW50ID0gKCByb3VuZGluZ01vZGUgPT0gZmxvYXRfcm91bmRfdXAgKSAmJiB6U2lnMTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KKyAgICBpZiAoIDB4N0ZGRCA8PSAoYml0czMyKSAoIHpFeHAgLSAxICkgKSB7CisgICAgICAgIGlmICggICAgKCAweDdGRkUgPCB6RXhwICkKKyAgICAgICAgICAgICB8fCAoICAgICggekV4cCA9PSAweDdGRkUgKQorICAgICAgICAgICAgICAgICAgJiYgKCB6U2lnMCA9PSBMSVQ2NCggMHhGRkZGRkZGRkZGRkZGRkZGICkgKQorICAgICAgICAgICAgICAgICAgJiYgaW5jcmVtZW50CisgICAgICAgICAgICAgICAgKQorICAgICAgICAgICApIHsKKyAgICAgICAgICAgIHJvdW5kTWFzayA9IDA7Cisgb3ZlcmZsb3c6CisgICAgICAgICAgICBmbG9hdF9yYWlzZSggZmxvYXRfZmxhZ19vdmVyZmxvdyB8IGZsb2F0X2ZsYWdfaW5leGFjdCApOworICAgICAgICAgICAgaWYgKCAgICAoIHJvdW5kaW5nTW9kZSA9PSBmbG9hdF9yb3VuZF90b196ZXJvICkKKyAgICAgICAgICAgICAgICAgfHwgKCB6U2lnbiAmJiAoIHJvdW5kaW5nTW9kZSA9PSBmbG9hdF9yb3VuZF91cCApICkKKyAgICAgICAgICAgICAgICAgfHwgKCAhIHpTaWduICYmICggcm91bmRpbmdNb2RlID09IGZsb2F0X3JvdW5kX2Rvd24gKSApCisgICAgICAgICAgICAgICApIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gcGFja0Zsb2F0eDgwKCB6U2lnbiwgMHg3RkZFLCB+IHJvdW5kTWFzayApOworICAgICAgICAgICAgfQorICAgICAgICAgICAgcmV0dXJuIHBhY2tGbG9hdHg4MCggelNpZ24sIDB4N0ZGRiwgTElUNjQoIDB4ODAwMDAwMDAwMDAwMDAwMCApICk7CisgICAgICAgIH0KKyAgICAgICAgaWYgKCB6RXhwIDw9IDAgKSB7CisgICAgICAgICAgICBpc1RpbnkgPQorICAgICAgICAgICAgICAgICAgICggZmxvYXRfZGV0ZWN0X3RpbmluZXNzID09IGZsb2F0X3RpbmluZXNzX2JlZm9yZV9yb3VuZGluZyApCisgICAgICAgICAgICAgICAgfHwgKCB6RXhwIDwgMCApCisgICAgICAgICAgICAgICAgfHwgISBpbmNyZW1lbnQKKyAgICAgICAgICAgICAgICB8fCAoIHpTaWcwIDwgTElUNjQoIDB4RkZGRkZGRkZGRkZGRkZGRiApICk7CisgICAgICAgICAgICBzaGlmdDY0RXh0cmFSaWdodEphbW1pbmcoIHpTaWcwLCB6U2lnMSwgMSAtIHpFeHAsICZ6U2lnMCwgJnpTaWcxICk7CisgICAgICAgICAgICB6RXhwID0gMDsKKyAgICAgICAgICAgIGlmICggaXNUaW55ICYmIHpTaWcxICkgZmxvYXRfcmFpc2UoIGZsb2F0X2ZsYWdfdW5kZXJmbG93ICk7CisgICAgICAgICAgICBpZiAoIHpTaWcxICkgZmxvYXRfZXhjZXB0aW9uX2ZsYWdzIHw9IGZsb2F0X2ZsYWdfaW5leGFjdDsKKyAgICAgICAgICAgIGlmICggcm91bmROZWFyZXN0RXZlbiApIHsKKyAgICAgICAgICAgICAgICBpbmNyZW1lbnQgPSAoIChzYml0czY0KSB6U2lnMSA8IDAgKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGVsc2UgeworICAgICAgICAgICAgICAgIGlmICggelNpZ24gKSB7CisgICAgICAgICAgICAgICAgICAgIGluY3JlbWVudCA9ICggcm91bmRpbmdNb2RlID09IGZsb2F0X3JvdW5kX2Rvd24gKSAmJiB6U2lnMTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgZWxzZSB7CisgICAgICAgICAgICAgICAgICAgIGluY3JlbWVudCA9ICggcm91bmRpbmdNb2RlID09IGZsb2F0X3JvdW5kX3VwICkgJiYgelNpZzE7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorICAgICAgICAgICAgaWYgKCBpbmNyZW1lbnQgKSB7CisgICAgICAgICAgICAgICAgKyt6U2lnMDsKKyAgICAgICAgICAgICAgICB6U2lnMCAmPSB+ICggKCB6U2lnMSArIHpTaWcxID09IDAgKSAmIHJvdW5kTmVhcmVzdEV2ZW4gKTsKKyAgICAgICAgICAgICAgICBpZiAoIChzYml0czY0KSB6U2lnMCA8IDAgKSB6RXhwID0gMTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHJldHVybiBwYWNrRmxvYXR4ODAoIHpTaWduLCB6RXhwLCB6U2lnMCApOworICAgICAgICB9CisgICAgfQorICAgIGlmICggelNpZzEgKSBmbG9hdF9leGNlcHRpb25fZmxhZ3MgfD0gZmxvYXRfZmxhZ19pbmV4YWN0OworICAgIGlmICggaW5jcmVtZW50ICkgeworICAgICAgICArK3pTaWcwOworICAgICAgICBpZiAoIHpTaWcwID09IDAgKSB7CisgICAgICAgICAgICArK3pFeHA7CisgICAgICAgICAgICB6U2ln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YUV4cCA8PSAweDdFICkgeworICAgICAgICBpZiAoIChiaXRzMzIpICggYTw8MSApID09IDAgKSByZXR1cm4gYTsKKyAgICAgICAgZmxvYXRfZXhjZXB0aW9uX2ZsYWdzIHw9IGZsb2F0X2ZsYWdfaW5leGFjdDsKKyAgICAgICAgYVNpZ24gPSBleHRyYWN0RmxvYXQzMlNpZ24oIGEgKTsKKyAgICAgICAgc3dpdGNoICggZmxvYXRfcm91bmRpbmdfbW9kZSApIHsKKyAgICAgICAgIGNhc2UgZmxvYXRfcm91bmRfbmVhcmVzdF9ldmVuOgorICAgICAgICAgICAgaWYgKCAoIGFFeHAgPT0gMHg3RSApICYmIGV4dHJhY3RGbG9hdDMyRnJhYyggYSApICkgeworICAgICAgICAgICAgICAgIHJldHVybiBwYWNrRmxvYXQzMiggYVNpZ24sIDB4N0YsIDAgKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgY2FzZSBmbG9hdF9yb3VuZF9kb3duOgorICAgICAgICAgICAgcmV0dXJuIGFTaWduID8gMHhCRjgwMDAwMCA6IDA7CisgICAgICAgICBjYXNlIGZsb2F0X3JvdW5kX3VwOgorICAgICAgICAgICAgcmV0dXJuIGFTaWduID8gMHg4MDAwMDAwMCA6IDB4M0Y4MDAwMDA7CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIHBhY2tGbG9hdDMyKCBhU2lnbiwgMCwgMCApOworICAgIH0KKyAgICBsYXN0Qml0TWFzayA9IDE7CisgICAgbGFzdEJpdE1hc2sgPDw9IDB4OTYgLSBhRXhwOworICAgIHJvdW5kQml0c01hc2sgPSBsYXN0Qml0TWFzayAtIDE7CisgICAgeiA9IGE7CisgICAgcm91bmRpbmdNb2RlID0gZmxvYXRfcm91bmRpbmdfbW9kZTsKKyAgICBpZiAoIHJvdW5kaW5nTW9kZSA9PSBmbG9hdF9yb3VuZF9uZWFyZXN0X2V2ZW4gKSB7CisgICAgICAgIHogKz0gbGFzdEJpdE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0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KKyovCitzdGF0aWMgZmxvYXQzMiBhZGRGbG9hdDMyU2lncyggZmxvYXQzMiBhLCBmbG9hdDMyIGIsIGZsYWcgelNpZ24gKQoreworICAgIGludDE2IGFFeHAsIGJFeHAsIHpFeHA7CisgICAgYml0czMyIGFTaWcsIGJTaWcsIHpTaWc7CisgICAgaW50MTYgZXhwRGlmZjsKKworICAgIGFTaWcgPSBleHRyYWN0RmxvYXQzMkZyYWMoIGEgKTsKKyAgICBhRXhwID0gZXh0cmFjdEZsb2F0MzJFeHAoIGEgKTsKKyAgICBiU2lnID0gZXh0cmFjdEZsb2F0MzJGcmFjKCBiICk7CisgICAgYkV4cCA9IGV4dHJhY3RGbG9hdDMyRXhwKCBiICk7CisgICAgZXhwRGlmZiA9IGFFeHAgLSBiRXhwOworICAgIGFTaWcgPDw9IDY7CisgICAgYlNpZyA8PD0gNjsKKyAgICBpZiAoIDAgPCBleHBEaWZmICkgeworICAgICAgICBpZiAoIGFFeHAgPT0gMHhGRiApIHsKKyAgICAgICAgICAgIGlmICggYVNpZyApIHJldHVybiBwcm9wYWdhdGVGbG9hdDMyTmFOKCBhLCBiICk7CisgICAgICAgICAgICByZXR1cm4gYTsKKyAgICAgICAgfQorICAgICAgICBpZiAoIGJFeHAgPT0gMCApIHsKKyAgICAgICAgICAgIC0tZXhwRGlmZjsKKyAgICAgICAgfQorICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgIGJTaWcgfD0gMHgyMDAwMDAwMDsKKyAgICAgICAgfQorICAgICAgICBzaGlmdDMyUmlnaHRKYW1taW5nKCBiU2lnLCBleHBEaWZmLCAmYlNpZyApOworICAgICAgICB6RXhwID0gYUV4cDsKKyAgICB9CisgICAgZWxzZSBpZiAoIGV4cERpZmYgPCAwICkgeworICAgICAgICBpZiAoIGJFeHAgPT0gMHhGRiApIHsKKyAgICAgICAgICAgIGlmICggYlNpZyApIHJldHVybiBwcm9wYWdhdGVGbG9hdDMyTmFOKCBhLCBiICk7CisgICAgICAgICAgICByZXR1cm4gcGFja0Zsb2F0MzIoIHpTaWduLCAweEZGLCAwICk7CisgICAgICAgIH0KKyAgICAgICAgaWYgKCBhRXhwID09IDAgKSB7CisgICAgICAgICAgICArK2V4cERpZmY7CisgICAgICAgIH0KKyAgICAgICAgZWxzZSB7CisgICAgICAgICAgICBhU2lnIHw9IDB4MjAwMDAwMDA7CisgICAgICAgIH0KKyAgICAgICAgc2hpZnQzMlJpZ2h0SmFtbWluZyggYVNpZywgLSBleHBEaWZmLCAmYVNpZyApOworICAgICAgICB6RXhwID0gYkV4cDsKKyAgICB9CisgICAgZWxzZSB7CisgICAgICAgIGlmICggYUV4cCA9PSAweEZGICkgeworICAgICAgICAgICAgaWYgKCBhU2lnIHwgYlNpZyApIHJldHVybiBwcm9wYWdhdGVGbG9hdDMyTmFOKCBhLCBiICk7CisgICAgICAgICAgICByZXR1cm4gYTsKKyAgICAgICAgfQorICAgICAgICBpZiAoIGFFeHAgPT0gMCApIHJldHVybiBwYWNrRmxvYXQzMiggelNpZ24sIDAsICggYVNpZyArIGJTaWcgKT4+NiApOworICAgICAgICB6U2lnID0gMHg0MDAwMDAwMCArIGFTaWcgKyBiU2lnOworICAgICAgICB6RXhwID0gYUV4cDsKKyAgICAgICAgZ290byByb3VuZEFuZFBhY2s7CisgICAgfQorICAgIGFTaWcgfD0gMHgyMDAwMDAwMDsKKyAgICB6U2lnID0gKCBhU2lnICsgYlNpZyApPDwxOworICAgIC0tekV4cDsKKyAgICBpZiAoIChzYml0czMyKSB6U2lnIDwgMCApIHsKKyAgICAgICAgelNpZyA9IGFTaWcgKyBiU2lnOworICAgICAgICArK3pFeHA7CisgICAgfQorIHJvdW5kQW5kUGFjazoKKyAgICByZXR1cm4gcm91bmRBbmRQYWNrRmxvYXQzMiggelNpZ24sIHpFeHAsIHpTaWcgKTsKKworfQorCisvKgorLS0tLS0tLS0tLS0tLS0tLS0t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eHA7CisgICAgYVNpZyA8PD0gNzsKKyAgICBiU2lnIDw8PSA3OworICAgIGlmICggMCA8IGV4cERpZmYgKSBnb3RvIGFFeHBCaWdnZXI7CisgICAgaWYgKCBleHBEaWZmIDwgMCApIGdvdG8gYkV4cEJpZ2dlcjsKKyAgICBpZiAoIGFFeHAgPT0gMHhGRiApIHsKKyAgICAgICAgaWYgKCBhU2lnIHwgYlNpZyApIHJldHVybiBwcm9wYWdhdGVGbG9hdDMyTmFOKCBhLCBiICk7CisgICAgICAgIGZsb2F0X3JhaXNlKCBmbG9hdF9mbGFnX2ludmFsaWQgKTsKKyAgICAgICAgcmV0dXJuIGZsb2F0MzJfZGVmYXVsdF9uYW47CisgICAgfQorICAgIGlmICggYUV4cCA9PSAwICkgeworICAgICAgICBhRXhwID0gMTsKKyAgICAgICAgYkV4cCA9IDE7CisgICAgfQorICAgIGlmICggYlNpZyA8IGFTaWcgKSBnb3RvIGFCaWdnZXI7CisgICAgaWYgKCBhU2lnIDwgYlNpZyApIGdvdG8gYkJpZ2dlcjsKKyAgICByZXR1cm4gcGFja0Zsb2F0MzIoIGZsb2F0X3JvdW5kaW5nX21vZGUgPT0gZmxvYXRfcm91bmRfZG93biwgMCwgMCApOworIGJFeHBCaWdnZXI6CisgICAgaWYgKCBiRXhwID09IDB4RkYgKSB7CisgICAgICAgIGlmICggYlNpZyApIHJldHVybiBwcm9wYWdhdGVGbG9hdDMyTmFOKCBhLCBiICk7CisgICAgICAgIHJldHVybiBwYWNrRmxvYXQzMiggelNpZ24gXiAxLCAweEZGLCAwICk7CisgICAgfQorICAgIGlmICggYUV4cCA9PSAwICkgeworICAgICAgICArK2V4cERpZmY7CisgICAgfQorICAgIGVsc2UgeworICAgICAgICBhU2lnIHw9IDB4NDAwMDAwMDA7CisgICAgfQorICAgIHNoaWZ0MzJSaWdodEphbW1pbmcoIGFTaWcsIC0gZXhwRGlmZiwgJmFTaWcgKTsKKyAgICBiU2lnIHw9IDB4NDAwMDAwMDA7Cis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KCBhICk7CisgICAgYUV4cCA9IGV4dHJhY3RGbG9hdDMyRXhwKCBhICk7CisgICAgYVNpZ24gPSBleHRyYWN0RmxvYXQzMlNpZ24oIGEgKTsKKyAgICBiU2lnID0gZXh0cmFjdEZsb2F0MzJGcmFjKCBiICk7CisgICAgYkV4cCA9IGV4dHJhY3RGbG9hdDMyRXhwKCBiICk7CisgICAgYlNpZ24gPSBleHRyYWN0RmxvYXQzMlNpZ24oIGIgKTsKKyAgICB6U2lnbiA9IGFTaWduIF4gYlNpZ247CisgICAgaWYgKCBhRXhwID09IDB4RkYgKSB7CisgICAgICAgIGlmICggYVNpZyB8fCAoICggYkV4cCA9PSAweEZGICkgJiYgYlNpZyApICkgeworICAgICAgICAgICAgcmV0dXJuIHByb3BhZ2F0ZUZsb2F0MzJOYU4oIGEsIGIgKTsKKyAgICAgICAgfQorICAgICAgICBpZiAoICggYkV4cCB8IGJTaWcgKSA9PSAwICkgeworICAgICAgICAgICAgZmxvYXRfcmFpc2UoIGZsb2F0X2ZsYWdfaW52YWxpZCApOworICAgICAgICAgICAgcmV0dXJuIGZsb2F0MzJfZGVmYXVsdF9uYW47CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIHBhY2tGbG9hdDMyKCB6U2lnbiwgMHhGRiwgMCApOworICAgIH0KKyAgICBpZiAoIGJFeHAgPT0gMHhGRiApIHsKKyAgICAgICAgaWYgKCBiU2lnICkgcmV0dXJuIHByb3BhZ2F0ZUZsb2F0MzJOYU4oIGEsIGIgKTsKKyAgICAgICAgaWYgKCAoIGFFeHAgfCBhU2lnICkgPT0gMCApIHsKKyAgICAgICAgICAgIGZsb2F0X3JhaXNlKCBmbG9hdF9mbGFnX2ludmFsaWQgKTsKKyAgICAgICAgICAgIHJldHVybiBmbG9hdDMyX2RlZmF1bHRfbmFuOworICAgICAgICB9CisgICAgICAgIHJldHVybiBwYWNrRmxvYXQzMiggelNpZ24sIDB4RkYsIDAgKTsKKyAgICB9CisgICAgaWYgKCBhRXh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GVmYXVsdF9uYW47CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIHBhY2tGbG9hdDMyKCB6U2lnbiwgMHhGRiwgMCApOworICAgIH0KKyAgICBpZiAoIGJFeHAgPT0gMHhGRiApIHsKKyAgICAgICAgaWYgKCBiU2lnICkgcmV0dXJuIHByb3BhZ2F0ZUZsb2F0MzJOYU4oIGEsIGIgKTsKKyAgICAgICAgcmV0dXJuIHBhY2tGbG9hdDMyKCB6U2lnbiwgMCwgMCApOworICAgIH0KKyAgICBpZiAoIGJFeHAgPT0gMCApIHsKKyAgICAgICAgaWYgKCBiU2lnID09IDAgKSB7CisgICAgICAgICAgICBpZiAoICggYUV4cCB8IGFTaWcgKSA9PSAwICkgeworICAgICAgICAgICAgICAgIGZsb2F0X3JhaXNlKCBmbG9hdF9mbGFnX2ludmFsaWQgKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gZmxvYXQzMl9kZWZhdWx0X25hbjsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGZsb2F0X3JhaXNlKCBmbG9hdF9mbGFnX2RpdmJ5emVybyApOworICAgICAgICAgICAgcmV0dXJuIHBhY2tGbG9hdDMyKCB6U2lnbiwgMHhGRiwgMCApOworICAgICAgICB9CisgICAgICAgIG5vcm1hbGl6ZUZsb2F0MzJTdWJub3JtYWwoIGJTaWcsICZiRXhwLCAmYlNpZyApOworICAgIH0KKyAgICBpZiAoIGFFeHAgPT0gMCApIHsKKyAgICAgICAgaWYgKCBhU2lnID09IDAgKSByZXR1cm4gcGFja0Zsb2F0MzIoIHpTaWduLCAwLCAwICk7CisgICAgICAgIG5vcm1hbGl6ZUZsb2F0MzJTdWJub3JtYWwoIGFTaWcsICZhRXhwLCAmYVNpZyApOworICAgIH0KKyAgICB6RXhwID0gYUV4cCAtIGJFeHAgKyAweDdEOworICAgIGFTaWcgPSAoIGFTaWcgfCAweDAwODAwMDAwICk8PDc7CisgICAgYlNpZyA9ICggYlNpZyB8IDB4MDA4MDAwMDA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c7CisgICAgYml0czMyIHE7CisgICAgYml0czY0IGFTaWc2NCwgYlNpZzY0LCBxNjQ7CisgICAgYml0czMyIGFsdGVybmF0ZUFTaWc7CisgICAgc2JpdHMzMiBzaWdNZWFuOworCisgICAgYVNpZyA9IGV4dHJhY3RGbG9hdDMyRnJhYyggYSApOworICAgIGFFeHAgPSBleHRyYWN0RmxvYXQzMkV4cCggYSApOworICAgIGFTaWduID0gZXh0cmFjdEZsb2F0MzJTaWduKCBhICk7CisgICAgYlNpZyA9IGV4dHJhY3RGbG9hdDMyRnJhYyggYiApOworICAgIGJFeHAgPSBleHRyYWN0RmxvYXQzMkV4cCggYiApOworICAgIGJTaWduID0gZXh0cmFjdEZsb2F0MzJTaWduKCBiICk7CisgICAgaWYgKCBhRXhwID09IDB4RkYgKSB7CisgICAgICAgIGlmICggYVNpZyB8fCAoICggYkV4cCA9PSAweEZGICkgJiYgYlNpZyApICkgeworICAgICAgICAgICAgcmV0dXJuIHByb3BhZ2F0ZUZsb2F0MzJOYU4oIGEsIGIgKTsKKyAgICAgICAgfQorICAgICAgICBmbG9hdF9yYWlzZSggZmxvYXRfZmxhZ19pbnZhbGlkICk7CisgICAgICAgIHJldHVybiBmbG9hdDMyX2RlZmF1bHRfbmFuOworICAgIH0KKyAgICBpZiAoIGJFeHAgPT0gMHhGRiApIHsKKyAgICAgICAgaWYgKCBiU2lnICkgcmV0dXJuIHByb3BhZ2F0ZUZsb2F0MzJOYU4oIGEsIGIgKTsKKyAgICAgICAgcmV0dXJuIGE7CisgICAgfQorICAgIGlmICggYkV4cCA9PSAwICkgeworICAgICAgICBpZiAoIGJTaWcgPT0gMCApIHsKKyAgICAgICAgICAgIGZsb2F0X3JhaXNlKCBmbG9hdF9mbGFnX2ludmFsaWQgKTsKKyAgICAgICAgICAgIHJldHVybiBmbG9hdDMyX2RlZmF1bHRfbmFuOworICAgICAgICB9CisgICAgICAgIG5vcm1hbGl6ZUZsb2F0MzJTdWJub3JtYWwoIGJTaWcsICZiRXhwLCAmYlNpZyApOworICAgIH0KKyAgICBpZiAoIGFFeHAgPT0gMCApIHsKKyAgICAgICAgaWYgKCBhU2lnID09IDAgKSByZXR1cm4gYTsKKyAgICAgICAgbm9ybWFsaXplRmxvYXQzMlN1Ym5vcm1hbCggYVNpZywgJmFFeHAsICZhU2lnICk7CisgICAgfQorICAgIGV4cERpZmYgPSBhRXhwIC0gYkV4cDsKKyAgICBhU2lnIHw9IDB4MDA4MDAwMDA7CisgICAgYlNpZyB8PSAweDAwODAwMDAwOworICAgIGlmICggZXhwRGlmZiA8IDMyICkgeworICAgICAgICBhU2lnIDw8PSA4OworICAgICAgICBiU2lnIDw8PSA4OworICAgICAgICBpZiAoIGV4cERpZmYgPCAwICkgeworICAgICAgICAgICAgaWYgKCBleHBEaWZmIDwgLTEgKSByZXR1cm4gYTsKKyAgICAgICAgICAgIGFTaWcgPj49IDE7CisgICAgICAgIH0KKyAgICAgICAgcSA9ICggYlNpZyA8PSBhU2lnICk7CisgICAgICAgIGlmICggcSApIGFTaWcgLT0gYlNpZzsKKyAgICAgICAgaWYgKCAwIDwgZXhwRGlmZiApIHsKKyAgICAgICAgICAgIHEgPSAoICggKGJpdHM2NCkgYVNpZyApPDwzMiApIC8gYlNpZzsKKyAgICAgICAgICAgIHEgPj49IDMyIC0gZXhwRGlmZjsKKyAgICAgICAgICAgIGJTaWcgPj49IDI7CisgICAgICAgICAgICBhU2lnID0gKCAoIGFTaWc+PjEgKTw8KCBleHBEaWZmIC0gMSApICkgLSBiU2lnICogcTsKKyAgICAgICAgfQorICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgIGFTaWcgPj49IDI7CisgICAgICAgICAgICBiU2lnID4+PSAyOworICAgICAgICB9CisgICAgfQorICAgIGVsc2UgeworICAgICAgICBpZiAoIGJTaWcgPD0gYVNpZyApIGFTaWcgLT0gYlNpZzsKKyAgICAgICAgYVNpZzY0ID0gKCAoYml0czY0KSBhU2lnICk8PDQwOworICAgICAgICBiU2lnNjQgPSAoIChiaXRzNjQpIGJTaWcgKTw8NDA7CisgICAgICAgIGV4cERpZmYgLT0gNjQ7CisgICAgICAgIHdoaWxlICggMCA8IGV4cERpZmYgKSB7CisgICAgICAgICAgICBxNjQgPSBlc3RpbWF0ZURpdjEyOFRvNjQoIGFTaWc2NCwgMCwgYlNpZzY0ICk7CisgICAgICAgICAgICBxNjQgPSAoIDIgPCBxNjQgKSA/IHE2NCAtIDIgOiAwOworICAgICAgICAgICAgYVNpZzY0ID0gLSAoICggYlNpZyAqIHE2NCApPDwzOCApOworICAgICAgICAgICAgZXhwRGlmZiAtPSA2MjsKKyAgICAgICAgfQorICAgICAgICBleHBEaWZmICs9IDY0OworICAgICAgICBxNjQgPSBlc3RpbWF0ZURpdjEyOFRvNjQoIGFTaWc2NCwgMCwgYlNpZzY0ICk7CisgICAgICAgIHE2NCA9ICggMiA8IHE2NCApID8gcTY0IC0gMiA6IDA7CisgICAgICAgIHEgPSBxNjQ+PiggNjQgLSBleHBEaWZmICk7CisgICAgICAgIGJTaWcgPDw9IDY7CisgICAgICAgIGFTaWcgPSAoICggYVNpZzY0Pj4zMyApPDwoIGV4cERpZmYgLSAxICkgKSAtIGJTaWcgKiBxOworICAgIH0KKyAgICBkbyB7CisgICAgICAgIGFsdGVybmF0ZUFTaWcgPSBhU2lnOworICAgICAgICArK3E7CisgICAgICAgIGFTaWcgLT0gYlNpZzsKKyAgICB9IHdoaWxlICggMCA8PSAoc2JpdHMzMikgYVNpZyApOworICAgIHNpZ01lYW4gPSBhU2lnICsgYWx0ZXJuYXRlQVNpZzsKKyAgICBpZiAoICggc2lnTWVhbiA8IDAgKSB8fCAoICggc2lnTWVhbiA9PSAwICkgJiYgKCBxICYgMSApICkgKSB7CisgICAgICAgIGFTaWcgPSBhbHRlcm5hdGVBU2lnOworICAgIH0KKyAgICB6U2lnbiA9ICggKHNiaXRzMzIpIGFTaWcgPCAwICk7CisgICAgaWYgKCB6U2lnbiApIGFTaWcgPSAtIGFTaWc7CisgIC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gICAgIHJldHVybiBmbG9hdDMyX2RlZmF1bHRfbmFuOworICAgIH0KKyAgICBpZiAoIGFTaWduICkgeworICAgICAgICBpZiAoICggYUV4cCB8IGFTaWcgKSA9PSAwICkgcmV0dXJuIGE7CisgICAgICAgIGZsb2F0X3JhaXNlKCBmbG9hdF9mbGFnX2ludmFsaWQgKTsKKyAgICAgICAgcmV0dXJuIGZsb2F0MzJfZGVmYXVsdF9uYW47CisgICAgfQorICAgIGlmICggYUV4cCA9PSAwICkgeworICAgICAgICBpZiAoIGFTaWcgPT0gMCApIHJldHVybiAwOworICAgICAgICBub3JtYWxpemVGbG9hdDMyU3Vibm9ybWFsKCBhU2lnLCAmYUV4cCwgJmFTaWcgKTsKKyAgICB9CisgICAgekV4cCA9ICggKCBhRXhwIC0gMHg3RiApPj4xICkgKyAweDdFOworICAgIGFTaWcgPSAoIGFTaWcgfCAweDAwODAwMDAwICk8PDg7CisgICAgelNpZyA9IGVzdGltYXRlU3FydDMyKCBhRXhwLCBhU2lnICkgKyAyOworICAgIGlmICggKCB6U2lnICYgMHg3RiApIDw9IDUgKSB7CisgICAgICAgIGlmICggelNpZyA8IDIgKSB7CisgICAgICAgICAgICB6U2lnID0gMHhGRkZGRkZGRjsKKyAgICAgICAgfQorICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgIGFTaWcgPj49IGFFeHAgJiAxOworICAgICAgICAgICAgdGVybSA9ICggKGJpdHM2NCkgelNpZyApICogelNpZzsKKyAgICAgICAgICAgIHJlbSA9ICggKCAoYml0czY0KSBhU2lnICk8PDMyICkgLSB0ZXJtOworICAgICAgICAgICAgd2hpbGUgKCAoc2JpdHM2NCkgcmVtIDwgMCApIHsKKyAgICAgICAgICAgICAgICAtLXpTaWc7CisgICAgICAgICAgICAgICAgcmVtICs9ICggKCAoYml0czY0KSB6U2lnICk8PDEgKSB8IDE7CisgICAgICAgICAgICB9CisgICAgICAgICAgICB6U2lnIHw9ICggcmVtICE9IDAgKTsKKyAgICAgICAgfQor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cmFjKCBhICkgKSB7CisgICAgICAgICAgICByZXR1cm4gcHJvcGFnYXRlRmxvYXQ2NE5hTiggYSwgYSApOworICAgICAgICB9CisgICAgICAgIHJldHVybiBhOworICAgIH0KKyAgICBpZiAoIGFFeHAgPD0gMHgzRkUgKSB7CisgICAgICAgIGlmICggKGJpdHM2NCkgKCBhPDwxICkgPT0gMCApIHJldHVybiBhOworICAgICAgICBmbG9hdF9leGNlcHRpb25fZmxhZ3MgfD0gZmxvYXRfZmxhZ19pbmV4YWN0OworICAgICAgICBhU2lnbiA9IGV4dHJhY3RGbG9hdDY0U2lnbiggYSApOworICAgICAgICBzd2l0Y2ggKCBmbG9hdF9yb3VuZGluZ19tb2RlICkgeworICAgICAgICAgY2FzZSBmbG9hdF9yb3VuZF9uZWFyZXN0X2V2ZW46CisgICAgICAgICAgICBpZiAoICggYUV4cCA9PSAweDNGRSApICYmIGV4dHJhY3RGbG9hdDY0RnJhYyggYSApICkgeworICAgICAgICAgICAgICAgIHJldHVybiBwYWNrRmxvYXQ2NCggYVNpZ24sIDB4M0ZGLCAwICk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgIGNhc2UgZmxvYXRfcm91bmRfZG93bjoKKyAgICAgICAgICAgIHJldHVybiBhU2lnbiA/IExJVDY0KCAweEJGRjAwMDAwMDAwMDAwMDAgKSA6IDA7CisgICAgICAgICBjYXNlIGZsb2F0X3JvdW5kX3VwOgorICAgICAgICAgICAgcmV0dXJuCisgICAgICAgICAgICBhU2lnbiA/IExJVDY0KCAweDgwMDAwMDAwMDAwMDAwMDAgKSA6IExJVDY0KCAweDNGRjAwMDAwMDAwMDAwMDAgKTsKKyAgICAgICAgfQorICAgICAgICByZXR1cm4gcGFja0Zsb2F0NjQoIGFTaWduLCAwLCAwICk7CisgICAgfQorICAgIGxhc3RCaXRNYXNrID0gMTsKKyAgICBsYXN0Qml0TWFzayA8PD0gMHg0MzMgLSBhRXhwOworICAgIHJvdW5kQml0c01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sKKyAgICAgICAgfQorICAgICAgICBzaGlmdDY0UmlnaHRKYW1taW5nKCBiU2lnLCBleHBEaWZmLCAmYlNpZyApOworICAgICAgICB6RXhwID0gYUV4cDsKKyAgICB9CisgICAgZWxzZSBpZiAoIGV4cERpZmYgPCAwICkgeworICAgICAgICBpZiAoIGJFeHAgPT0gMHg3RkYgKSB7CisgICAgICAgICAgICBpZiAoIGJTaWcgKSByZXR1cm4gcHJvcGFnYXRlRmxvYXQ2NE5hTiggYSwgYiApOworICAgICAgICAgICAgcmV0dXJuIHBhY2tGbG9hdDY0KCB6U2lnbiwgMHg3RkYsIDAgKTsKKyAgICAgICAgfQorICAgICAgICBpZiAoIGFFeHAgPT0gMCApIHsKKyAgICAgICAgICAgICsrZXhwRGlmZjsKKyAgICAgICAgfQorICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgIGFTaWcgfD0gTElUNjQoIDB4MjAwMDAwMDAwMDAwMDAwMCApOworICAgICAgICB9CisgICAgICAgIHNoaWZ0NjRSaWdodEphbW1pbmcoIGFTaWcsIC0gZXhwRGlmZiwgJmFTaWcgKTsKKyAgICAgICAgekV4cCA9IGJFeHA7CisgICAgfQorICAgIGVsc2UgeworICAgICAgICBpZiAoIGFFeHAgPT0gMHg3RkYgKSB7CisgICAgICAgICAgICBpZiAoIGFTaWcgfCBiU2lnICkgcmV0dXJuIHByb3BhZ2F0ZUZsb2F0NjROYU4oIGEsIGIgKTsKKyAgICAgICAgICAgIHJldHVybiBhOworICAgICAgICB9CisgICAgICAgIGlmICggYUV4cCA9PSAwICkgcmV0dXJuIHBhY2tGbG9hdDY0KCB6U2lnbiwgMCwgKCBhU2lnICsgYlNpZyApPj45ICk7CisgICAgICAgIHpTaWcgPSBMSVQ2NCggMHg0MDAwMDAwMDAwMDAwMDAwICkgKyBhU2lnICsgYlNpZzsKKyAgICAgICAgekV4cCA9IGFFeHA7CisgICAgICAgIGdvdG8gcm91bmRBbmRQYWNrOworICAgIH0KKyAgICBhU2lnIHw9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biApCit7CisgICAgaW50MTYgYUV4cCwgYkV4cCwgekV4cDsKKyAgICBiaXRzNjQgYVNpZywgYlNpZywgelNpZzsKKyAgICBpbnQxNiBleHBEaWZmOworCisgICAgYVNpZyA9IGV4dHJhY3RGbG9hdDY0RnJhYyggYSApOworICAgIGFFeHAgPSBleHRyYWN0RmxvYXQ2NEV4cCggYSApOworICAgIGJTaWcgPSBleHRyYWN0RmxvYXQ2NEZyYWMoIGIgKTsKKyAgICBiRXhwID0gZXh0cmFjdEZsb2F0NjRFeHAoIGIgKTsKKyAgICBleHBEaWZmID0gYUV4cCAtIGJFeHA7CisgICAgYVNpZyA8PD0gMTA7CisgICAgYlNpZyA8PD0gMTA7CisgICAgaWYgKCAwIDwgZXhwRGlmZiApIGdvdG8gYUV4cEJpZ2dlcjsKKyAgICBpZiAoIGV4cERpZmYgPCAwICkgZ290byBiRXhwQmlnZ2VyOworICAgIGlmICggYUV4cCA9PSAweDdGRiApIHsKKyAgICAgICAgaWYgKCBhU2lnIHwgYlNpZyApIHJldHVybiBwcm9wYWdhdGVGbG9hdDY0TmFOKCBhLCBiICk7CisgICAgICAgIGZsb2F0X3JhaXNlKCBmbG9hdF9mbGFnX2ludmFsaWQgKTsKKyAgICAgICAgcmV0dXJuIGZsb2F0NjRfZGVmYXVsdF9uYW47CisgICAgfQorICAgIGlmICggYUV4cCA9PSAwICkgeworICAgICAgICBhRXhwID0gMTsKKyAgICAgICAgYkV4cCA9IDE7CisgICAgfQorICAgIGlmICggYlNpZyA8IGFTaWcgKSBnb3RvIGFCaWdnZXI7CisgICAgaWYgKCBhU2lnIDwgYlNpZyApIGdvdG8gYkJpZ2dlcjsKKyAgICByZXR1cm4gcGFja0Zsb2F0NjQoIGZsb2F0X3JvdW5kaW5nX21vZGUgPT0gZmxvYXRfcm91bmRfZG93biwgMCwgMCApOworIGJFeHBCaWdnZXI6CisgICAgaWYgKCBiRXhwID09IDB4N0ZGICkgeworICAgICAgICBpZiAoIGJTaWcgKSByZXR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xvYXQ2NCggelNpZ24sIDB4N0ZGLCAwICk7CisgICAgfQorICAgIGlmICggYkV4cCA9PSAweDdGRiApIHsKKyAgICAgICAgaWYgKCBiU2lnICkgcmV0dXJuIHByb3BhZ2F0ZUZsb2F0NjROYU4oIGEsIGIgKTsKKyAgICAgICAgaWYgKCAoIGFFeHAgfCBhU2lnICkgPT0gMCApIHsKKyAgICAgICAgICAgIGZsb2F0X3JhaXNlKCBmbG9hdF9mbGFnX2ludmFsaWQgKTsKKyAgICAgICAgICAgIHJldHVybiBmbG9hdDY0X2RlZmF1bHRfbmFuOworICAgICAgICB9CisgICAgICAgIHJldHVybiBwYWNrRmxvYXQ2NCggelNpZ24sIDB4N0ZGLCAwICk7CisgICAgfQorICAgIGlmICggYUV4cCA9PSAwICkgeworICAgICAgICBpZiAoIGFTaWcgPT0gMCApIHJldHVybiBwYWNrRmxvYXQ2NCggelNpZ24sIDAsIDAgKTsKKyAgICAgICAgbm9ybWFsaXplRmxvYXQ2NFN1Ym5vcm1hbCggYVNpZywgJmFFeHAsICZhU2lnICk7CisgICAgfQorICAgIGlmICggYkV4cCA9PSAwICkgeworICAgICAgICBpZiAoIGJTaWcgPT0gMCApIHJldHVybiBwYWNrRmxvYXQ2NCggelNpZ24sIDAsIDAgKTsKKyAgICAgICAgbm9ybWFsaXplRmxvYXQ2NFN1Ym5vcm1hbCggYlNpZywgJmJFeHAsICZiU2lnICk7CisgICAgfQorICAgIHpFeHAgPSBhRXhwICsgYkV4cCAtIDB4M0ZGOworICAgIGFTaWcgPSAoIGFTaWcgfCBMSVQ2NCggMHgwMDEwMDAwMDAwMDAwMDAwICkgKTw8MTA7CisgICAgYlNpZyA9ICggYlNpZyB8IExJVDY0KCAweDAwMTAwMDAwMDAwMDAwMDAgKSApPDwxMTsKKyAgICBtdWw2NFRvMTI4KCBhU2lnLCBiU2lnLCAmelNpZzAsICZ6U2lnMSApOworICAgIHpTaWcwIHw9ICggelNpZzEgIT0gMCApOworICAgIGlmICggMCA8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worICAgIGJTaWcgPSBleHRyYWN0RmxvYXQ2NEZyYWMoIGIgKTsKKyAgICBiRXhwID0gZXh0cmFjdEZsb2F0NjRFeHAoIGIgKTsKKyAgICBiU2lnbiA9IGV4dHJhY3RGbG9hdDY0U2lnbiggYiApOworICAgIHpTaWduID0gYVNpZ24gXiBiU2lnbjsKKyAgICBpZiAoIGFFeHAgPT0gMHg3RkYgKSB7CisgICAgICAgIGlmICggYVNpZyApIHJldHVybiBwcm9wYWdhdGVGbG9hdDY0TmFOKCBhLCBiICk7CisgICAgICAgIGlmICggYkV4cCA9PSAweDdGRiApIHsKKyAgICAgICAgICAgIGlmICggYlNpZyApIHJldHVybiBwcm9wYWdhdGVGbG9hdDY0TmFOKCBhLCBiICk7CisgICAgICAgICAgICBmbG9hdF9yYWlzZSggZmxvYXRfZmxhZ19pbnZhbGlkICk7CisgICAgICAgICAgICByZXR1cm4gZmxvYXQ2NF9kZWZhdWx0X25hbjsKKyAgICAgICAgfQorICAgICAgICByZXR1cm4gcGFja0Zsb2F0NjQoIHpTaWduLCAweDdGRiwgMCApOworICAgIH0KKyAgICBpZiAoIGJFeHAgPT0gMHg3RkYgKSB7CisgICAgICAgIGlmICggYlNpZyApIHJldHVybiBwcm9wYWdhdGVGbG9hdDY0TmFOKCBhLCBiICk7CisgICAgICAgIHJldHVybiBwYWNrRmxvYXQ2NCggelNpZ24sIDAsIDAgKTsKKyAgICB9CisgICAgaWYgKCBiRXhwID09IDAgKSB7CisgICAgICAgIGlmICggYlNpZyA9PSAwICkgeworICAgICAgICAgICAgaWYgKCAoIGFFeHAgfCBhU2lnICkgPT0gMCApIHsKKyAgICAgICAgICAgICAgICBmbG9hdF9yYWlzZSggZmxvYXRfZmxhZ19pbnZhbGlkICk7CisgICAgICAgICAgICAgICAgcmV0dXJuIGZsb2F0NjRfZGVmYXVsdF9uYW47CisgICAgICAgICAgICB9CisgICAgICAgICAgICBmbG9hdF9yYWlzZSggZmxvYXRfZmxhZ19kaXZieXplcm8gKTsKKyAgICAgICAgICAgIHJldHVybiBwYWNrRmxvYXQ2NCggelNpZ24sIDB4N0ZGLCAwICk7CisgICAgICAgIH0KKyAgICAgICAgbm9ybWFsaXplRmxvYXQ2NFN1Ym5vcm1hbCggYlNpZywgJmJFeHAsICZiU2lnICk7CisgICAgfQorICAgIGlmICggYUV4cCA9PSAwICkgeworICAgICAgICBpZiAoIGFTaWcgPT0gMCApIHJldHVybiBwYWNrRmxvYXQ2NCggelNpZ24sIDAsIDAgKTsKKyAgICAgICAgbm9ybWFsaXplRmxvYXQ2NFN1Ym5vcm1hbCggYVNpZywgJmFFeHAsICZhU2lnICk7CisgICAgfQorICAgIHpFeHAgPSBhRXhwIC0gYkV4cCArIDB4M0ZEOworICAgIGFTaWcgPSAoIGFTaWcgfCBMSVQ2NCggMHgwMDEwMDAwMDAwMDAwMDAwICkgKTw8MTA7CisgICAgYlNpZyA9ICggYlNpZyB8IExJVDY0KCAweDAwMTAwMDAwMDAwMDAwMDAgKSApPDwxMTsKKyAgICBpZiAoIGJTaWcgPD0gKCBhU2lnICsgYVNpZyApICkgeworICAgICAgICBhU2lnID4+PSAxOworICAgICAgICArK3pFeHA7CisgICAgfQorICAgIHpTaWcgPSBlc3RpbWF0ZURpdjEyOFRvNjQoIGFTaWcsIDAsIGJTaWcgKTsKKyAgICBpZiAoICggelNpZyAmIDB4MUZGICkgPD0gMiApIHsKKyAgICAgICAgbXVsNjRUbzEyOCggYlNpZywgelNpZywgJnRlcm0wLCAmdGVybTEgKTsKKyAgICAgICAgc3ViMTI4KCBhU2lnLCAwLCB0ZXJtMCwgdGVybTEsICZyZW0wLCAmcmVtMSApOworICAgICAgICB3aGlsZSAoIChzYml0czY0KSByZW0wIDwgMCApIHsKKyAgICAgICAgICAgIC0telNpZzsKKyAgICAgICAgICAgIGFkZDEyOCggcmVtMCwgcmVtMSwgMCwgYlNpZywgJnJlbTAsICZyZW0xICk7CisgICAgICAgIH0KKyAgICAgICAgelNpZyB8PSAoIHJlbT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YXQ2NEV4cCggYiApOworICAgIGJTaWduID0gZXh0cmFjdEZsb2F0NjRTaWduKCBiICk7CisgICAgaWYgKCBhRXhwID09IDB4N0ZGICkgeworICAgICAgICBpZiAoIGFTaWcgfHwgKCAoIGJFeHAgPT0gMHg3RkYgKSAmJiBiU2lnICkgKSB7CisgICAgICAgICAgICByZXR1cm4gcHJvcGFnYXRlRmxvYXQ2NE5hTiggYSwgYiApOworICAgICAgICB9CisgICAgICAgIGZsb2F0X3JhaXNlKCBmbG9hdF9mbGFnX2ludmFsaWQgKTsKKyAgICAgICAgcmV0dXJuIGZsb2F0NjRfZGVmYXVsdF9uYW47CisgICAgfQorICAgIGlmICggYkV4cCA9PSAweDdGRiApIHsKKyAgICAgICAgaWYgKCBiU2lnICkgcmV0dXJuIHByb3BhZ2F0ZUZsb2F0NjROYU4oIGEsIGIgKTsKKyAgICAgICAgcmV0dXJuIGE7CisgICAgfQorICAgIGlmICggYkV4cCA9PSAwICkgeworICAgICAgICBpZiAoIGJTaWcgPT0gMCApIHsKKyAgICAgICAgICAgIGZsb2F0X3JhaXNlKCBmbG9hdF9mbGFnX2ludmFsaWQgKTsKKyAgICAgICAgICAgIHJldHVybiBmbG9hdDY0X2RlZmF1bHRfbmFuOworICAgICAgICB9CisgICAgICAgIG5vcm1hbGl6ZUZsb2F0NjRTdWJub3JtYWwoIGJTaWcsICZiRXhwLCAmYlNpZyApOworICAgIH0KKyAgICBpZiAoIGFFeHAgPT0gMCApIHsKKyAgICAgICAgaWYgKCBhU2lnID09IDAgKSByZXR1cm4gYTsKKyAgICAgICAgbm9ybWFsaXplRmxvYXQ2NFN1Ym5vcm1hbCggYVNpZywgJmFFeHAsICZhU2lnICk7CisgICAgfQorICAgIGV4cERpZmYgPSBhRXhwIC0gYkV4cDsKKyAgICBhU2lnID0gKCBhU2lnIHwgTElUNjQoIDB4MDAxMDAwMDAwMDAwMDAwMCApICk8PDExOworICAgIGJTaWcgPSAoIGJTaWcgfCBMSVQ2NCggMHgwMDEwMDAwMDAwMDAwMDAwICkgKTw8MTE7CisgICAgaWYgKCBleHBEaWZmIDwgMCApIHsKKyAgICAgICAgaWYgKCBleHBEaWZmIDwgLTEgKSByZXR1cm4gYTsKKyAgICAgICAgYVNpZyA+Pj0gMTsKKyAgICB9CisgICAgcSA9ICggYlNpZyA8PSBhU2lnICk7CisgICAgaWYgKCBxICkgYVNpZyAtPSBiU2lnOworICAgIGV4cERpZmYgLT0gNjQ7CisgICAgd2hpbGUgKCAwIDwgZXhwRGlmZiApIHsKKyAgICAgICAgcSA9IGVzdGltYXRlRGl2MTI4VG82NCggYVNpZywgMCwgYlNpZyApOworICAgICAgICBxID0gKCAyIDwgcSApID8gcSAtIDIgOiAwOworICAgICAgICBhU2lnID0gLSAoICggYlNpZz4+MiApICogcSApOworICAgICAgICBleHBEaWZmIC09IDYyOworICAgIH0KKyAgICBleHBEaWZmICs9IDY0OworICAgIGlmICggMCA8IGV4cERpZmYgKSB7CisgICAgICAgIHEgPSBlc3RpbWF0ZURpdjEyOFRvNjQoIGFTaWcsIDAsIGJTaWcgKTsKKyAgICAgICAgcSA9ICggMiA8IHEgKSA/IHEgLSAyIDogMDsKKyAgICAgICAgcSA+Pj0gNjQgLSBleHBEaWZmOworICAgICAgICBiU2lnID4+PSAyOworICAgICAgICBhU2lnID0gKCAoIGFTaWc+PjEgKTw8KCBleHBEaWZmIC0gMSApICkgLSBiU2lnICogcTsKKyAgICB9CisgICAgZWxzZSB7CisgICAgICAgIGFTaWcgPj49IDI7CisgICAgICAgIGJTaWcgPj49IDI7CisgICAgfQorICAgIGRvIHsKKyAgICAgICAgYWx0ZXJuYXRlQVNpZyA9IGFTaWc7CisgICAgICAgICsrcTsKKyAgICAgICAgYVNpZyAtPSBiU2lnOworICAgIH0gd2hpbGUgKCAwIDw9IChzYml0czY0KSBhU2lnICk7CisgICAgc2lnTWVhbiA9IGFTaWcgKyBhbHRlcm5hdGVBU2lnOworICAgIGlmICggKCBzaWdNZWFuIDwgMCAp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cCggYSApOworICAgIGFTaWduID0gZXh0cmFjdEZsb2F0NjRTaWduKCBhICk7CisgICAgaWYgKCBhRXhwID09IDB4N0ZGICkgeworICAgICAgICBpZiAoIGFTaWcgKSByZXR1cm4gcHJvcGFnYXRlRmxvYXQ2NE5hTiggYSwgYSApOworICAgICAgICBpZiAoICEgYVNpZ24gKSByZXR1cm4gYTsKKyAgICAgICAgZmxvYXRfcmFpc2UoIGZsb2F0X2ZsYWdfaW52YWxpZCApOworICAgICAgICByZXR1cm4gZmxvYXQ2NF9kZWZhdWx0X25hbjsKKyAgICB9CisgICAgaWYgKCBhU2lnbiApIHsKKyAgICAgICAgaWYgKCAoIGFFeHAgfCBhU2lnICkgPT0gMCApIHJldHVybiBhOworICAgICAgICBmbG9hdF9yYWlzZSggZmxvYXRfZmxhZ19pbnZhbGlkICk7CisgICAgICAgIHJldHVybiBmbG9hdDY0X2RlZmF1bHRfbmFuOworICAgIH0KKyAgICBpZiAoIGFFeHAgPT0gMCApIHsKKyAgICAgICAgaWYgKCBhU2lnID09IDAgKSByZXR1cm4gMDsKKyAgICAgICAgbm9ybWFsaXplRmxvYXQ2NFN1Ym5vcm1hbCggYVNpZywgJmFFeHAsICZhU2lnICk7CisgICAgfQorICAgIHpFeHAgPSAoICggYUV4cCAtIDB4M0ZGICk+PjEgKSArIDB4M0ZFOworICAgIGFTaWcgfD0gTElUNjQoIDB4MDAxMDAwMDAwMDAwMDAwMCApOworICAgIHpTaWcgPSBlc3RpbWF0ZVNxcnQzMiggYUV4cCwgYVNpZz4+MjEgKTsKKyAgICB6U2lnIDw8PSAzMTsKKyAgICBhU2lnIDw8PSA5IC0gKCBhRXhwICYgMSApOworICAgIHpTaWcgPSBlc3RpbWF0ZURpdjEyOFRvNjQoIGFTaWcsIDAsIHpTaWcgKSArIHpTaWcgKyAyOworICAgIGlmICggKCB6U2lnICYgMHgzRkYgKSA8PSA1ICkgeworICAgICAgICBpZiAoIHpTaWcgPCAyICkgeworICAgICAgICAgICAgelNpZyA9IExJVDY0KCAweEZGRkZGRkZGRkZGRkZGRkYgKTsKKyAgICAgICAgfQorICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgIGFTaWcgPDw9IDI7CisgICAgICAgICAgICBtdWw2NFRvMTI4KCB6U2lnLCB6U2lnLCAmdGVybTAsICZ0ZXJtMSApOworICAgICAgICAgICAgc3ViMTI4KCBhU2lnLCAwLCB0ZXJtMCwgdGVybTEsICZyZW0wLCAmcmVtMSApOworICAgICAgICAgICAgd2hpbGUgKCAoc2JpdHM2NCkgcmVtMCA8IDAgKSB7CisgICAgICAgICAgICAgICAgLS16U2lnOworICAgICAgICAgICAgICAgIHNob3J0U2hpZnQxMjhMZWZ0KCAwLCB6U2lnLCAxLCAmdGVybTAsICZ0ZXJtMSApOworICAgICAgICAgICAgICAgIHRlcm0xIHw9IDE7CisgICAgICAgICAgICAgICAgYWRkMTI4KCByZW0wLCByZW0xLCB0ZXJtMCwgdGVybTEsICZyZW0wLCAmcmVtMSApOworICAgICAgICAgICAgfQorICAgICAgICAgICAgelNpZyB8PSAoICggcmVtMCB8IHJlbTEgKSAhPSAwICk7CisgICAgICAgIH0KKyAgICB9CisgICAgc2hpZnQ2NFJpZ2h0SmFtbWluZyggelNpZywgMSwgJnpTaWcgKTsKKyAgICByZXR1cm4gcm91bmRBbmRQYWNrRmxvYXQ2NCggMCwgekV4cCwgelNpZyApOworCit9CisKKy8qCistLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCitSZXR1cm5zIDEgaWYgdGhlIGRvdWJsZS1wcmVjaXNpb24gZmxvYXRpbmctcG9pbnQgdmFsdWUgYGEnIGlzIGVxdWFsIHRvIHRoZQorY29ycmVzcG9uZGluZyB2YWx1ZSBgYicsIGFuZCAwIG90aGVyd2lzZS4gIFRoZSBjb21wYXJpc29uIGlzIHBlcmZvcm1lZAorYW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gICBpbnQ4IHJvdW5kaW5nTW9kZTsKKyAgICBmbG9hdHg4MCB6OworCisgICAgYUV4cCA9IGV4dHJhY3RGbG9hdHg4MEV4cCggYSApOworICAgIGlmICggMHg0MDNFIDw9IGFFeHAgKSB7CisgICAgICAgIGlmICggKCBhRXhwID09IDB4N0ZGRiApICYmIChiaXRzNjQpICggZXh0cmFjdEZsb2F0eDgwRnJhYyggYSApPDwxICkgKSB7CisgICAgICAgICAgICByZXR1cm4gcHJvcGFnYXRlRmxvYXR4ODBOYU4oIGEsIGEgKTsKKyAgICAgICAgfQorICAgICAgICByZXR1cm4gYTsKKyAgICB9CisgICAgaWYgKCBhRXhwIDw9IDB4M0ZGRSApIHsKKyAgICAgICAgaWYgKCAgICAoIGFFeHAgPT0gMCApCisgICAgICAgICAgICAgJiYgKCAoYml0czY0KSAoIGV4dHJhY3RGbG9hdHg4MEZyYWMoIGEgKTw8MSApID09IDAgKSApIHsKKyAgICAgICAgICAgIHJldHVybiBhOworICAgICAgICB9CisgICAgICAgIGZsb2F0X2V4Y2VwdGlvbl9mbGFncyB8PSBmbG9hdF9mbGFnX2luZXhhY3Q7CisgICAgICAgIGFTaWduID0gZXh0cmFjdEZsb2F0eDgwU2lnbiggYSApOworICAgICAgICBzd2l0Y2ggKCBmbG9hdF9yb3VuZGluZ19tb2RlICkgeworICAgICAgICAgY2FzZSBmbG9hdF9yb3VuZF9uZWFyZXN0X2V2ZW46CisgICAgICAgICAgICBpZiAoICggYUV4cCA9PSAweDNGRkUgKSAmJiAoYml0czY0KSAoIGV4dHJhY3RGbG9hdHg4MEZyYWMoIGEgKTw8MSApCisgICAgICAgICAgICAgICApIHsKKyAgICAgICAgICAgICAgICByZXR1cm4KKyAgICAgICAgICAgICAgICAgICAgcGFja0Zsb2F0eDgwKCBhU2lnbiwgMHgzRkZGLCBMSVQ2NCggMHg4MDAwMDAwMDAwMDAwMDAwICkgKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgY2FzZSBmbG9hdF9yb3VuZF9kb3duOgorICAgICAgICAgICAgcmV0dXJuCisgICAgICAgICAgICAgICAgICBhU2lnbiA/CisgICAgICAgICAgICAgICAgICAgICAgcGFja0Zsb2F0eDgwKCAxLCAweDNGRkYsIExJVDY0KCAweDgwMDAwMDAwMDAwMDAwMDAgKSApCisgICAgICAgICAgICAgICAgOiBwYWNrRmxvYXR4ODAoIDAsIDAsIDAgKTsKKyAgICAgICAgIGNhc2UgZmxvYXRfcm91bmRfdXA6CisgICAgICAgICAgICByZXR1cm4KKyAgICAgICAgICAgICAgICAgIGFTaWduID8gcGFja0Zsb2F0eDgwKCAxLCAwLCAwICkKKyAgICAgICAgICAgICAgICA6IHBhY2tGbG9hdHg4MCggMCwgMHgzRkZGLCBMSVQ2NCggMHg4MDAwMDAwMDAwMDAwMDAwICkgKTsKKyAgICAgICAgfQorICAgICAgICByZXR1cm4gcGFja0Zsb2F0eDgwKCBhU2lnbiwgMCwgMCApOworICAgIH0KKyAgICBsYXN0Qml0TWFzayA9IDE7CisgICAgbGFzdEJpdE1hc2sgPDw9IDB4NDAzRSAtIGFFeHA7CisgICAgcm91bmRCaXRzTWFzayA9IGxhc3RCaXRNYXNrIC0gMTsKKyAgICB6ID0gYTsKKyAgICByb3VuZGluZ01vZGUgPSBmbG9hdF9yb3VuZGluZ19tb2RlOworICAgIGlmICggcm91bmRpbmdNb2RlID09IGZsb2F0X3JvdW5kX25lYXJlc3RfZXZlbiApIHsKKyAgICAgICAgei5sb3cgKz0gbGFzdEJpdE1hc2s+PjE7CisgICAgICAgIGlmICggKCB6LmxvdyAmIHJvdW5kQml0c01hc2sgKSA9PSAwICkgei5sb3cgJj0gfiBsYXN0Qml0TWFzazsKKyAgICB9CisgICAgZWxzZSBpZiAoIHJvdW5kaW5nTW9kZSAhPSBmbG9hdF9yb3VuZF90b196ZXJvICkgeworICAgICAgICBpZiAoIGV4dHJhY3RGbG9hdHg4MFNpZ24oIHogKSBeICggcm91bm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AwMDAwMDAwMDAwMDAwICkgKTsKKyAgICAgICAgfQorICAgICAgICBpZiAoIGFFeHAgPT0gMCApICsrZXhwRGlmZjsKKyAgICAgICAgc2hpZnQ2NEV4dHJhUmlnaHRKYW1taW5nKCBhU2lnLCAwLCAtIGV4cERpZmYsICZhU2lnLCAmelNpZzEgKTsKKyAgICAgICAgekV4cCA9IGJFeHA7CisgICAgfQorICAgIGVsc2UgeworICAgICAgICBpZiAoIGFFeHAgPT0gMHg3RkZGICkgeworICAgICAgICAgICAgaWYgKCAoYml0czY0KSAoICggYVNpZyB8IGJTaWcgKTw8MSApICkgeworICAgICAgICAgICAgICAgIHJldHVybiBwcm9wYWdhdGVGbG9hdHg4ME5hTiggYSwgYiApOworICAgICAgICAgICAgfQorICAgICAgICAgICAgcmV0dXJuIGE7CisgICAgICAgIH0KKyAgICAgICAgelNpZzEgPSAwOworICAgICAgICB6U2lnMCA9IGFTaWcgKyBiU2lnOworICAgICAgICBpZiAoIGFFeHAgPT0gMCApIHsKKyAgICAgICAgICAgIG5vcm1hbGl6ZUZsb2F0eDgwU3Vibm9ybWFsKCB6U2lnMCwgJnpFeHAsICZ6U2lnMCApOworICAgICAgICAgICAgZ290byByb3VuZEFuZFBhY2s7CisgICAgICAgIH0KKyAgICAgICAgekV4cCA9IGFFeHA7CisgICAgICAgIGdvdG8gc2hpZnRSaWdodDE7CisgICAgfQorICAgIAorICAgIHpTaWcwID0gYVNpZyArIGJTaWc7CisKKyAgICBpZiAoIChzYml0czY0KSB6U2lnMCA8IDAgKSBnb3RvIHJvdW5kQW5kUGFjazsgCisgc2hpZnRSaWdodDE6CisgICAgc2hpZnQ2NEV4dHJhUmlnaHRKYW1taW5nKCB6U2lnMCwgelNpZzEsIDEsICZ6U2lnMCwgJnpTaWcxICk7CisgICAgelNpZzAgfD0gTElUNjQoIDB4ODAwMDAwMDAwMDAwMDAwMCApOworICAgICsrekV4cDsKKyByb3VuZEFuZFBhY2s6CisgICAgcmV0dXJuCisgICAgIC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AweDdGRkYsIExJVDY0KCAweDgwMDAwMDAwMDAwMDAwMDAgKSApOworICAgIH0KKyAgICBpZiAoIGJFeHAgPT0gMHg3RkZGICkgeworICAgICAgICBpZiAoIChiaXRzNjQpICggYlNpZzw8MSApICkgcmV0dXJuIHByb3BhZ2F0ZUZsb2F0eDgwTmFOKCBhLCBiICk7CisgICAgICAgIGlmICggKCBhRXhwIHwgYVNpZyApID09IDAgKSB7CisgaW52YWxpZDoKKyAgICAgICAgICAgIGZsb2F0X3JhaXNlKCBmbG9hdF9mbGFnX2ludmFsaWQgKTsKKyAgICAgICAgICAgIHoubG93ID0gZmxvYXR4ODBfZGVmYXVsdF9uYW5fbG93OworICAgICAgICAgICAgei5oaWdoID0gZmxvYXR4ODBfZGVmYXVsdF9uYW5faGlnaDsKKyAgICAgICAgICAgIHJldHVybiB6OworICAgICAgICB9CisgICAgICAgIHJldHVybiBwYWNrRmxvYXR4ODAoIHpTaWduLCAweDdGRkYsIExJVDY0KCAweDgwMDAwMDAwMDAwMDAwMDAgKSApOworICAgIH0KKyAgICBpZiAoIGFFeHAgPT0gMCApIHsKKyAgICAgICAgaWYgKCBhU2lnID09IDAgKSByZXR1cm4gcGFja0Zsb2F0eDgwKCB6U2lnbiwgMCwgMCApOworICAgICAgICBub3JtYWxpemVGbG9hdHg4MFN1Ym5vcm1hbCggYVNpZywgJmFFeHAsICZhU2lnICk7CisgICAgfQorICAgIGlmICggYkV4cCA9PSAwICkgeworICAgICAgICBpZiAoIGJTaWcgPT0gMCApIHJldHVybiBwYWNrRmxvYXR4ODAoIHpTaWduLCAwLCAwICk7CisgICAgICAgIG5vcm1hbGl6ZUZsb2F0eDgwU3Vibm9ybWFsKCBiU2lnLCAmYkV4cCwgJmJTaWcgKTsKKyAgICB9CisgICAgekV4cCA9IGFFeHAgKyBiRXhwIC0gMHgzRkZFOworICAgIG11bDY0VG8xMjgoIGFTaWcsIGJTaWcsICZ6U2lnMCwgJnpTaWcxICk7CisgICAgaWYgKCAwI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yOworICAgIGZsb2F0eDgwIHo7CisKKyAgICBhU2lnID0gZXh0cmFjdEZsb2F0eDgwRnJhYyggYSApOworICAgIGFFeHAgPSBleHRyYWN0RmxvYXR4ODBFeHAoIGEgKTsKKyAgICBhU2lnbiA9IGV4dHJhY3RGbG9hdHg4MFNpZ24oIGEgKTsKKyAgICBiU2lnID0gZXh0cmFjdEZsb2F0eDgwRnJhYyggYiApOworICAgIGJFeHAgPSBleHRyYWN0RmxvYXR4ODBFeHAoIGIgKTsKKyAgICBiU2lnbiA9IGV4dHJhY3RGbG9hdHg4MFNpZ24oIGIgKTsKKyAgICB6U2lnbiA9IGFTaWduIF4gYlNpZ247CisgICAgaWYgKCBhRXhwID09IDB4N0ZGRiApIHsKKyAgICAgICAgaWYgKCAoYml0czY0KSAoIGFTaWc8PDEgKSApIHJldHVybiBwcm9wYWdhdGVGbG9hdHg4ME5hTiggYSwgYiApOworICAgICAgICBpZiAoIGJFeHAgPT0gMHg3RkZGICkgeworICAgICAgICAgICAgaWYgKCAoYml0czY0KSAoIGJTaWc8PDEgKSApIHJldHVybiBwcm9wYWdhdGVGbG9hdHg4ME5hTiggYSwgYiApOworICAgICAgICAgICAgZ290byBpbnZhbGlkOworICAgICAgICB9CisgICAgICAgIHJldHVybiBwYWNrRmxvYXR4ODAoIHpTaWduLCAweDdGRkYsIExJVDY0KCAweDgwMDAwMDAwMDAwMDAwMDAgKSApOworICAgIH0KKyAgICBpZiAoIGJFeHAgPT0gMHg3RkZGICkgeworICAgICAgICBpZiAoIChiaXRzNjQpICggYlNpZzw8MSApICkgcmV0dXJuIHByb3BhZ2F0ZUZsb2F0eDgwTmFOKCBhLCBiICk7CisgICAgICAgIHJldHVybiBwYWNrRmxvYXR4ODAoIHpTaWduLCAwLCAwICk7CisgICAgfQorICAgIGlmICggYkV4cCA9PSAwICkgeworICAgICAgICBpZiAoIGJTaWcgPT0gMCApIHsKKyAgICAgICAgICAgIGlmICggKCBhRXhwIHwgYVNpZyApID09IDAgKSB7CisgaW52YWxpZDoKKyAgICAgICAgICAgICAgICBmbG9hdF9yYWlzZSggZmxvYXRfZmxhZ19pbnZhbGlkICk7CisgICAgICAgICAgICAgICAgei5sb3cgPSBmbG9hdHg4MF9kZWZhdWx0X25hbl9sb3c7CisgICAgICAgICAgICAgICAgei5oaWdoID0gZmxvYXR4ODBfZGVmYXVsdF9uYW5faGlnaDsKKyAgICAgICAgICAgICAgICByZXR1cm4gejsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGZsb2F0X3JhaXNlKCBmbG9hdF9mbGFnX2RpdmJ5emVybyApOworICAgICAgICAgICAgcmV0dXJuIHBhY2tGbG9hdHg4MCggelNpZ24sIDB4N0ZGRiwgTElUNjQoIDB4ODAwMDAwMDAwMDAwMDAwMCApICk7CisgICAgICAgIH0KKyAgICAgICAgbm9ybWFsaXplRmxvYXR4ODBTdWJub3JtYWwoIGJTaWcsICZiRXhwLCAmYlNpZyApOworICAgIH0KKyAgICBpZiAoIGFFeHAgPT0gMCApIHsKKyAgICAgICAgaWYgKCBhU2lnID09IDAgKSByZXR1cm4gcGFja0Zsb2F0eDgwKCB6U2lnbiwgMCwgMCApOworICAgICAgICBub3JtYWxpemVGbG9hdHg4MFN1Ym5vcm1hbCggYVNpZywgJmFFeHAsICZhU2lnICk7CisgICAgfQorICAgIHpFeHAgPSBhRXhwIC0gYkV4cCArIDB4M0ZGRTsKKyAgICByZW0xID0gMDsKKyAgICBpZiAoIGJTaWcgPD0gYVNpZyApIHsKKyAgICAgICAgc2hpZnQxMjhSaWdodCggYVNpZywgMCwgMSwgJmFTaWcsICZyZW0xICk7CisgICAgICAgICsrekV4cDsKKyAgICB9CisgICAgelNpZzAgPSBlc3RpbWF0ZURpdjEyOFRvNjQoIGFTaWcsIHJlbTEsIGJTaWcgKTsKKyAgICBtdWw2NFRvMTI4KCBiU2lnLCB6U2lnMCwgJnRlcm0wLCAmdGVybTEgKTsKKyAgICBzdWIxMjgoIGFTaWcsIHJlbTEsIHR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YXRlRmxvYXR4ODBOYU4oIGEsIGIgKTsKKyAgICAgICAgfQorICAgICAgICBnb3RvIGludmFsaWQ7CisgICAgfQorICAgIGlmICggYkV4cCA9PSAweDdGRkYgKSB7CisgICAgICAgIGlmICggKGJpdHM2NCkgKCBiU2lnPDwxICkgKSByZXR1cm4gcHJvcGFnYXRlRmxvYXR4ODBOYU4oIGEsIGIgKTsKKyAgICAgICAgcmV0dXJuIGE7CisgICAgfQorICAgIGlmICggYkV4cCA9PSAwICkgeworICAgICAgICBpZiAoIGJTaWcgPT0gMCApIHsKKyBpbnZhbGlkOgorICAgICAgICAgICAgZmxvYXRfcmFpc2UoIGZsb2F0X2ZsYWdfaW52YWxpZCApOworICAgICAgICAgICAgei5sb3cgPSBmbG9hdHg4MF9kZWZhdWx0X25hbl9sb3c7CisgICAgICAgICAgICB6LmhpZ2ggPSBmbG9hdHg4MF9kZWZhdWx0X25hbl9oaWdoOworICAgICAgICAgICAgcmV0dXJuIHo7CisgICAgICAgIH0KKyAgICAgICAgbm9ybWFsaXplRmxvYXR4ODBTdWJub3JtYWwoIGJTaWcsICZiRXhwLCAmYlNpZyApOworICAgIH0KKyAgICBpZiAoIGFFeHAgPT0gMCApIHsKKyAgICAgICAgaWYgKCAoYml0czY0KSAoIGFTaWcwPDwxICkgPT0gMCApIHJldHVybiBhOworICAgICAgICBub3JtYWxpemVGbG9hdHg4MFN1Ym5vcm1hbCggYVNpZzAsICZhRXhwLCAmYVNpZzAgKTsKKyAgICB9CisgICAgYlNpZyB8PSBMSVQ2NCggMHg4MDAwMDAwMDAwMDAwMDAwICk7CisgICAgelNpZ24gPSBhU2lnbjsKKyAgICBleHBEaWZmID0gYUV4cCAtIGJFeHA7CisgICAgYVNpZzEgPSAwOworICAgIGlmICggZXhwRGlmZiA8IDAgKSB7CisgICAgICAgIGlmICggZXhwRGlmZiA8IC0xICkgcmV0dXJuIGE7CisgICAgICAgIHNoaWZ0MTI4UmlnaHQoIGFTaWcwLCAwLCAxLCAm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dHJhY3RGbG9hdHg4MEZyYWMoIGEgKTw8MSApICkKKyAgICAgICAgIHx8ICggICAgKCBleHRyYWN0RmxvYXR4ODBFeHAoIGIgKSA9PSAweDdGRkYgKQorICAgICAgICAgICAgICAmJiAoYml0czY0KSAoIGV4dHJhY3RGbG9hdHg4MEZyYWMoIGIgKTw8MSApICkKKyAgICAgICApIHsKKyAgICAgICAgaWYgKCAgICBmbG9hdHg4MF9pc19zaWduYWxpbmdfbmFuKCBhICkKKyAgICAgICAgICAgICB8fCBmbG9hdHg4MF9pc19zaWduYWxpbmdfbmFuKCBiICkgKSB7CisgICAgICAgICAgICBmbG9hdF9yYWlzZSggZmxvYXRfZmxhZ19pbnZhbGlkICk7CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIDA7CisgICAgfQorICAgIHJldHVybgorICAgICAgICAgICAoIGEubG93ID09IGIubG93ICkKKyAgICAgICAgJiYgKCAgICAoIGEuaGlnaCA9PSBiLmhpZ2ggKQorICAgICAgICAgICAgIHx8ICggICAgKCBhLmxvdyA9PSAwICkKKyAgICAgICAgICAgICAgICAgICYmICggKGJpdHMxNikgKCAoIGEuaGlnaCB8IGIuaGlnaCApPDwxICkgPT0gMCApICkKKyAgICAgICAgICAgKTsKKworfQorCisvKgorLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQorUmV0dXJucyAxIGlmIHRoZSBleHRlbmRlZCBkb3VibGUtcHJlY2lzaW9uIGZsb2F0aW5nLXBvaW50IHZhbHVlIGBhJyBpcworbGVzcyB0aGFuIG9yIGVxdWFsIHRvIHRoZSBjb3JyZXNwb25kaW5nIHZhbHVlIGBiJywgYW5kIDAgb3RoZXJ3aXNlLiAgVGhlCitjb21wYXJpc29uIGlzIHBlcmZvcm1lZCBhY2NvcmRpbmcgdG8gdGhlIElFQy9JRUVFIFN0YW5kYXJkIGZvciBCaW5hcnkKK0Zsb2F0aW5nLXBvaW50IEFyaXRobWV0aWMuCistLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCisqLworZmxhZyBmbG9hdHg4MF9sZSggZmxvYXR4ODAgYSwgZmxvYXR4ODAgYiApCit7CisgICAgZmxhZyBhU2lnbiwgYlNpZ247CisKKyAgICBpZiAoICAgICggICAgKCBleHRyYWN0RmxvYXR4ODBFeHAoIGEgKSA9PSAweDdGRkYgKQorICAgICAgICAgICAgICAmJiAoYml0czY0KSAoIGV4dHJhY3RGbG9hdHg4MEZyYWMoIGEgKTw8MSApICkKKyAgICAgICAgIHx8ICggICAgKCBleHRyYWN0RmxvYXR4ODBFeHAoIGIgKSA9PSAweDdGRkYgKQorICAgICAgICAgICAgICAmJiAoYml0czY0KSAoIGV4dHJhY3RGbG9hdHg4MEZyYWMoIGIgKTw8MSApICkKKyAgICAgICApIHsKKyAgICAgICAgZmxvYXRfcmFpc2UoIGZsb2F0X2ZsYWdfaW52YWxpZCApOworICAgICAgICByZXR1cm4gMDsKKyAgICB9CisgICAgYVNpZ24gPSBleHRyYWN0RmxvYXR4ODBTaWduKCBhICk7CisgICAgYlNpZ24gPSBleHRyYWN0RmxvYXR4ODBTaWduKCBiICk7CisgICAgaWYgKCBhU2lnbiAhPSBiU2lnbiApIHsKKyAgICAgICAgcmV0dXJuCisgICAgICAgICAgICAgICBhU2lnbgorICAgICAgICAgICAgfHwgKCAgICAoICggKGJpdHMxNikgKCAoIGEuaGlnaCB8IGIuaGlnaCApPDwxICkgKSB8IGEubG93IHwgYi5sb3cgKQorICAgICAgICAgICAgICAgICA9PSAwICk7CisgICAgfQorICAgIHJldHVybgorICAgICAgICAgIGFTaWduID8gbGUxMjgoIGIuaGlnaCwgYi5sb3csIGEuaGlnaCwgYS5sb3cgKQorICAgICAgICA6IGxlMTI4KCBh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S0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQorKi8KK2ZsYWcgZmxvYXR4ODBfZXFfc2lnbmFsaW5nKCBmbG9hdHg4MCBhLCBmbG9hdHg4MCBiICkKK3sKKworICAgIGlmICggICAgKCAgICAoIGV4dHJhY3RGbG9hdHg4MEV4cCggYSApID09IDB4N0ZGRiApCisgICAgICAgICAgICAgICYmIChiaXRzNjQpICggZXh0cmFjdEZsb2F0eDgwRnJhYyggYSApPDwxICkgKQorICAgICAgICAgfHwgKCAgICAoIGV4dHJhY3RGbG9hdHg4MEV4cCggYiApID09IDB4N0ZGRiApCisgICAgICAgICAgICAgICYmIChiaXRzNjQpICggZXh0cmFjdEZsb2F0eDgwRnJhYyggYiApPDwxICkgKQorICAgICAgICkgeworICAgICAgICBmbG9hdF9yYWlzZSggZmxvYXRfZmxhZ19pbnZhbGlkICk7CisgICAgICAgIHJldHVybiAwOworICAgIH0KKyAgICByZXR1cm4KKyAgICAgICAgICAgKCBhLmxvdyA9PSBiLmxvdyApCisgICAgICAgICYmICggICAgKCBhLmhpZ2ggPT0gYi5oaWdoICkKKyAgICAgICAgICAgICB8fCAoICAgICggYS5sb3cgPT0gMCApCisgICAgICAgICAgICAgICAgICAmJiAoIChiaXRzMTYpICggKCBhLmhpZ2ggfCBiLmhpZ2ggKTw8MSApID09IDAgKSApCisgICAgICAgICAgICk7CisKK30KKworLyoKKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KK1JldHVybnMgMSBpZiB0aGUgZXh0ZW5kZWQgZG91YmxlLXByZWNpc2lvbiBmbG9hdGluZy1wb2ludCB2YWx1ZSBgYScgaXMgbGVzcwordGhhbiBvciBlcXVhbCB0byB0aGUgY29ycmVzcG9uZGluZyB2YWx1ZSBgYicsIGFuZCAwIG90aGVyd2lzZS4gIFF1aWV0IE5hTnM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ICAoICAgICggZXh0cmFjdEZsb2F0eDgwRXhwKCBhICkgPT0gMHg3RkZGICkKKyAgICAgICAgICAgICAgJiYgKGJpdHM2NCkgKCBleHRyYWN0RmxvYXR4ODBGcmFjKCBhICk8PDEgKSApCisgICAgICAgICB8fCAoICAgICggZXh0cmFjdEZsb2F0eDgwRXhwKCBiICkgPT0gMHg3RkZGICkKKyAgICAgICAgICAgICAgJiYgKGJpdHM2NCkgKCBleHRyYWN0RmxvYXR4ODBGcmFjKCBiICk8PDEgKSApCisgICAgICAgKSB7CisgICAgICAgIGlmICggICAgZmxvYXR4ODBfaXNfc2lnbmFsaW5nX25hbiggYSApCisgICAgICAgICAgICAgfHwgZmxvYXR4ODBfaXNfc2lnbmFsaW5nX25hbiggYiApICkgeworICAgICAgICAgICAgZmxvYXRfcmFpc2UoIGZsb2F0X2ZsYWdfaW52YWxpZCApOworICAgICAgICB9CisgICAgICAgIHJldHVybiAwOworICAgIH0KKyAgICBhU2lnbiA9IGV4dHJhY3RGbG9hdHg4MFNpZ24oIGEgKTsKKyAgICBiU2lnbiA9IGV4dHJhY3RGbG9hdHg4MFNpZ24oIGIgKTsKKyAgICBpZiAoIGFTaWduICE9IGJTaWduICkgeworICAgICAgICByZXR1cm4KKyAgICAgICAgICAgICAgIGFTaWduCisgICAgICAgICAgICAmJiAoICAgICggKCAoYml0czE2KSAoICggYS5oaWdoIHwgYi5oaWdoICk8PDEgKSApIHwgYS5sb3cgfCBiLmxvdyApCisgICAgICAgICAgICAgICAgICE9IDAgKTsKKyAgICB9CisgICAgcmV0dXJuCisgICAgICAgICAgYVNpZ24gPyBsdDEyOCggYi5oaWdoLCBiLmxvdywgYS5oaWdoLCBhLmxvdyApCisgICAgICAgIDogbHQxMjgoIGEuaGlnaCwgYS5sb3csIGIuaGlnaCwgYi5sb3cgKTsKKworfQorCisjZW5kaWYKKwpkaWZmIC0tZ2l0IGEvYXJjaC9hcm0vbndmcGUvc29mdGZsb2F0LmggYi9hcmNoL2FybS9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