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0KICAgIGlmKHBTcmMgPT0gIE5VTEwgfHwgcERzdCA9PSBOVUxMIHx8IG5TcmNMZW5ndGggPCAwKQ0KICAgIHsNCiAgICAgICAgcmV0dXJuIC0xOw0KICAgIH0NCg0KICAgIGZvcihpID0gMDsgaSA8IG5TcmNMZW5ndGg7IGkgKz0gMikNCiAgICB7DQogICAgICAgIC8vIMrks/a43zTOuw0KICAgICAgICBpZigqcFNyYyA+PSAnMCcgJiYgKnBTcmMgPD0gJzknKQ0KICAgICAgICB7DQogICAgICAgICAgICAqcERzdCA9ICgqcFNyYyAtICcwJykgPDwgNDsNCiAgICAgICAgfQ0KICAgICAgICBlbHNlDQogICAgICAgIHsNCiAgICAgICAgICAgICpwRHN0ID0gKCh0b3VwcGVyKCpwU3JjKSAtICdBJykgKyAxMCkgPDwgNDsNCiAgICAgICAgfQ0KDQogICAgICAgIHBTcmMrKzsNCg0KICAgICAgICAvLyDK5LP2tc00zrsNCiAgICAgICAgaWYoKnBTcmMgPj0gJzAnICYmICpwU3JjIDw9ICc5JykNCiAgICAgICAgew0KICAgICAgICAgICAgKnBEc3QgfD0gKnBTcmMgLSAnMCc7DQogICAgICAgIH0NCiAgICAgICAgZWxzZQ0KICAgICAgICB7DQogICAgICAgICAgICAqcERzdCB8PSAodG91cHBlcigqcFNyYykgLSAnQScpICsgMTA7DQogICAgICAgIH0NCg0KICAgICAgICBwU3JjKys7DQogICAgICAgIHBEc3QrKzsNCiAgICB9DQoNCiAgICAvLyC3tbvYxL+x6sr9vt2zpLbIDQogICAgcmV0dXJuIG5TcmNMZW5ndGggLyAyOw0KfQ0KDQovKioNCiAqIEBicmllZiDX1r3ayv2+3dequ7vOqr/JtPLTodfWt/u0riCjrMjno7oNCiAgICAgICAgICAgICAgICAgICAgIHsweEM4LCAweDMyLCAweDlCLCAweEZELCAweDBFLCAweDAxfSAtLT4gIkM4MzI5QkZEMEUwMSINCiAqIEBwYXJhbSBwU3JjINS0yv2+3da41esNCiAqIEBwYXJhbSBwR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2xlbiArPSAxOyANCiAgICB9IA0KICAgIHJldF9sZW4gPSByZXRfbGVuKjQgKyAxOyANCiAgICByZXQgPSAoY2hhciAqKW1hbGxvYyhyZXRfbGVuKTsgDQogICAgICANCiAgICBpZiAocmV0ID09IE5VTEwpIA0KICAgIHsgDQogICAgICAgIHByaW50ZigiTm8gZW5vdWdoIG1lbW9yeS5cbiIpOyANCiAgICAgICAgcmV0dXJuIE5VTEw7DQogICAgfSANCiAgICBtZW1zZXQocmV0LCAwLCByZXRfbGVuKTsgDQogICAgZiA9IHJldDsgDQogICAgd2hpbGUgKHRtcCA8IGRhdGFfbGVuKSANCiAgICB7IA0KICAgICAgICB0ZW1wID0gMDsgDQogICAgICAgIHByZXBhcmUgPSAwOyANCiAgICAgICAgbWVtc2V0KGNoYW5nZWQsICdcMCcsIDQpOyANCiAgICAgICAgd2hpbGUgKHRlbXAgPCAzKSANCiAgICAgICAgeyANCiAgICAgICAgICAgIC8vcHJpbnRmKCJ0bXAgPSAlZFxuIiwgdG1wKTsgDQogICAgICAgICAgICBpZiAodG1wID49IGRhdGFfbGVuKSANCiAgICAgICAgICAgIHsgDQogICAgICAgICAgICAgICAgYnJlYWs7IA0KICAgICAgICAgICAgfSANCiAgICAgICAgICAgIHByZXBhcmUgPSAoKHByZXBhcmUgPDwgOCkgfCAoZGF0YVt0bXBdICYgMHhGRikpOyANCiAgICAgICAgICAgIHRtcCsrOyANCiAgICAgICAgICAgIHRlbXArKzsgDQogICAgICAgIH0gDQogICAgICAgIHByZXBhcmUgPSAocHJlcGFyZTw8KCgzLXRlbXApKjgpKTsgDQogICAgICAgIC8vcHJpbnRmKCJiZWZvcmUgZm9yIDogdGVtcCA9ICVkLCBwcmVwYXJlID0gJWRcbiIsIHRlbXAsIHByZXBhcmUpOyANCiAgICAgICAgZm9yIChpID0gMDsgaSA8IDQgO2krKyApIA0KICAgICAgICB7IA0KICAgICAgICAgICAgaWYgKHRlbXAgPCBpKSANCiAgICAgICAgICAgIHsgDQogIC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