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0uaW1hZygpKSkKICAgICAgICB7CiAgICAgICAgICAgIGFzc2VydChyLnJlYWwoKSA9PSAxKTsKICAgICAgICAgICAgYXNzZXJ0KHIuaW1hZygpID09IDApOwogICAgICAgICAgICBhc3NlcnQoc3RkOjpzaWduYml0KHIuaW1hZygpKSA9PSBzdGQ6OnNpZ25iaXQoc2luKDIqeFtpXS5pbWFnKCkpKSk7CiAgICAgICAgfQogICAgICAgIGVsc2UgaWYgKHN0ZDo6aXNpbmYoeFtpXS5yZWFsKCkpICYmIHN0ZDo6aXNpbmYoeFtpXS5pbWFnKCkpKQogICAgICAgIHsKICAgICAgICAgICAgYXNzZXJ0KHIucmVhbCgpID09IDEpOwogICAgICAgICAgICBhc3NlcnQoci5pbWFnKCkgPT0gMCk7CiAgICAgICAgfQogICAgICAgIGVsc2UgaWYgKHN0ZDo6aXNpbmYoeFtpXS5yZWFsKCkpICYmIHN0ZDo6aXNuYW4oeFtpXS5pbWFnKCkpKQogICAgICAgIHsKICAgICAgICAgICAgYXNzZXJ0KHIucmVhbCgpID09IDEpOwogICAgICAgICAgICBhc3NlcnQoci5pbWFnKCkgPT0gMCk7CiAgICAgICAgfQogICAgICAgIGVsc2UgaWYgKHN0ZDo6aXNuYW4oeFtpXS5yZWFsKCkpICYmIHhbaV0uaW1hZygpID09IDApCiAgICAgICAgewogICAgICAgICAgICBhc3NlcnQoc3RkOjppc25hbihyLnJlYWwoKSkpOwogICAgICAgICAgICBhc3NlcnQoci5pbWFnKCkgPT0gMCk7CiAgICAgICAgICAgIGFzc2VydChzdGQ6OnNpZ25iaXQoci5pbWFnKCkpID09IHN0ZDo6c2lnbmJpdCh4W2ldLmltYWcoKSkpOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChzdGQ6OmlzbmFuKHhbaV0ucmVhbCgpKSAmJiBzdGQ6OmlzZmluaXRlKHhbaV0uaW1hZygpKSkKICAgICAgICB7CiAgICAgICAgICAgIGFzc2VydChzdGQ6OmlzbmFuKHIucmVhbCgp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