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IGVuZHRpbWUgLSB0aW1lLnRpbWUoKSAKICAgICAgICBpZiBydGltZSA8IDA6
CiAgICAgICAgICAgIHJldHVybiBOb25lCiAgICAgICAgciwgdywgZSA9IHNlbGVjdC5zZWxlY3Qo
W3NdLCBbXSwgW10sIDUpCiAgICAgICAgaWYgcyBpbiByOgogICAgICAgICAgICBkYXRhID0gcy5y
ZWN2KHJlbWFpbikKICAgICAgICAgICAgaWYgbm90IGRhdGE6CiAgICAgICAgICAgICAgICByZXR1
cm4gTm9uZQogICAgICAgICAgICByZGF0YSArPSBkYXRhCiAgICAgICAgICAgIHJlbWFpbiAtPSBs
ZW4oZGF0YSkKICAgIHJldHVybiByZGF0YQogICAgICAgIAoKZGVmIHJlY3Ztc2cocyk6CiAgICBo
ZHIgPSByZWN2YWxsKHMsIDUpCiAgICBpZiBoZHIgaXMgTm9uZToKICAgICAgICByZXR1cm4gTm9u
ZSwgTm9uZSwgTm9uZQogICAgdHlwLCB2ZXIsIGxuID0gc3RydWN0LnVucGFjaygnPkJISCcsIGhk
cikKICAgIHBheSA9IHJlY3ZhbGwocywgbG4sIDEwKQogICAgaWYgcGF5IGlzIE5vbmU6CiAgICAg
ICAgcmV0dXJuIE5vbmUsIE5vbmUsIE5vbmUKICAgIHJldHVybiB0eXAsIHZlciwgcGF5CgpkZWYg
aGl0X2hiKHMsdGFyZ2V0KToKICAgIHMuc2VuZChoYikKICAgIHdoaWxlIFRydWU6CiAgICAgICAg
dHlwLCB2ZXIsIHBheSA9IHJlY3Ztc2cocykKICAgICAgICBpZiB0eXAgaXMgTm9uZToKICAgICAg
ICAgICAgcmV0dXJuIEZhbHNlCgogICAgICAgIGlmIHR5cCA9PSAyNDoKICAgICAgICAgICAgbG9n
aXQoaGV4ZHVtcChwYXkpLCB0YXJnZXQpCiAgICAgICAgICAgIHJldHVybiBUcnVlCgogICAgICAg
IGlmIHR5cCA9PSAyMToKICAgICAgICAgICAgcmV0dXJuIEZhbHNlCgpkZWYgbG9naXQocGF5b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AgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAg
ICAgICBmb3IgaSBpbiB0YXJnZXRzOiAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAg
ICAgICAgICAgICAgICBpZiBpIG5vdCBpbiBbJ1xuJ106CiAgICAgICAgICAgICAgICAgICAgICAg
ICAgICBtYWluKGlbOi0xXSkKICAgICAgICAgICAgICAgICAgICB4Kz0xCiAgICAgICAgICAgIGV4
Y2VwdCBLZXlib2FyZEludGVycnVwdDoKICAgICAgICAgICAgICAgIHN5cy5leGl0KDEpCiAgICAg
ICAgZWxzZToKICAgICAgICAgICAgc3lzLmV4aXQoMSkKICAgIGVsc2U6CiAgICAgICAgcHJpbnQo
InVzYWdlOiAlcyBGSUxFIiAlIHN5cy5hcmd2WzBdKQogICAgICAgIHN5cy5leGl0KDEpCg==