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N0QWRkcjsKCXVfaW50IHNyY0FkZHI7Cgl1X2ludCBnYXRlV2F5OwoJY2hhciBpZk5hbWVbSUZfTkFNRVNJWkVdOwp9OwoKI2RlZmluZSBCVUZTSVpFIDgxOTIKCiNkZWZpbmUgU1BJTkxPQ0tfSU9DX01BR0lDCSdTJwoKI2RlZmluZSBTUElOTE9DS19HRVRfU1RBVFVTICBfSU9XUihTUElOTE9DS19JT0NfTUFHSUMsMSxjaGFyICopCgojZGVmaW5lIFJFQURfQlVGX1NJWkUgNTYKLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKICogICAgICAgICAgICAgICAgICAgICAgSW5saW5lIGZ1bmN0aW9uIGltcGxlbWVudGF0aW9ucyAgICAgICAgICAgICAgICAgICAgICAgICoKICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KaW5saW5lIGNoYXIgKnN0cmlwX3NwYWNlKGNoYXIgKnN0cikKewoJd2hpbGUgKCpzdHIgPT0gJyAnKQoJCXN0cisrOwoJcmV0dXJuIHN0cjsKfQovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgogKiAgICAgICAgICAgICAgICAgICAgICBMb2NhbCBmdW5jdGlvbiBpbXBsZW1lbnRhdGlvbnMgICAgICAgICAgICAgICAgICAgICAgICAgKgogKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiDQtM7EvP6y2df3uq/K/SAqLwppbnQgd3JpdGVfZmlsZShjb25zdCBjaGFyICpmaWxlcGF0aCwgaW50IGZsYWdzLCBjb25zdCBjaGFyICpidWYsIGludCBzaXplKQp7CglpbnQgZmQgPSAwOwoJaW50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lcHRyLT50bV9zZWMsCgkgICAgICAgIDE5MDAgKyB0aW1lcHRyLT50bV95ZWFyKTsKCXJldHVybiByZXN1bHQ7Cn0KCi8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCiAqICAgICAgICAgICAgICAgICAgICAgIEdsb2JhbCBmdW5jdGlvbiBpbXBsZW1lbnRhdGlvbnMgICAgICAgICAgICAgICAgICAgICAgICAqCiAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLy9pbnB1dDogIG52X3N0cjpudsTayN3WuNXrICAgICogbnZfcGFyYW0gveLO9rrzss7K/bXE1rjV6wovL291dHB1dDogICBwYXJhbV9udW0gICAgIG52X3BhcmFtCi8vyr7A/ToKLy8gICBpbnQgbnVtOwovLyAgIGNoYXIqKiBudl9wYXJhbTsKLy8gICBudW0gPSBudl9hbmFseXplKG52X3N0ciwmbnZfcGFyYW0pCi8vICAgc3RyY21wKG52X3BhcmFtWzBdLCJhYWEiKSAuLi4KLy8gICBzdHJjbXAobnZfcGFyYW1bMV0sImJiYiIpIC4uLgovLyAgIC4uLgovLyAgIGZyZWUobnZfcGFyYW0pOwovLwovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KCmludCBudl9hbmFseXplKGNoYXIqIG52X3N0ciwgY2hhcioqKiBudl9wYXJhbSkKewoJaW50IHBhcmFtX251bSA9IDE7CglpbnQgaSA9IDA7CgljaGFyKiBzdHJfcHRyOwoJY2hhcioqIG1lbV9wdHI7CgljaGFyKiB0bXBfcHRyOwoJZm9yIChzdHJfcHRyID0gbnZfc3RyOyAqc3RyX3B0ciAhPSAnXDAnOyBzdHJfcHRyKyspIHsKCQlpZiAoKnN0cl9wdHIgPT0gJys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