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AgICAgIHJldHVybiBCOTYwMDsNCiAgICAgICAgY2FzZSAxOTIwMDoNCiAgICAgICAgICAgIHJldHVybiBCMTkyMDA7DQogICAgICAgIGNhc2UgMzg0MDA6DQogICAgICAgICAgICByZXR1cm4gQjM4NDAwOw0KICAgICAgICBjYXNlIDU3NjAwOg0KICAgICAgICAgICAgcmV0dXJuIEI1NzYwMDsNCiAgICAgICAgY2FzZSAxMTUyMDA6DQogICAgICAgICAgICByZXR1cm4gQjExNTIwMDsNCiAgICAgICAgZGVmYXVsdDoNCiAgICAgICAgICAgIHJldHVybiBCOTYwMDsNCiAgICB9DQp9DQoNCi8vILKozNjCyre016q7r9equ7u6r8r9DQpzdGF0aWMgaW50MzJfdCBpRm5CYXVkY29udihpbnQzMl90IEJhdWRyYXRlKQ0Kew0KICAgIHN3aXRjaChCYXVkcmF0ZSkNCiAgICB7DQogICAgICAgIGNhc2UgQjI0MDA6DQogICAgICAgICAgICByZXR1cm4gMjQwMDsNCiAgICAgICAgY2FzZSBCNDgwMDoNCiAgICAgICAgICAgIHJldHVybiA0ODAwOw0KICAgICAgICBjYXNlIEI5NjAwOg0KICAgICAgICAgICAgcmV0dXJuIDk2MDA7DQogICAgICAgIGNhc2UgQjE5MjAwOg0KICAgICAgICAgICAgcmV0dXJuIDE5MjAwOw0KICAgICAgICBjYXNlIEIzODQwMDoNCiAgICAgICAgICAgIHJldHVybiAzODQwMDsNCiAgICAgICAgY2FzZSBCNTc2MDA6DQogICAgICAgICAgICByZXR1cm4gNTc2MDA7DQogICAgICAgIGNhc2UgQjExNTIwMDoNCiAgICAgICAgICAgIHJldHVybiAxMTUyMDA7DQogICAgICAgIGRlZmF1bHQ6DQogICAgICAgICAgICByZXR1cm4gOTYwMDsNCiAgICB9DQp9DQoNCi8vIMno1sO2y7/a0MXPoqGjaUZkQ29tOiC0rr/azsS8/sPoyva3+ywgcHRQb3J0SW5mbzogtP3J6NbDtcS2y7/a0MXPoqGjDQp2b2lkIHZGblNldFVzYkluZm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HdhcmUgZmxvdyBjb250cm9sDQogICAgICAgICAgICB9YnJlYWs7DQogICAgICAgIGNhc2UgJzInOg0KICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgIHROZXdUZXJtaW9zLmNfaWZsYWcgfD0gSVhPTiB8IElYT0ZGIHwgSVhBTlk7ICAgIC8vc29mdHdhcmUgZmxvdyBjb250cm9sDQogICAgICAgICAgICB9YnJlYWs7DQogICAgICAgIGRlZmF1bHQ6DQogICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICB9DQogICAgfQ0KICAgIC8vIL/Y1sbEo8q9LCBkYXRhIGJpdHMNCiAgICB0TmV3VGVybWlvcy5jX2NmbGFnICY9IH5DU0laRTsgLy+/2NbGxKPKvSwgxsGxztfWt/u089ChzrsNCiAgICBjRGF0YWJpdCA9IHB0UG9ydEluZm8tPmNEYXRhYml0Ow0KICAgIHN3aXRjaChjRGF0YWJpdCkNCiAgICB7DQogICAgICAgIGNhc2UgJzUnOg0KICAgICAgICAgICAgdE5ld1Rlcm1pb3MuY19jZmxhZyB8PSBDUzU7DQogICAgICAgICAgICAvLyBsaW50IC1mYWxsdGhyb3VnaA0KICAgICAgICBjYXNlICc2JzoNCiAgICAgICAgICAgIHROZXdUZXJtaW9zLmNfY2ZsYWcgfD0gQ1M2Ow0KICAgICAgICAgICAgLy8gbGludCAtZmFsbHRocm91Z2gNCiAgICAgICAgY2FzZSAnNyc6DQogICAgICAgICAgICB0TmV3VGVybWlvcy5jX2NmbGFnIHw9IENTNzsNCiAgICAgICAgICAgIC8vIGxpbnQgLWZhbGx0aHJvdWdoDQogICAgICAgIGRlZmF1bHQ6DQogICAgICAgICAgICB0TmV3VGVybWlvcy5jX2NmbGFnIHw9IENTODsNCiAgICB9DQogICAgLy8gv9jWxsSjyr0gcGFyaXR5IGNoZWNrDQogICAgY1Bhcml0eSA9IHB0UG9ydEluZm8tPmNQYXJpdHk7DQogICAgc3dpdGNoKGNQYXJpdHkpDQogICAgew0KICAgICAgICBjYXNlICcwJzoNCiAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICB0TmV3VGVybWlvcy5jX2NmbGFnICY9IH5QQVJFTkI7IC8vbm8gcGFyaXR5IGNoZWNrDQogICAgICAgICAgICB9YnJlYWs7DQogICAgICAgIGNhc2UgJzEnOg0KICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgIHROZXdUZXJtaW9zLmNfY2ZsYWcgfD0gUEFSRU5COyAgLy9vZGQgY2hlY2sNCiAgICAgICAgICAgICAgICB0TmV3VGVybWlvcy5jX2NmbGFnICY9IH5QQVJPREQ7DQogICAgICAgICAgICB9YnJlYWs7DQogICAgICAgIGNhc2UgJzInOg0KICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgIHROZXdUZXJtaW9zLmNfY2ZsYWcgfD0gUEFSRU5COyAgLy9ldmVuIGNoZWNrDQogICAgICAgICAgICAgICAgdE5ld1Rlcm1pb3MuY19jZmxhZyB8PSBQQVJPREQ7DQogICAgICAgICAgICB9YnJlYWs7DQogICAgICAgIGRlZmF1bHQ6DQogICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICB9DQogICAgfQ0KICAgIC8vIL/Y1sbEo8q9LCBzdG9wIGJpdHMNCiAgICBjU3RvcGJpdCA9IHB0UG9ydEluZm8tPmNTdG9wYml0Ow0KICAgIGlmKCcyJyA9PSBjU3RvcGJpdCkNCiAgICB7DQogICAgICAgIHROZXdUZXJtaW9zLmNfY2ZsYWcgfD0gQ1NUT1BCOw0KICAgIH0NCiAgICBlbHNlDQogICAgew0KICAgICAgICB0TmV3VGVybWlvcy5jX2NmbGFnICY9IH5DU1RPUEI7DQogICAgfQ0KICAgIC8vIG90aGVyIGF0dHJpYnV0aW9ucyBkZWZhdWx0DQogICAgdE5ld1Rlcm1pb3MuY19vZmxhZyAmPSB+T1BPU1Q7ICAgICAgICAgICAgLy/K5LP2xKPKvSwg1K3KvMr9vt3K5LP2D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