-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdependancies.deb
1 lines (1 loc) · 115 KB
/
dependancies.deb
1
QXNzaWdubWVudCAxDQpJbnB1dDoNCg0KUGFzczEuamF2YQ0KDQppbXBvcnQgamF2YS5pby4qOw0KaW1wb3J0IGphdmEudXRpbC5BcnJheUxpc3Q7DQppbXBvcnQgamF2YS51dGlsLkxpbmtlZEhhc2hNYXA7DQoNCnB1YmxpYyBjbGFzcyBQYXNzMSB7DQoNCiAgICBpbnQgbGMgPSAwOw0KICAgIGludCBsaWJ0YWJfcHRyID0gMCwgcG9vbHRhYl9wdHIgPSAwOw0KICAgIGludCBzeW1JbmRleCA9IDAsIGxpdEluZGV4ID0gMDsNCg0KICAgIFN0cmluZyBvdXQ7DQoNCiAgICBMaW5rZWRIYXNoTWFwPFN0cmluZywgVGFibGVSb3c+IFNZTVRBQjsNCiAgICBBcnJheUxpc3Q8VGFibGVSb3c+IExJVFRBQjsNCiAgICBBcnJheUxpc3Q8SW50ZWdlcj4gUE9PTFRBQjsNCiAgICBwcml2YXRlIEJ1ZmZlcmVkUmVhZGVyIGJyOw0KDQogICAgcHVibGljIFBhc3MxKCkgew0KICAgICAgICBTWU1UQUIgPSBuZXcgTGlua2VkSGFzaE1hcDw+KCk7DQogICAgICAgIExJVFRBQiA9IG5ldyBBcnJheUxpc3Q8PigpOw0KICAgICAgICBQT09MVEFCID0gbmV3IEFycmF5TGlzdDw+KCk7DQogICAgICAgIGxjID0gMDsNCiAgICAgICAgUE9PTFRBQi5hZGQoMCk7DQogICAgfQ0KDQogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgdGhyb3dzIEV4Y2VwdGlvbiB7DQogICAgICAgIFBhc3MxIG9iaiA9IG5ldyBQYXNzMSgpOw0KICAgICAgICBvYmoucmVhZEZpbGUoKTsNCiAgICB9DQoNCiAgICBwdWJsaWMgdm9pZCByZWFkRmlsZSgpIHRocm93cyBFeGNlcHRpb24gew0KICAgICAgICBTdHJpbmcgcHJldiA9ICIiOw0KICAgICAgICBTdHJpbmcgbGluZTsNCiAgICAgICAgU3RyaW5nIGNvZGU7DQoNCiAgICAgICAgbmV3IE1PVCgpOw0KICAgICAgICBiciA9IG5ldyBCdWZmZXJlZFJlYWRlcihuZXcgRmlsZVJlYWRlcigiaW5wdXQxLmFzbSIpKTsNCiAgICAgICAgd2hpbGUgKChsaW5lID0gYnIucmVhZExpbmUoKSkgIT0gbnVsbCkgew0KLy8gICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4obGluZSk7DQoNCiAgICAgICAgICAgIFN0cmluZyBwYWdlW10gPSBsaW5lLnNwbGl0KCJcXHMrIik7DQoNCiAgICAgICAgICAgIGlmIChwYWdlWzBdICE9ICIiKSB7Ly9MQUJMRSBWRVJJRklDQVRJT04NCi8vICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnQoIlx0TGFibGUtPiIgKyBwYWdlWzBdICsgIlx0Iik7DQogICAgICAgICAgICAgICAgaWYgKFNZTVRBQi5jb250YWluc0tleShwYWdlWzBdKSkgew0KICAgICAgICAgICAgICAgICAgICBTWU1UQUIucHV0KHBhZ2VbMF0sIG5ldyBUYWJsZVJvdyhwYWdlWzBdLCBsYywgU1lNVEFCLmdldChwYWdlWzBdKS5nZXRJbmRleCgpKSk7DQogICAgICAgICAgICAgICAgICAgIGxjKys7DQogICAgICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICAgICAgU1lNVEFCLnB1dChwYWdlWzBdLCBuZXcgVGFibGVSb3cocGFnZVswXSwgbGMsICsrc3ltSW5kZXgpKTsNCg0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludCgiXHRcdFx0Iik7DQogICAgICAgICAgICB9DQoNCiAgICAgICAgICAgIGlmIChwYWdlWzFdLmVxdWFscygiU1RBUlQiKSkgLy9DSEVDSyBTVEFSVA0KICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgIGxjID0gSW50ZWdlci5wYXJzZUludChwYWdlWzJdKTsNCiAgICAgICAgICAgICAgICBvdXQgPSAiKCIgKyBNT1QuY2hlY2tjbHMocGFnZVsxXSkgKyAiLCIgKyBNT1QuY2hlY2tvcChwYWdlWzFdKSArICIpXHQoQywiICsgcGFnZVsyXSArICIpIjsNCg0KICAgICAgICAgICAgfSBlbHNlIGlmIChwYWdlWzFdLmVxdWFscygiRVFVIikpIHsNCiAgICAgICAgICAgICAgICBTdHJpbmcgc3BsaXQxW10gPSBwYWdlWzJdLnNwbGl0KCJcXCsiKTsNCiAgICAgICAgICAgICAgICBpbnQgbG9jID0gU1lNVEFCLmdldChzcGxpdDFbMF0pLmdldEFkZHJlc3MoKSArIEludGVnZXIucGFyc2VJbnQoc3BsaXQxWzFdKTsNCiAgICAgICAgICAgICAgICAvL2JlbG93IElmIGNvbmRpdGlvbnMgYXJlIG9wdGlvbmFsIGFzIG5vIElDIGlzIGdlbmVyYXRlZCBmb3IgdGhlbQ0KICAgICAgICAgICAgICAgIGlmIChwYWdlWzJdLmNvbnRhaW5zKCIrIikpIHsNCiAgICAgICAgICAgICAgICAgICAgU3RyaW5nIHBhcnRzc2xwW10gPSBwYWdlWzJdLnNwbGl0KCJcXCsiKTsNCiAgICAgICAgICAgICAgICAgICAgb3V0ID0gIihBRCwwNClcdChTLCIgKyBTWU1UQUIuZ2V0KHBhcnRzc2xwWzBdKS5nZXRJbmRleCgpICsgIikgKyAiICsgSW50ZWdlci5wYXJzZUludChwYXJ0c3NscFsxXSk7DQoNCiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHBhZ2VbMl0uY29udGFpbnMoIi0iKSkgew0KICAgICAgICAgICAgICAgICAgICBTdHJpbmcgcGFydHNzbHBbXSA9IHBhZ2VbMl0uc3BsaXQoIlxcLSIpOw0KICAgICAgICAgICAgICAgICAgICBvdXQgPSAiKEFELDA0KVx0KFMsIiArIFNZTVRBQi5nZXQocGFydHNzbHBbMF0pLmdldEluZGV4KCkgKyAiKS0iICsgSW50ZWdlci5wYXJzZUludChwYXJ0c3NscFsxXSk7DQogICAgICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICAgICAgb3V0ID0gIihBRCwwNClcdChDLCIgKyBJbnRlZ2VyLnBhcnNlSW50KHBhZ2VbMl0gKyAiKSIpOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAoU1lNVEFCLmNvbnRhaW5zS2V5KHBhZ2VbMF0pKQ0KICAgICAgICAgICAgICAgICAgICBTWU1UQUIucHV0KHBhZ2VbMF0sIG5ldyBUYWJsZVJvdyhwYWdlWzBdLCBsb2MsIFNZTVRBQi5nZXQocGFnZVswXSkuZ2V0SW5kZXgoKSkpOw0KICAgICAgICAgICAgICAgIGVsc2UNCiAgICAgICAgICAgICAgICAgICAgU1lNVEFCLnB1dChwYWdlWzBdLCBuZXcgVGFibGVSb3cocGFnZVswXSwgbG9jLCArK3N5bUluZGV4KSk7DQoNCiAgICAgICAgICAgIH0gZWxzZSBpZiAocGFnZVsxXS5lcXVhbHMoIk9SSUdJTiIpKSB7DQogICAgICAgICAgICAgICAgU3RyaW5nIHBhcnRzbHBbXSA9IChwYWdlWzJdKS5zcGxpdCgiXFwrIik7DQogICAgICAgICAgICAgICAgb3V0ID0gIigiICsgTU9ULmNoZWNrY2xzKHBhZ2VbMV0pICsgIiwiICsgTU9ULmNoZWNrb3AocGFnZVsxXSkgKyAiKVx0KFMsIiArIFNZTVRBQi5nZXQocGFydHNscFswXSkuZ2V0SW5kZXgoKSArICIpICsgIiArIEludGVnZXIucGFyc2VJbnQocGFydHNscFsxXSk7DQoNCiAgICAgICAgICAgIH0gZWxzZSBpZiAocGFnZVsxXS5lcXVhbHMoIkxUT1JHIikpIHsNCiAgICAgICAgICAgICAgICBpbnQgcHRyID0gUE9PTFRBQi5nZXQocG9vbHRhYl9wdHIpOw0KICAgICAgICAgICAgICAgIGZvciAoaW50IGogPSBwdHI7IGogPCBsaWJ0YWJfcHRyOyBqKyspIHsNCiAgICAgICAgICAgICAgICAgICAgbGMrKzsNCiAgICAgICAgICAgICAgICAgICAgTElUVEFCLnNldChqLCBuZXcgVGFibGVSb3coTElUVEFCLmdldChqKS5nZXRTeW1ib2woKSwgbGMpKTsNCiAgICAgICAgICAgICAgICAgICAgb3V0ID0gIigiICsgTU9ULmNoZWNrY2xzKHBhZ2VbMV0pICsgIiwiICsgTU9ULmNoZWNrb3AocGFnZVsxXSkgKyAiKVx0KEMsIiArIExJVFRBQi5nZXQoaikuc3ltYm9sICsgIikiOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBwb29sdGFiX3B0cisrOw0KICAgICAgICAgICAgICAgIGxjKys7DQogICAgICAgICAgICAgICAgUE9PTFRBQi5hZGQobGlidGFiX3B0cik7DQoNCiAgICAgICAgICAgIH0gZWxzZSBpZiAocGFnZVsxXS5lcXVhbHMoIkRDIikpIHsNCg0KICAgICAgICAgICAgICAgIGludCBzaXplID0gSW50ZWdlci5wYXJzZUludChwYWdlWzJdLnJlcGxhY2UoIiciLCAiIikpOw0KICAgICAgICAgICAgICAgIG91dCA9ICIoIiArIE1PVC5jaGVja2NscyhwYWdlWzFdKSArICIsIiArIE1PVC5jaGVja29wKHBhZ2VbMV0pICsgIilcdChDLCIgKyBzaXplICsgIikiOw0KDQoNCiAgICAgICAgICAgIH0gZWxzZSBpZiAocGFnZVsxXS5lcXVhbHMoIkRTIikpIHsNCiAgICAgICAgICAgICAgICBsYysrOw0KICAgICAgICAgICAgICAgIG91dCA9ICIoIiArIE1PVC5jaGVja2NscyhwYWdlWzFdKSArICIsIiArIE1PVC5jaGVja29wKHBhZ2VbMV0pICsgIilcdChDLCIgKyBwYWdlWzJdICsgIikiOw0KDQogICAgICAgICAgICB9IGVsc2UgaWYgKHBhZ2VbMV0uZXF1YWxzKCJFTkQiKSkgew0KICAgICAgICAgICAgICAgIGludCBwdHIgPSBQT09MVEFCLmdldChwb29sdGFiX3B0cik7DQogICAgICAgICAgICAgICAgZm9yIChpbnQgaiA9IHB0cjsgaiA8IHBvb2x0YWJfcHRyOyBqKyspIHsNCiAgICAgICAgICAgICAgICAgICAgbGMrKzsNCiAgICAgICAgICAgICAgICAgICAgTElUVEFCLnNldChqLCBuZXcgVGFibGVSb3coTElUVEFCLmdldChqKS5nZXRTeW1ib2woKSwgbGMpKTsNCiAgICAgICAgICAgICAgICAgICAgb3V0ID0gIigiICsgTU9ULmNoZWNrY2xzKHBhZ2VbMV0pICsgIiwiICsgTU9ULmNoZWNrb3AocGFnZVsxXSkgKyAiKVx0KEMsIiArIExJVFRBQi5nZXQoaikuc3ltYm9sICsgIikiOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBwb29sdGFiX3B0cisrOw0KICAgICAgICAgICAgICAgIFBPT0xUQUIuYWRkKGxpYnRhYl9wdHIpOw0KICAgICAgICAgICAgICAgIG91dCA9ICIoQUQsMDIpIjsNCg0KICAgICAgICAgICAgfQ0KDQogICAgICAgICAgICBpZiAoTU9ULmNoZWNrY2xzKHBhZ2VbMV0pLmVxdWFscygiSVMiKSkgew0KICAgICAgICAgICAgICAgIGludCBsZW4gPSBwYWdlLmxlbmd0aDsNCiAgICAgICAgICAgICAgICBTdHJpbmcgRmluYWxPcCA9ICIiOw0KICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAyOyBpIDwgbGVuOyBpKyspIHsNCiAgICAgICAgICAgICAgICAgICAgcGFnZVtpXSA9IHBhZ2VbaV0ucmVwbGFjZSgiLCIsICIiKTsNCiAgICAgICAgICAgICAgICAgICAgaWYgKE1PVC5jaGVja2NscyhwYWdlW2ldKSA9PSAiUkciKSB7DQovLyAgICAgICAgICAgICAgICAgICAgICAgIEZpbmFsT3AgKz0gTU9ULmNoZWNrb3AocGFnZVtpXSkgKyAiXHQiOw0KICAgICAgICAgICAgICAgICAgICAgICAgRmluYWxPcCArPSAiICAoUkcsIitNT1QuY2hlY2tvcChwYWdlW2ldKSsiKSAgICI7DQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFnZVtpXS5jb250YWlucygiPSIpKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVtpXSA9IHBhZ2VbaV0ucmVwbGFjZSgiPSIsICIiKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlW2ldID0gcGFnZVtpXS5yZXBsYWNlKCInIiwgIiIpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIExJVFRBQi5hZGQobmV3IFRhYmxlUm93KHBhZ2VbaV0sIC0xLCArK2xpdEluZGV4KSk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlidGFiX3B0cisrOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZpbmFsT3AgKz0gIihMLCIgKyBsaWJ0YWJfcHRyICsgIikiOw0KDQogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKFNZTVRBQi5jb250YWluc0tleShwYWdlW2ldKSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCBTaW5kZXggPSBTWU1UQUIuZ2V0KHBhZ2VbaV0pLmdldEluZGV4KCk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgRmluYWxPcCArPSAiKFMsIiArIFNpbmRleCArICIpIjsNCiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgU1lNVEFCLnB1dChwYWdlW2ldLCBuZXcgVGFibGVSb3cocGFnZVtpXSwgLTEsICsrc3ltSW5kZXgpKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgU2luZGV4ID0gU1lNVEFCLmdldChwYWdlW2ldKS5nZXRJbmRleCgpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZpbmFsT3AgKz0gIihTLCIgKyBTaW5kZXggKyAiKSI7DQogICAgICAgICAgICAgICAgICAgICAgICB9DQoNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIH0NCg0KICAgICAgICAgICAgICAgIGxjKys7DQogICAgICAgICAgICAgICAgb3V0ID0gIigiICsgTU9ULmNoZWNrY2xzKHBhZ2VbMV0pICsgIiwiICsgTU9ULmNoZWNrb3AocGFnZVsxXSkgKyAiKSIgKyBGaW5hbE9wOw0KICAgICAgICAgICAgfQ0KLy8gICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50KCJNbmV1bW9uaWMtPiIgKyBwYWdlWzFdICsgIlxuIik7DQoNCiAgICAgICAgfQ0KICAgICAgICBQcmludGVyKCJQVGFiIik7DQogICAgICAgIFByaW50ZXIoIkxUYWIiKTsNCiAgICAgICAgUHJpbnRlcigiU1RhYiIpOw0KICAgIH0NCg0KICAgIHB1YmxpYyB2b2lkIFByaW50ZXIoU3RyaW5nIE9QVCkgdGhyb3dzIElPRXhjZXB0aW9uIHsNCiAgICAgICAgc3dpdGNoKE9QVCl7DQogICAgICAgICAgICBjYXNlICJTVGFiIjoNCiAgICAgICAgICAgICAgICBCdWZmZXJlZFdyaXRlciBydz1uZXcgQnVmZmVyZWRXcml0ZXIobmV3IEZpbGVXcml0ZXIoIlNZTVRBQi50eHQiKSk7DQogICAgICAgICAgICAgICAgLy9QcmludGluZyBTeW1ib2wgVGFibGUNCiAgICAgICAgICAgICAgICBqYXZhLnV0aWwuSXRlcmF0b3I8U3RyaW5nPiBpdGVyYXRvciA9IFNZTVRBQi5rZXlTZXQoKS5pdGVyYXRvcigpOw0KICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiXG5cblx0U1lNQk9MIFRBQkxFIik7DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJfX19fX19fX19fX19fX19fX19fX19fX19fX19fXyIpOw0KICAgICAgICAgICAgICAgIHdoaWxlIChpdGVyYXRvci5oYXNOZXh0KCkpIHsNCiAgICAgICAgICAgICAgICAgICAgU3RyaW5nIGtleSA9IGl0ZXJhdG9yLm5leHQoKS50b1N0cmluZygpOw0KICAgICAgICAgICAgICAgICAgICBUYWJsZVJvdyB2YWx1ZSA9IFNZTVRBQi5nZXQoa2V5KTsNCiAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJ8XHNccyIrdmFsdWUuZ2V0SW5kZXgoKSsiXHR8XHNccyIgKyB2YWx1ZS5nZXRTeW1ib2woKSsiXHR8XHNcc1xzIit2YWx1ZS5nZXRBZGRyZXNzKCkrIlx0XHR8Iik7DQoNCi8vICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oInwuLi4uLi4ufC4uLi4uLi58Li4uLi4uLi4uLi4uLi4ufCIpOw0KICAgICAgICAgICAgICAgICAgICBydy53cml0ZSh2YWx1ZS5nZXRJbmRleCgpKyJcdCIgKyB2YWx1ZS5nZXRTeW1ib2woKSsiXHQiK3ZhbHVlLmdldEFkZHJlc3MoKSsiXG4iKTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgcncuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBicmVhazsNCg0KICAgICAgICAgICAgY2FzZSAiUFRhYiI6DQogICAgICAgICAgICAgICAgQnVmZmVyZWRXcml0ZXIgcHJ3PW5ldyBCdWZmZXJlZFdyaXRlcihuZXcgRmlsZVdyaXRlcigiUE9PTFRBQi50eHQiKSk7DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJcblxuXHRQT09MIFRBQkxFIFxuIik7DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJfX19fX19fX19fX19fX19fX18iKTsNCiAgICAgICAgICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8UE9PTFRBQi5zaXplKCktMjsgaSsrKSB7DQogICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigifFxzXHMiKyhpKzEpKyJcdHxcc1xzIyIrKFBPT0xUQUIuZ2V0KGkpKzEpKyJcdHwiKTsNCi8vICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oInwuLi4uLi4ufC4uLi4uLi4uLi4uLi4uLnwiKTsNCiAgICAgICAgICAgICAgICAgICAgcHJ3LndyaXRlKChpKzEpKyJcdCMiKyhQT09MVEFCLmdldChpKSsxKSsiXG4iKTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgcHJ3LmNsb3NlKCk7DQogICAgICAgICAgICAgICAgYnJlYWs7DQoNCiAgICAgICAgICAgIGNhc2UgIkxUYWIiOg0KICAgICAgICAgICAgICAgIEJ1ZmZlcmVkV3JpdGVyIGxydz1uZXcgQnVmZmVyZWRXcml0ZXIobmV3IEZpbGVXcml0ZXIoIkxJVFRBQi50eHQiKSk7DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJcblxuXHRMaXRlcmFsIFRhYmxlIik7DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJfX19fX19fX19fX19fX19fX19fX19fX19fX19fIik7DQogICAgICAgICAgICAgICAgLy9Qcm9jZXNzaW5nIExJVFRBQg0KICAgICAgICAgICAgICAgIGZvcihpbnQgaT0wO2k8TElUVEFCLnNpemUoKTtpKyspDQogICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICBUYWJsZVJvdyByb3c9TElUVEFCLmdldChpKTsNCiAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJ8XHNccyIrKGkrMSkrIlx0fFxzXHMiK3Jvdy5nZXRTeW1ib2woKSsiXHR8XHNcc1xzIityb3cuZ2V0QWRkcmVzcygpKyJcdFx0fCIpOw0KLy8gICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigifC4uLi4uLi58Li4uLi4uLnwuLi4uLi4uLi4uLi4uLi58Iik7DQogICAgICAgIC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BQi5hZGQoMCk7DQogICAgfQ0KDQogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgdGhyb3dzIEV4Y2VwdGlvbiB7DQogICAgICAgIFBhc3MxIG9iaiA9IG5ldyBQYXNzMSgpOw0KICAgICAgICBvYmoucmVhZEZpbGUoKTsNCiAgICB9DQoNCiAgICBwdWJsaWMgdm9pZCByZWFkRmlsZSgpIHRocm93cyBFeGNlcHRpb24gew0KICAgICAgICBTdHJpbmcgcHJldiA9ICIiOw0KICAgICAgICBTdHJpbmcgbGluZTsNCiAgICAgICAgU3RyaW5nIGNvZGU7DQoNCiAgICAgICAgbmV3IE1PVCgpOw0KICAgICAgICBiciA9IG5ldyBCdWZmZXJlZFJlYWRlcihuZXcgRmlsZVJlYWRlcigiaW5wdXQxLmFzbSIpKTsNCiAgICAgICAgd2hpbGUgKChsaW5lID0gYnIucmVhZExpbmUoKSkgIT0gbnVsbCkgew0KLy8gICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4obGluZSk7DQoNCiAgICAgICAgICAgIFN0cmluZyBwYWdlW10gPSBsaW5lLnNwbGl0KCJcXHMrIik7DQoNCiAgICAgICAgICAgIGlmIChwYWdlWzBdICE9ICIiKSB7Ly9MQUJMRSBWRVJJRklDQVRJT04NCi8vICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnQoIlx0TGFibGUtPiIgKyBwYWdlWzBdICsgIlx0Iik7DQogICAgICAgICAgICAgICAgaWYgKFNZTVRBQi5jb250YWluc0tleShwYWdlWzBdKSkgew0KICAgICAgICAgICAgICAgICAgICBTWU1UQUIucHV0KHBhZ2VbMF0sIG5ldyBUYWJsZVJvdyhwYWdlWzBdLCBsYywgU1lNVEFCLmdldChwYWdlWzBdKS5nZXRJbmRleCgpKSk7DQogICAgICAgICAgICAgICAgICAgIGxjKys7DQogICAgICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICAgICAgU1lNVEFCLnB1dChwYWdlWzBdLCBuZXcgVGFibGVSb3cocGFnZVswXSwgbGMsICsrc3ltSW5kZXgpKTsNCg0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludCgiXHRcdFx0Iik7DQogICAgICAgICAgICB9DQoNCiAgICAgICAgICAgIGlmIChwYWdlWzFdLmVxdWFscygiU1RBUlQiKSkgLy9DSEVDSyBTVEFSVA0KICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgIGxjID0gSW50ZWdlci5wYXJzZUludChwYWdlWzJdKTsNCiAgICAgICAgICAgICAgICBvdXQgPSAiKCIgKyBNT1QuY2hlY2tjbHMocGFnZVsxXSkgKyAiLCIgKyBNT1QuY2hlY2tvcChwYWdlWzFdKSArICIpXHQoQywiICsgcGFnZVsyXSArICIpIjsNCg0KICAgICAgICAgICAgfSBlbHNlIGlmIChwYWdlWzFdLmVxdWFscygiRVFVIikpIHsNCiAgICAgICAgICAgICAgICBTdHJpbmcgc3BsaXQxW10gPSBwYWdlWzJdLnNwbGl0KCJcXCsiKTsNCiAgICAgICAgICAgICAgICBpbnQgbG9jID0gU1lNVEFCLmdldChzcGxpdDFbMF0pLmdldEFkZHJlc3MoKSArIEludGVnZXIucGFyc2VJbnQoc3BsaXQxWzFdKTsNCiAgICAgICAgICAgICAgICAvL2JlbG93IElmIGNvbmRpdGlvbnMgYXJlIG9wdGlvbmFsIGFzIG5vIElDIGlzIGdlbmVyYXRlZCBmb3IgdGhlbQ0KICAgICAgICAgICAgICAgIGlmIChwYWdlWzJdLmNvbnRhaW5zKCIrIikpIHsNCiAgICAgICAgICAgICAgICAgICAgU3RyaW5nIHBhcnRzc2xwW10gPSBwYWdlWzJdLnNwbGl0KCJcXCsiKTsNCiAgICAgICAgICAgICAgICAgICAgb3V0ID0gIihBRCwwNClcdChTLCIgKyBTWU1UQUIuZ2V0KHBhcnRzc2xwWzBdKS5nZXRJbmRleCgpICsgIikgKyAiICsgSW50ZWdlci5wYXJzZUludChwYXJ0c3NscFsxXSk7DQoNCiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHBhZ2VbMl0uY29udGFpbnMoIi0iKSkgew0KICAgICAgICAgICAgICAgICAgICBTdHJpbmcgcGFydHNzbHBbXSA9IHBhZ2VbMl0uc3BsaXQoIlxcLSIpOw0KICAgICAgICAgICAgICAgICAgICBvdXQgPSAiKEFELDA0KVx0KFMsIiArIFNZTVRBQi5nZXQocGFydHNzbHBbMF0pLmdldEluZGV4KCkgKyAiKS0iICsgSW50ZWdlci5wYXJzZUludChwYXJ0c3NscFsxXSk7DQogICAgICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICAgICAgb3V0ID0gIihBRCwwNClcdChDLCIgKyBJbnRlZ2VyLnBhcnNlSW50KHBhZ2VbMl0gKyAiKSIpOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAoU1lNVEFCLmNvbnRhaW5zS2V5KHBhZ2VbMF0pKQ0KICAgICAgICAgICAgICAgICAgICBTWU1UQUIucHV0KHBhZ2VbMF0sIG5ldyBUYWJsZVJvdyhwYWdlWzBdLCBsb2MsIFNZTVRBQi5nZXQocGFnZVswXSkuZ2V0SW5kZXgoKSkpOw0KICAgICAgICAgICAgICAgIGVsc2UNCiAgICAgICAgICAgICAgICAgICAgU1lNVEFCLnB1dChwYWdlWzBdLCBuZXcgVGFibGVSb3cocGFnZVswXSwgbG9jLCArK3N5bUluZGV4KSk7DQoNCiAgICAgICAgICAgIH0gZWxzZSBpZiAocGFnZVsxXS5lcXVhbHMoIk9SSUdJTiIpKSB7DQogICAgICAgICAgICAgICAgU3RyaW5nIHBhcnRzbHBbXSA9IChwYWdlWzJdKS5zcGxpdCgiXFwrIik7DQogICAgICAgICAgICAgICAgb3V0ID0gIigiICsgTU9ULmNoZWNrY2xzKHBhZ2VbMV0pICsgIiwiICsgTU9ULmNoZWNrb3AocGFnZVsxXSkgKyAiKVx0KFMsIiArIFNZTVRBQi5nZXQocGFydHNscFswXSkuZ2V0SW5kZXgoKSArICIpICsgIiArIEludGVnZXIucGFyc2VJbnQocGFydHNscFsxXSk7DQoNCiAgICAgICAgICAgIH0gZWxzZSBpZiAocGFnZVsxXS5lcXVhbHMoIkxUT1JHIikpIHsNCiAgICAgICAgICAgICAgICBpbnQgcHRyID0gUE9PTFRBQi5nZXQocG9vbHRhYl9wdHIpOw0KICAgICAgICAgICAgICAgIGZvciAoaW50IGogPSBwdHI7IGogPCBsaWJ0YWJfcHRyOyBqKyspIHsNCiAgICAgICAgICAgICAgICAgICAgbGMrKzsNCiAgICAgICAgICAgICAgICAgICAgTElUVEFCLnNldChqLCBuZXcgVGFibGVSb3coTElUVEFCLmdldChqKS5nZXRTeW1ib2woKSwgbGMpKTsNCiAgICAgICAgICAgICAgICAgICAgb3V0ID0gIigiICsgTU9ULmNoZWNrY2xzKHBhZ2VbMV0pICsgIiwiICsgTU9ULmNoZWNrb3AocGFnZVsxXSkgKyAiKVx0KEMsIiArIExJVFRBQi5nZXQoaikuc3ltYm9sICsgIikiOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBwb29sdGFiX3B0cisrOw0KICAgICAgICAgICAgICAgIGxjKys7DQogICAgICAgICAgICAgICAgUE9PTFRBQi5hZGQobGlidGFiX3B0cik7DQoNCiAgICAgICAgICAgIH0gZWxzZSBpZiAocGFnZVsxXS5lcXVhbHMoIkRDIikpIHsNCg0KICAgICAgICAgICAgICAgIGludCBzaXplID0gSW50ZWdlci5wYXJzZUludChwYWdlWzJdLnJlcGxhY2UoIiciLCAiIikpOw0KICAgICAgICAgICAgICAgIG91dCA9ICIoIiArIE1PVC5jaGVja2NscyhwYWdlWzFdKSArICIsIiArIE1PVC5jaGVja29wKHBhZ2VbMV0pICsgIilcdChDLCIgKyBzaXplICsgIikiOw0KDQoNCiAgICAgICAgICAgIH0gZWxzZSBpZiAocGFnZVsxXS5lcXVhbHMoIkRTIikpIHsNCiAgICAgICAgICAgICAgICBsYysrOw0KICAgICAgICAgICAgICAgIG91dCA9ICIoIiArIE1PVC5jaGVja2NscyhwYWdlWzFdKSArICIsIiArIE1PVC5jaGVja29wKHBhZ2VbMV0pICsgIilcdChDLCIgKyBwYWdlWzJdICsgIikiOw0KDQogICAgICAgICAgICB9IGVsc2UgaWYgKHBhZ2VbMV0uZXF1YWxzKCJFTkQiKSkgew0KICAgICAgICAgICAgICAgIGludCBwdHIgPSBQT09MVEFCLmdldChwb29sdGFiX3B0cik7DQogICAgICAgICAgICAgICAgZm9yIChpbnQgaiA9IHB0cjsgaiA8IHBvb2x0YWJfcHRyOyBqKyspIHsNCiAgICAgICAgICAgICAgICAgICAgbGMrKzsNCiAgICAgICAgICAgICAgICAgICAgTElUVEFCLnNldChqLCBuZXcgVGFibGVSb3coTElUVEFCLmdldChqKS5nZXRTeW1ib2woKSwgbGMpKTsNCiAgICAgICAgICAgICAgICAgICAgb3V0ID0gIigiICsgTU9ULmNoZWNrY2xzKHBhZ2VbMV0pICsgIiwiICsgTU9ULmNoZWNrb3AocGFnZVsxXSkgKyAiKVx0KEMsIiArIExJVFRBQi5nZXQoaikuc3ltYm9sICsgIikiOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBwb29sdGFiX3B0cisrOw0KICAgICAgICAgICAgICAgIFBPT0xUQUIuYWRkKGxpYnRhYl9wdHIpOw0KICAgICAgICAgICAgICAgIG91dCA9ICIoQUQsMDIpIjsNCg0KICAgICAgICAgICAgfQ0KDQogICAgICAgICAgICBpZiAoTU9ULmNoZWNrY2xzKHBhZ2VbMV0pLmVxdWFscygiSVMiKSkgew0KICAgICAgICAgICAgICAgIGludCBsZW4gPSBwYWdlLmxlbmd0aDsNCiAgICAgICAgICAgICAgICBTdHJpbmcgRmluYWxPcCA9ICIiOw0KICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAyOyBpIDwgbGVuOyBpKyspIHsNCiAgICAgICAgICAgICAgICAgICAgcGFnZVtpXSA9IHBhZ2VbaV0ucmVwbGFjZSgiLCIsICIiKTsNCiAgICAgICAgICAgICAgICAgICAgaWYgKE1PVC5jaGVja2NscyhwYWdlW2ldKSA9PSAiUkciKSB7DQovLyAgICAgICAgICAgICAgICAgICAgICAgIEZpbmFsT3AgKz0gTU9ULmNoZWNrb3AocGFnZVtpXSkgKyAiXHQiOw0KICAgICAgICAgICAgICAgICAgICAgICAgRmluYWxPcCArPSAiICAoUkcsIitNT1QuY2hlY2tvcChwYWdlW2ldKSsiKSAgICI7DQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFnZVtpXS5jb250YWlucygiPSIpKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVtpXSA9IHBhZ2VbaV0ucmVwbGFjZSgiPSIsICIiKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlW2ldID0gcGFnZVtpXS5yZXBsYWNlKCInIiwgIiIpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIExJVFRBQi5hZGQobmV3IFRhYmxlUm93KHBhZ2VbaV0sIC0xLCArK2xpdEluZGV4KSk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlidGFiX3B0cisrOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZpbmFsT3AgKz0gIihMLCIgKyBsaWJ0YWJfcHRyICsgIikiOw0KDQogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKFNZTVRBQi5jb250YWluc0tleShwYWdlW2ldKSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCBTaW5kZXggPSBTWU1UQUIuZ2V0KHBhZ2VbaV0pLmdldEluZGV4KCk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgRmluYWxPcCArPSAiKFMsIiArIFNpbmRleCArICIpIjsNCiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgU1lNVEFCLnB1dChwYWdlW2ldLCBuZXcgVGFibGVSb3cocGFnZVtpXSwgLTEsICsrc3ltSW5kZXgpKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgU2luZGV4ID0gU1lNVEFCLmdldChwYWdlW2ldKS5nZXRJbmRleCgpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZpbmFsT3AgKz0gIihTLCIgKyBTaW5kZXggKyAiKSI7DQogICAgICAgICAgICAgICAgICAgICAgICB9DQoNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIH0NCg0KICAgICAgICAgICAgICAgIGxjKys7DQogICAgICAgICAgICAgICAgb3V0ID0gIigiICsgTU9ULmNoZWNrY2xzKHBhZ2VbMV0pICsgIiwiICsgTU9ULmNoZWNrb3AocGFnZVsxXSkgKyAiKSIgKyBGaW5hbE9wOw0KICAgICAgICAgICAgfQ0KLy8gICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50KCJNbmV1bW9uaWMtPiIgKyBwYWdlWzFdICsgIlxuIik7DQoNCiAgICAgICAgfQ0KICAgICAgICBQcmludGVyKCJQVGFiIik7DQogICAgICAgIFByaW50ZXIoIkxUYWIiKTsNCiAgICAgICAgUHJpbnRlcigiU1RhYiIpOw0KICAgIH0NCg0KICAgIHB1YmxpYyB2b2lkIFByaW50ZXIoU3RyaW5nIE9QVCkgdGhyb3dzIElPRXhjZXB0aW9uIHsNCiAgICAgICAgc3dpdGNoKE9QVCl7DQogICAgICAgICAgICBjYXNlICJTVGFiIjoNCiAgICAgICAgICAgICAgICBCdWZmZXJlZFdyaXRlciBydz1uZXcgQnVmZmVyZWRXcml0ZXIobmV3IEZpbGVXcml0ZXIoIlNZTVRBQi50eHQiKSk7DQogICAgICAgICAgICAgICAgLy9QcmludGluZyBTeW1ib2wgVGFibGUNCiAgICAgICAgICAgICAgICBqYXZhLnV0aWwuSXRlcmF0b3I8U3RyaW5nPiBpdGVyYXRvciA9IFNZTVRBQi5rZXlTZXQoKS5pdGVyYXRvcigpOw0KICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiXG5cblx0U1lNQk9MIFRBQkxFIik7DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJfX19fX19fX19fX19fX19fX19fX19fX19fX19fXyIpOw0KICAgICAgICAgICAgICAgIHdoaWxlIChpdGVyYXRvci5oYXNOZXh0KCkpIHsNCiAgICAgICAgICAgICAgICAgICAgU3RyaW5nIGtleSA9IGl0ZXJhdG9yLm5leHQoKS50b1N0cmluZygpOw0KICAgICAgICAgICAgICAgICAgICBUYWJsZVJvdyB2YWx1ZSA9IFNZTVRBQi5nZXQoa2V5KTsNCiAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJ8XHNccyIrdmFsdWUuZ2V0SW5kZXgoKSsiXHR8XHNccyIgKyB2YWx1ZS5nZXRTeW1ib2woKSsiXHR8XHNcc1xzIit2YWx1ZS5nZXRBZGRyZXNzKCkrIlx0XHR8Iik7DQoNCi8vICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oInwuLi4uLi4ufC4uLi4uLi58Li4uLi4uLi4uLi4uLi4ufCIpOw0KICAgICAgICAgICAgICAgICAgICBydy53cml0ZSh2YWx1ZS5nZXRJbmRleCgpKyJcdCIgKyB2YWx1ZS5nZXRTeW1ib2woKSsiXHQiK3ZhbHVlLmdldEFkZHJlc3MoKSsiXG4iKTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgcncuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBicmVhazsNCg0KICAgICAgICAgICAgY2FzZSAiUFRhYiI6DQogICAgICAgICAgICAgICAgQnVmZmVyZWRXcml0ZXIgcHJ3PW5ldyBCdWZmZXJlZFdyaXRlcihuZXcgRmlsZVdyaXRlcigiUE9PTFRBQi50eHQiKSk7DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJcblxuXHRQT09MIFRBQkxFIFxuIik7DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJfX19fX19fX19fX19fX19fX18iKTsNCiAgICAgICAgICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8UE9PTFRBQi5zaXplKCktMjsgaSsrKSB7DQogICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigifFxzXHMiKyhpKzEpKyJcdHxcc1xzIyIrKFBPT0xUQUIuZ2V0KGkpKzEpKyJcdHwiKTsNCi8vICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oInwuLi4uLi4ufC4uLi4uLi4uLi4uLi4uLnwiKTsNCiAgICAgICAgICAgICAgICAgICAgcHJ3LndyaXRlKChpKzEpKyJcdCMiKyhQT09MVEFCLmdldChpKSsxKSsiXG4iKTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgcHJ3LmNsb3NlKCk7DQogICAgICAgICAgICAgICAgYnJlYWs7DQoNCiAgICAgICAgICAgIGNhc2UgIkxUYWIiOg0KICAgICAgICAgICAgICAgIEJ1ZmZlcmVkV3JpdGVyIGxydz1uZXcgQnVmZmVyZWRXcml0ZXIobmV3IEZpbGVXcml0ZXIoIkxJVFRBQi50eHQiKSk7DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJcblxuXHRMaXRlcmFsIFRhYmxlIik7DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJfX19fX19fX19fX19fX19fX19fX19fX19fX19fIik7DQogICAgICAgICAgICAgICAgLy9Qcm9jZXNzaW5nIExJVFRBQg0KICAgICAgICAgICAgICAgIGZvcihpbnQgaT0wO2k8TElUVEFCLnNpemUoKTtpKyspDQogICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICBUYWJsZVJvdyByb3c9TElUVEFCLmdldChpKTsNCiAgICAgICAg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CiAgICBwcml2YXRlIEJ1ZmZlcmVkUmVhZGVyIGJyOw0KDQogICAgcHVibGljIFBhc3MxKCkgew0KICAgICAgICBTWU1UQUIgPSBuZXcgTGlua2VkSGFzaE1hcDw+KCk7DQogICAgICAgIExJVFRBQiA9IG5ldyBBcnJheUxpc3Q8PigpOw0KICAgICAgICBQT09MVEFCID0gbmV3IEFycmF5TGlzdDw+KCk7DQogICAgICAgIGxjID0gMDsNCiAgICAgICAgUE9PTFRBQi5hZGQoMCk7DQogICAgfQ0KDQogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgdGhyb3dzIEV4Y2VwdGlvbiB7DQogICAgICAgIFBhc3MxIG9iaiA9IG5ldyBQYXNzMSgpOw0KICAgICAgICBvYmoucmVhZEZpbGUoKTsNCiAgICB9DQoNCiAgICBwdWJsaWMgdm9pZCByZWFkRmlsZSgpIHRocm93cyBFeGNlcHRpb24gew0KICAgICAgICBTdHJpbmcgcHJldiA9ICIiOw0KICAgICAgICBTdHJpbmcgbGluZTsNCiAgICAgICAgU3RyaW5nIGNvZGU7DQoNCiAgICAgICAgbmV3IE1PVCgpOw0KICAgICAgICBiciA9IG5ldyBCdWZmZXJlZFJlYWRlcihuZXcgRmlsZVJlYWRlcigiaW5wdXQxLmFzbSIpKTsNCiAgICAgICAgd2hpbGUgKChsaW5lID0gYnIucmVhZExpbmUoKSkgIT0gbnVsbCkgew0KLy8gICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4obGluZSk7DQoNCiAgICAgICAgICAgIFN0cmluZyBwYWdlW10gPSBsaW5lLnNwbGl0KCJcXHMrIik7DQoNCiAgICAgICAgICAgIGlmIChwYWdlWzBdICE9ICIiKSB7Ly9MQUJMRSBWRVJJRklDQVRJT04NCi8vICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnQoIlx0TGFibGUtPiIgKyBwYWdlWzBdICsgIlx0Iik7DQogICAgICAgICAgICAgICAgaWYgKFNZTVRBQi5jb250YWluc0tleShwYWdlWzBdKSkgew0KICAgICAgICAgICAgICAgICAgICBTWU1UQUIucHV0KHBhZ2VbMF0sIG5ldyBUYWJsZVJvdyhwYWdlWzBdLCBsYywgU1lNVEFCLmdldChwYWdlWzBdKS5nZXRJbmRleCgpKSk7DQogICAgICAgICAgICAgICAgICAgIGxjKys7DQogICAgICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICAgICAgU1lNVEFCLnB1dChwYWdlWzBdLCBuZXcgVGFibGVSb3cocGFnZVswXSwgbGMsICsrc3ltSW5kZXgpKTsNCg0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludCgiXHRcdFx0Iik7DQogICAgICAgICAgICB9DQoNCiAgICAgICAgICAgIGlmIChwYWdlWzFdLmVxdWFscygiU1RBUlQiKSkgLy9DSEVDSyBTVEFSVA0KICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgIGxjID0gSW50ZWdlci5wYXJzZUludChwYWdlWzJdKTsNCiAgICAgICAgICAgICAgICBvdXQgPSAiKCIgKyBNT1QuY2hlY2tjbHMocGFnZVsxXSkgKyAiLCIgKyBNT1QuY2hlY2tvcChwYWdlWzFdKSArICIpXHQoQywiICsgcGFnZVsyXSArICIpIjsNCg0KICAgICAgICAgICAgfSBlbHNlIGlmIChwYWdlWzFdLmVxdWFscygiRVFVIikpIHsNCiAgICAgICAgICAgICAgICBTdHJpbmcgc3BsaXQxW10gPSBwYWdlWzJdLnNwbGl0KCJcXCsiKTsNCiAgICAgICAgICAgICAgICBpbnQgbG9jID0gU1lNVEFCLmdldChzcGxpdDFbMF0pLmdldEFkZHJlc3MoKSArIEludGVnZXIucGFyc2VJbnQoc3BsaXQxWzFdKTsNCiAgICAgICAgICAgICAgICAvL2JlbG93IElmIGNvbmRpdGlvbnMgYXJlIG9wdGlvbmFsIGFzIG5vIElDIGlzIGdlbmVyYXRlZCBmb3IgdGhlbQ0KICAgICAgICAgICAgICAgIGlmIChwYWdlWzJdLmNvbnRhaW5zKCIrIikpIHsNCiAgICAgICAgICAgICAgICAgICAgU3RyaW5nIHBhcnRzc2xwW10gPSBwYWdlWzJdLnNwbGl0KCJcXCsiKTsNCiAgICAgICAgICAgICAgICAgICAgb3V0ID0gIihBRCwwNClcdChTLCIgKyBTWU1UQUIuZ2V0KHBhcnRzc2xwWzBdKS5nZXRJbmRleCgpICsgIikgKyAiICsgSW50ZWdlci5wYXJzZUludChwYXJ0c3NscFsxXSk7DQoNCiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHBhZ2VbMl0uY29udGFpbnMoIi0iKSkgew0KICAgICAgICAgICAgICAgICAgICBTdHJpbmcgcGFydHNzbHBbXSA9IHBhZ2VbMl0uc3BsaXQoIlxcLSIpOw0KICAgICAgICAgICAgICAgICAgICBvdXQgPSAiKEFELDA0KVx0KFMsIiArIFNZTVRBQi5nZXQocGFydHNzbHBbMF0pLmdldEluZGV4KCkgKyAiKS0iICsgSW50ZWdlci5wYXJzZUludChwYXJ0c3NscFsxXSk7DQogICAgICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICAgICAgb3V0ID0gIihBRCwwNClcdChDLCIgKyBJbnRlZ2VyLnBhcnNlSW50KHBhZ2VbMl0gKyAiKSIpOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAoU1lNVEFCLmNvbnRhaW5zS2V5KHBhZ2VbMF0pKQ0KICAgICAgICAgICAgICAgICAgICBTWU1UQUIucHV0KHBhZ2VbMF0sIG5ldyBUYWJsZVJvdyhwYWdlWzBdLCBsb2MsIFNZTVRBQi5nZXQocGFnZVswXSkuZ2V0SW5kZXgoKSkpOw0KICAgICAgICAgICAgICAgIGVsc2UNCiAgICAgICAgICAgICAgICAgICAgU1lNVEFCLnB1dChwYWdlWzBdLCBuZXcgVGFibGVSb3cocGFnZVswXSwgbG9jLCArK3N5bUluZGV4KSk7DQoNCiAgICAgICAgICAgIH0gZWxzZSBpZiAocGFnZVsxXS5lcXVhbHMoIk9SSUdJTiIpKSB7DQogICAgICAgICAgICAgICAgU3RyaW5nIHBhcnRzbHBbXSA9IChwYWdlWzJdKS5zcGxpdCgiXFwrIik7DQogICAgICAgICAgICAgICAgb3V0ID0gIigiICsgTU9ULmNoZWNrY2xzKHBhZ2VbMV0pICsgIiwiICsgTU9ULmNoZWNrb3AocGFnZVsxXSkgKyAiKVx0KFMsIiArIFNZTVRBQi5nZXQocGFydHNscFswXSkuZ2V0SW5kZXgoKSArICIpICsgIiArIEludGVnZXIucGFyc2VJbnQocGFydHNscFsxXSk7DQoNCiAgICAgICAgICAgIH0gZWxzZSBpZiAocGFnZVsxXS5lcXVhbHMoIkxUT1JHIikpIHsNCiAgICAgICAgICAgICAgICBpbnQgcHRyID0gUE9PTFRBQi5nZXQocG9vbHRhYl9wdHIpOw0KICAgICAgICAgICAgICAgIGZvciAoaW50IGogPSBwdHI7IGogPCBsaWJ0YWJfcHRyOyBqKyspIHsNCiAgICAgICAgICAgICAgICAgICAgbGMrKzsNCiAgICAgICAgICAgICAgICAgICAgTElUVEFCLnNldChqLCBuZXcgVGFibGVSb3coTElUVEFCLmdldChqKS5nZXRTeW1ib2woKSwgbGMpKTsNCiAgICAgICAgICAgICAgICAgICAgb3V0ID0gIigiICsgTU9ULmNoZWNrY2xzKHBhZ2VbMV0pICsgIiwiICsgTU9ULmNoZWNrb3AocGFnZVsxXSkgKyAiKVx0KEMsIiArIExJVFRBQi5nZXQoaikuc3ltYm9sICsgIikiOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBwb29sdGFiX3B0cisrOw0KICAgICAgICAgICAgICAgIGxjKys7DQogICAgICAgICAgICAgICAgUE9PTFRBQi5hZGQobGlidGFiX3B0cik7DQoNCiAgICAgICAgICAgIH0gZWxzZSBpZiAocGFnZVsxXS5lcXVhbHMoIkRDIikpIHsNCg0KICAgICAgICAgICAgICAgIGludCBzaXplID0gSW50ZWdlci5wYXJzZUludChwYWdlWzJdLnJlcGxhY2UoIiciLCAiIikpOw0KICAgICAgICAgICAgICAgIG91dCA9ICIoIiArIE1PVC5jaGVja2NscyhwYWdlWzFdKSArICIsIiArIE1PVC5jaGVja29wKHBhZ2VbMV0pICsgIilcdChDLCIgKyBzaXplICsgIikiOw0KDQoNCiAgICAgICAgICAgIH0gZWxzZSBpZiAocGFnZVsxXS5lcXVhbHMoIkRTIikpIHsNCiAgICAgICAgICAgICAgICBsYysrOw0KICAgICAgICAgICAgICAgIG91dCA9ICIoIiArIE1PVC5jaGVja2NscyhwYWdlWzFdKSArICIsIiArIE1PVC5jaGVja29wKHBhZ2VbMV0pICsgIilcdChDLCIgKyBwYWdlWzJdICsgIikiOw0KDQogICAgICAgICAgICB9IGVsc2UgaWYgKHBhZ2VbMV0uZXF1YWxzKCJFTkQiKSkgew0KICAgICAgICAgICAgICAgIGludCBwdHIgPSBQT09MVEFCLmdldChwb29sdGFiX3B0cik7DQogICAgICAgICAgICAgICAgZm9yIChpbnQgaiA9IHB0cjsgaiA8IHBvb2x0YWJfcHRyOyBqKyspIHsNCiAgICAgICAgICAgICAgICAgICAgbGMrKzsNCiAgICAgICAgICAgICAgICAgICAgTElUVEFCLnNldChqLCBuZXcgVGFibGVSb3coTElUVEFCLmdldChqKS5nZXRTeW1ib2woKSwgbGMpKTsNCiAgICAgICAgICAgICAgICAgICAgb3V0ID0gIigiICsgTU9ULmNoZWNrY2xzKHBhZ2VbMV0pICsgIiwiICsgTU9ULmNoZWNrb3AocGFnZVsxXSkgKyAiKVx0KEMsIiArIExJVFRBQi5nZXQoaikuc3ltYm9sICsgIikiOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBwb29sdGFiX3B0cisrOw0KICAgICAgICAgICAgICAgIFBPT0xUQUIuYWRkKGxpYnRhYl9wdHIpOw0KICAgICAgICAgICAgICAgIG91dCA9ICIoQUQsMDIpIjsNCg0KICAgICAgICAgICAgfQ0KDQogICAgICAgICAgICBpZiAoTU9ULmNoZWNrY2xzKHBhZ2VbMV0pLmVxdWFscygiSVMiKSkgew0KICAgICAgICAgICAgICAgIGludCBsZW4gPSBwYWdlLmxlbmd0aDsNCiAgICAgICAgICAgICAgICBTdHJpbmcgRmluYWxPcCA9ICIiOw0KICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAyOyBpIDwgbGVuOyBpKyspIHsNCiAgICAgICAgICAgICAgICAgICAgcGFnZVtpXSA9IHBhZ2VbaV0ucmVwbGFjZSgiLCIsICIiKTsNCiAgICAgICAgICAgICAgICAgICAgaWYgKE1PVC5jaGVja2NscyhwYWdlW2ldKSA9PSAiUkciKSB7DQovLyAgICAgICAgICAgICAgICAgICAgICAgIEZpbmFsT3AgKz0gTU9ULmNoZWNrb3AocGFnZVtpXSkgKyAiXHQiOw0KICAgICAgICAgICAgICAgICAgICAgICAgRmluYWxPcCArPSAiICAoUkcsIitNT1QuY2hlY2tvcChwYWdlW2ldKSsiKSAgICI7DQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFnZVtpXS5jb250YWlucygiPSIpKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVtpXSA9IHBhZ2VbaV0ucmVwbGFjZSgiPSIsICIiKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlW2ldID0gcGFnZVtpXS5yZXBsYWNlKCInIiwgIiIpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIExJVFRBQi5hZGQobmV3IFRhYmxlUm93KHBhZ2VbaV0sIC0xLCArK2xpdEluZGV4KSk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlidGFiX3B0cisrOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZpbmFsT3AgKz0gIihMLCIgKyBsaWJ0YWJfcHRyICsgIikiOw0KDQogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKFNZTVRBQi5jb250YWluc0tleShwYWdlW2ldKSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCBTaW5kZXggPSBTWU1UQUIuZ2V0KHBhZ2VbaV0pLmdldEluZGV4KCk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgRmluYWxPcCArPSAiKFMsIiArIFNpbmRleCArICIpIjsNCiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgU1lNVEFCLnB1dChwYWdlW2ldLCBuZXcgVGFibGVSb3cocGFnZVtpXSwgLTEsICsrc3ltSW5kZXgpKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgU2luZGV4ID0gU1lNVEFCLmdldChwYWdlW2ldKS5nZXRJbmRleCgpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZpbmFsT3AgKz0gIihTLCIgKyBTaW5kZXggKyAiKSI7DQogICAgICAgICAgICAgICAgICAgICAgICB9DQoNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIH0NCg0KICAgICAgICAgICAgICAgIGxjKys7DQogICAgICAgICAgICAgICAgb3V0ID0gIigiICsgTU9ULmNoZWNrY2xzKHBhZ2VbMV0pICsgIiwiICsgTU9ULmNoZWNrb3AocGFnZVsxXSkgKyAiKSIgKyBGaW5hbE9wOw0KICAgICAgICAgICAgfQ0KLy8gICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50KCJNbmV1bW9uaWMtPiIgKyBwYWdlWzFdICsgIlxuIik7DQoNCiAgICAgICAgfQ0KICAgICAgICBQcmludGVyKCJQVGFiIik7DQogICAgICAgIFByaW50ZXIoIkxUYWIiKTsNCiAgICAgICAgUHJpbnRlcigiU1RhYiIpOw0KICAgIH0NCg0KICAgIHB1YmxpYyB2b2lkIFByaW50ZXIoU3RyaW5nIE9QVCkgdGhyb3dzIElPRXhjZXB0aW9uIHsNCiAgICAgICAgc3dpdGNoKE9QVCl7DQogICAgICAgICAgICBjYXNlICJTVGFiIjoNCiAgICAgICAgICAgICAgICBCdWZmZXJlZFdyaXRlciBydz1uZXcgQnVmZmVyZWRXcml0ZXIobmV3IEZpbGVXcml0ZXIoIlNZTVRBQi50eHQiKSk7DQogICAgICAgICAgICAgICAgLy9QcmludGluZyBTeW1ib2wgVGFibGUNCiAgICAgICAgICAgICAgICBqYXZhLnV0aWwuSXRlcmF0b3I8U3RyaW5nPiBpdGVyYXRvciA9IFNZTVRBQi5rZXlTZXQoKS5pdGVyYXRvcigpOw0KICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiXG5cblx0U1lNQk9MIFRBQkxFIik7DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJfX19fX19fX19fX19fX19fX19fX19fX19fX19fXyIpOw0KICAgICAgICAgICAgICAgIHdoaWxlIChpdGVyYXRvci5oYXNOZXh0KCkpIHsNCiAgICAgICAgICAgICAgICAgICAgU3RyaW5nIGtleSA9IGl0ZXJhdG9yLm5leHQoKS50b1N0cmluZygpOw0KICAgICAgICAgICAgICAgICAgICBUYWJsZVJvdyB2YWx1ZSA9IFNZTVRBQi5nZXQoa2V5KTsNCiAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJ8XHNccyIrdmFsdWUuZ2V0SW5kZXgoKSsiXHR8XHNccyIgKyB2YWx1ZS5nZXRTeW1ib2woKSsiXHR8XHNcc1xzIit2YWx1ZS5nZXRBZGRyZXNzKCkrIlx0XHR8Iik7DQoNCi8vICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oInwuLi4uLi4ufC4uLi4uLi58Li4uLi4uLi4uLi4uLi4ufCIpOw0KICAgICAgICAgICAgICAgICAgICBydy53cml0ZSh2YWx1ZS5nZXRJbmRleCgpKyJcdCIgKyB2YWx1ZS5nZXRTeW1ib2woKSsiXHQiK3ZhbHVlLmdldEFkZHJlc3MoKSsiXG4iKTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgcncuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBicmVhazsNCg0KICAgICAgICAgICAgY2FzZSAiUFRhYiI6DQogICAgICAgICAgICAgICAgQnVmZmVyZWRXcml0ZXIgcHJ3PW5ldyBCdWZmZXJlZFdyaXRlcihuZXcgRmlsZVdyaXRlcigiUE9PTFRBQi50eHQiKSk7DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJcblxuXHRQT09MIFRBQkxFIFxuIik7DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJfX19fX19fX19fX19fX19fX18iKTsNCiAgICAgICAgICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8UE9PTFRBQi5zaXplKCktMjsgaSsrKSB7DQogICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigifFxzXHMiKyhpKzEpKyJcdHxcc1xzIyIrKFBPT0xUQUIuZ2V0KGkpKzEpKyJcdHwiKTsNCi8vICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oInwuLi4uLi4ufC4uLi4uLi4uLi4uLi4uLnwiKTsNCiAgICAgICAgICAgICAgICAgICAgcHJ3LndyaXRlKChpKzEpKyJcdCMiKyhQT09MVEFCLmdldChpKSsxKSsiXG4iKTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgcHJ3LmNsb3NlKCk7DQogICAgICAgICAgICAgICAgYnJlYWs7DQoNCiAgICAgICAgICAgIGNhc2UgIkxUYWIiOg0KICAgICAgICAgICAgICAgIEJ1ZmZlcmVkV3JpdGVyIGxydz1uZXcgQnVmZmVyZWRXcml0ZXIobmV3IEZpbGVXcml0ZXIoIkxJVFRBQi50eHQiKSk7DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJcblxuXHRMaXRlcmFsIFRhYmxlIik7DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJfX19fX19fX19fX19fX19fX19fX19fX19fX19fIik7DQogICAgICAgICAgICAgICAgLy9Qcm9jZXNzaW5nIExJVFRBQg0KICAgICAgICAgICAgICAgIGZvcihpbnQgaT0wO2k8TElUVEFCLnNpemUoKTtpKyspDQogICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICBUYWJsZVJvdyByb3c9TElUVEFCLmdldChpKTsNCiAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJ8XHNccyIrKGkrMSkrIlx0fFxzXHMiK3Jvdy5nZXRTeW1ib2woKSsiXHR8XHNcc1xzIityb3cuZ2V0QWRkcmVzcygpKyJcdFx0fCIpOw0KLy8gICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigifC4uLi4uLi58Li4uLi4uLnwuLi4uLi4uLi4uLi4uLi58Iik7DQogICAgICAgICAgICAgICAgICAgIGxydy53cml0ZSgoaSsxKSsiXHQiK3Jvdy5nZXRTeW1ib2woKSsiXHQiK3Jvdy5nZXRBZGRyZXNzKCkrIlxuIik7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIGxydy5jbG9zZSgpOw0KICAgICAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICAgICAgZGVmYXVsdDoNCiAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkRhdGEgU2V0IE5vdCBwcm92aWRlZCIpOw0KICAgICAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICB9DQoNCiAgICB9DQoNCn0NCg0KUGFzczIuamF2YQ0KDQppbXBvcnQgamF2YS5pby5CdWZmZXJlZFJlYWRlcjsNCmltcG9ydCBqYXZhLmlvLkZpbGVSZWFkZXI7DQppbXBvcnQgamF2YS5pby5GaWxlV3JpdGVyOw0KaW1wb3J0IGphdmEuaW8uSU9FeGNlcHRpb247DQppbXBvcnQgamF2YS51dGlsLkhhc2hNYXA7DQ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W10gPSBuZXcgaW50W25dOw0KLy8gQ29weSB0aGUgYnVyc3QgdGltZSBpbnRvIHJ0W10NCiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspDQogICAgICAgICAgICBydFtpXSA9IHByb2NbaV0uYnQ7DQogICAgICAgIGludCBjb21wbGV0ZSA9IDAsIHQgPSAwLCBtaW5tID0gSW50ZWdlci5NQVhfVkFMVUU7DQogICAgICAgIGludCBzaG9ydGVzdCA9IDAsIGZpbmlzaF90aW1lOw0KICAgICAgICBib29sZWFuIGNoZWNrID0gZmFsc2U7DQovLyBQcm9jZXNzIHVudGlsIGFsbCBwcm9jZXNzZXMgZ2V0cw0KLy8gY29tcGxldGVkDQogICAgICAgIHdoaWxlIChjb21wbGV0ZSAhPSBuKSB7DQovLyBGaW5kIHByb2Nlc3Mgd2l0aCBtaW5pbXVtDQovLyByZW1haW5pbmcgdGltZSBhbW9uZyB0aGUNCi8vIHByb2Nlc3NlcyB0aGF0IGFycml2ZXMgdGlsbCB0aGUNCi8vIGN1cnJlbnQgdGltZWANCiAgICAgICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgbjsgaisrKQ0KICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgIGlmICgocHJvY1tqXS5hcnQgPD0gdCkgJiYNCiAgICAgICAgICAgICAgICAgICAgICAgIChydFtqXSA8IG1pbm0pICYmIHJ0W2pdID4gMCkgew0KICAgICAgICAgICAgICAgICAgICBtaW5tID0gcnRbal07DQogICAgICAgICAgICAgICAgICAgIHNob3J0ZXN0ID0gajsNCiAgICAgICAgICAgICAgICAgICAgY2hlY2sgPSB0cnVlOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIGlmIChjaGVjayA9PSBmYWxzZSkgew0KICAgICAgICAgICAgICAgIHQrKzsNCiAgICAgICAgICAgICAgICBjb250aW51ZTsNCiAgICAgICAgICAgIH0NCi8vIFJlZHVjZSByZW1haW5pbmcgdGltZSBieSBvbmUNCiAgICAgICAgICAgIHJ0W3Nob3J0ZXN0XS0tOw0KLy8gVXBkYXRlIG1pbmltdW0NCiAgICAgICAgICAgIG1pbm0gPSBydFtzaG9ydGVzdF07DQogICAgICAgICAgICBpZiAobWlubSA9PSAwKQ0KICAgICAgICAgICAgICAgIG1pbm0gPSBJbnRlZ2VyLk1BWF9WQUxVRTsNCi8vIElmIGEgcHJvY2VzcyBnZXRzIGNvbXBsZXRlbHkNCi8vIGV4ZWN1dGVkDQogICAgICAgICAgICBpZiAocnRbc2hvcnRlc3RdID09IDApIHsNCi8vIEluY3JlbWVudCBjb21wbGV0ZQ0KICAgICAgICAgICAgICAgIGNvbXBsZXRlKys7DQogICAgICAgICAgICAgICAgY2hlY2sgPSBmYWxzZTsNCi8vIEZpbmQgZmluaXNoIHRpbWUgb2YgY3VycmVudA0KLy8gcHJvY2Vzcw0KICAgICAgICAgICAgICAgIGZpbmlzaF90aW1lID0gdCArIDE7DQovLyBDYWxjdWxhdGUgd2FpdGluZyB0aW1lDQogICAgICAgICAgICAgICAgd3Rbc2hvcnRlc3RdID0gZmluaXNoX3RpbWUgLQ0KICAgICAgICAgICAgICAgICAgICAgICAgcHJvY1tzaG9ydGVzdF0uYnQgLQ0KICAgICAgICAgICAgICAgICAgICAgICAgcHJvY1tzaG9ydGVzdF0uYXJ0Ow0KICAgICAgICAgICAgICAgIGlmICh3dFtzaG9ydGVzdF0gPCAwKQ0KICAgICAgICAgICAgICAgICAgICB3dFtzaG9ydGVzdF0gPSAwOw0KICAgICAgICAgICAgfQ0KLy8gSW5jcmVtZW50IHRpbWUNCiAgICAgICAgICAgIHQrKzsNCiAgICAgICAgfQ0KICAgIH0NCiAgICAvLyBNZXRob2QgdG8gY2FsY3VsYXRlIHR1cm4gYXJvdW5kIHRpbWUNCiAgICBzdGF0aWMgdm9pZCBmaW5kVHVybkFyb3VuZFRpbWUoUHJvY2VzcyBwcm9jW10sIGludCBuLA0KICAgICAgICAgICAgICAgICAgICA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JuIGFyb3VuZCB0aW1lDQogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7DQogICAgICAgICAgICB0b3RhbF93dCA9IHRvdGFsX3d0ICsgd3RbaV07DQogICAgICAgICAgICB0b3RhbF90YXQgPSB0b3RhbF90YXQgKyB0YXRbaV07DQogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIiAiICsgcHJvY1tpXS5waWQgKyAiXHRcdCINCiAgICAgICAgICAgICAgICAgICAgKyBwcm9jW2ldLmJ0ICsgIlx0XHQgIiArIHd0W2ldDQogICAgICAgICAgICAgICAgICAgICsgIlx0XHQiICsgdGF0W2ldKTsNCiAgICAgICAgfQ0KICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkF2ZXJhZ2Ugd2FpdGluZyB0aW1lID0gIiArDQogICAgICAgICAgICAgICAgKGZsb2F0KXRvdGFsX3d0IC8gKGZsb2F0KW4pOw0KICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkF2ZXJhZ2UgdHVybiBhcm91bmQgdGltZSA9ICIgKw0KICAgICAgICAgICAgICAgIChmbG9hdCl0b3RhbF90YXQgLyAoZmxvYXQpbik7DQogICAgfQ0KfQ0KY2xhc3MgUlINCnsNCiAgICAvL01ldGhvZCB0byBmaW5kIHRoZSB3YWl0aW5nIHRpbWUgZm9yIGFsbA0KLy9wcm9jZXNzZXMNCiAgICBzdGF0aWMgdm9pZCBmaW5kV2FpdGluZ1RpbWUoaW50IHByb2Nlc3Nlc1tdLCBpbnQgbiwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IGJ0W10sIGludCB3dFtdLCBpbnQgcXVhbnR1bSkNCiAgICB7DQovLyBNYWtlIGEgY29weSBvZiBidXJzdCB0aW1lcyBidFtdIHRvIHN0b3JlIHJlbWFpbmluZw0KLy8gYnVyc3QgdGltZXMuDQogICAgICAgIGludCByZW1fYnRbXSA9IG5ldyBpbnRbbl07DQogICAgICAgIGZvciA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GltZSBhbmQgdG90YWwgdHVybg0KLy8gYXJvdW5kIHRpbWUNCiAgICAgICAgZm9yIChpbnQgaT0wOyBpPG47IGkrKykNCiAgICAgICAgew0KICAgICAgICAgICAgdG90YWxfd3QgPSB0b3RhbF93dCArIHd0W2ldOw0KICAgICAgICAgICAgdG90YWxfdGF0ID0gdG90YWxfdGF0ICsgdGF0W2ldOw0KICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCIgIiArIChpKzEpICsgIlx0XHQiICsgYnRbaV0gKyJcdCAiICsNCiAgICAgICAgICAgICAgICAgICAgd3RbaV0gKyJcdFx0ICIgKyB0YXRbaV0pOw0KICAgICAgICB9DQogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiQXZlcmFnZSB3YWl0aW5nIHRpbWUgPSAiICsNCiAgICAgICAgICAgICAgICAoZmxvYXQpdG90YWxfd3QgLyAoZmxvYXQpbik7DQogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiQXZlcmFnZSB0dXJuIGFyb3VuZCB0aW1lID0gIiArDQogICAgICAgICAgICAgICAgKGZsb2F0KXRvdGFsX3RhdCAvIChmbG9hdCluKTsNCiAgICB9DQp9DQpjbGFzcyBQcmlvcml0eSB7DQogICAgdm9pZCBwcmlvcml0eShTdHJpbmcgcHJvY2Vzc2VzW10sIGludCBuLCBpbnQgYnVyc3RUaW1lW10sIGludCBwcmlvcml0eVtdKSB7DQogICAgICAgIGludCBudW1iZXJPZlByb2Nlc3MgPSBuOw0KICAgICAgICBpbnQgdGVtcDsNCiAgICAgICAgU3RyaW5nIHRlbXAyOw0KLy8gU29ydGluZyBwcm9jZXNzICYgYnVyc3QgdGltZSBieSBwcmlvcml0eQ0KICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IG51bWJlck9mUHJvY2VzcyAtIDE7IGkrKykgew0KICAgICAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCBudW1iZXJPZlByb2Nlc3MgLSAxOyBqKyspIHsNCiAgICAgICAgICAgICAgICBpZiAocHJpb3JpdHlbal0gPiBwcmlvcml0eVtqICsgMV0pIHsNCiAgICAgICAgICAgICAgICAgICAgdGVtcCA9IHByaW9yaXR5W2pdOw0KICAgICAgICAgICAgICAgICAgICBwcmlvcml0eVtqXSA9IHByaW9yaXR5W2ogKyAxXTsNCiAgICAgICAgICAgICAgICAgICAgcHJpb3JpdHlbaiArIDFdID0gdGVtcDsNCiAgICAgICAgICAgICAgICAgICAgdGVtcCA9IGJ1cnN0VGltZVtqXTsNCiAgICAgICAgICAgICAgICAgICAgYnVyc3RUaW1lW2pdID0gYnVyc3RUaW1lW2ogKyAxXTsNCiAgICAgICAgICAgICAgICAgICAgYnVyc3RUaW1lW2ogKyAxXSA9IHRlbXA7DQogICAgICAgICAgICAgICAgICAgIHRlbXAyID0gcHJvY2Vzc2VzW2pdOw0KICAgICAgICAgICAgICAgICAgICBwcm9jZXNzZXNbal0gPSBwcm9jZXNzZXNbaiArIDFdOw0KICAgICAgICAgICAgICAgICAgICBwcm9jZXNzZXNbaiArIDFdID0gdGVtcDI7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgfQ0KICAgICAgICB9DQovLyBUQVQgLSBUdXJuIEFyb3VuZCBUaW1lDQogICAgICAgIGludCBUQVRbXSA9IG5ldyBpbnRbbnVtYmVyT2ZQcm9jZXNzICsgMV07DQogICAgICAgIGludCB3YWl0aW5nVGltZVtdID0gbmV3IGludFtudW1iZXJPZlByb2Nlc3MgKyAxXTsNCi8vIENhbGN1bGF0aW5nIFdhaXRpbmcgVGltZSAmIFR1cm4gQXJvdW5kIFRpbWUNCiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBudW1iZXJPZlByb2Nlc3M7IGkrKykgew0KICAgICAgICAgICAgVEFUW2ldID0gYnVyc3RUaW1lW2ldICsgd2FpdGluZ1RpbWVbaV07DQogICAgICAgICAgICB3YWl0aW5nVGltZVtpICsgMV0gPSBUQVRbaV07DQogICAgICAgIH0NCi8vIFd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ID0gbmV3IEZDRlMoKTsNCiAgICAgICAgU0pGIHNqZiA9IG5ldyBTSkYoKTsNCiAgICAgICAgUlIgcnIgPSBuZXcgUlIoKTsNCiAgICAgICAgUHJpb3JpdHkgcHIgPSBuZXcgUHJpb3JpdHkoKTsNCiAgICAgICAgU2Nhbm5lciBzY2FuID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsNCiAgICAgICAgd2hpbGUodHJ1ZSl7DQogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIlxuIFRoZSBhdmFpbGFibGUgYWxnb3JpdGhtcyBhcmU6ICIpOw0KICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCIxLiBGQ0ZTIik7DQogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIjIuIFNKRiIpOw0KICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCIzLiBSUiIpOw0KICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCI0LiBQcmlvcml0eSIpOw0KICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCI1LiBFeGl0Iik7DQogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkNob29zZSB5b3VyIGFsZ29yaXRobTogIik7DQogICAgICAgICAgICBpbnQgYWxnbyA9IHNjYW4ubmV4dEludCgpOw0KICAgICAgICAgICAgaWYgKGFsZ289PTEpew0KICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiRW50ZXIgdGhlIG51bWJlciBvZiBwcm9jZXNzZXM6ICIpOw0KICAgICAgICAgICAgICAgIGludCBuID0gc2Nhbi5uZXh0SW50KCk7DQogICAgICAgICAgICAgICAgaW50W10gcHJvY2Vzc2VzID0gbmV3IGludFtuXTsNCi8vQnVyc3QgdGltZSBvZiBhbGwgcHJvY2Vzc2VzDQogICAgICAgICAgICAgICAgaW50W10gYnVyc3RfdGltZSA9IG5ldyBpbnRbbl07DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJFbnRlciB0aGUgcHJvY2Vzc2VzOiAiKTsNCiAgICAgICAgICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKyl7DQogICAgICAgICAgICAgICAgICAgIHByb2Nlc3Nlc1tpXSA9IHNjYW4ubmV4dEludCgpOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkVudGVyIHRoZSBCdXJzdCB0aW1lIGZvciBoZSBwcm9jZXNzZXM6ICIpOw0KICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKXsNCiAgICAgICAgICAgICAgICAgICAgYnVyc3RfdGltZVtpXSA9IHNjYW4ubmV4dEludCgpOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBmY2ZzLmZpbmRhdmdUaW1lKHByb2Nlc3NlcywgbiwgYnVyc3RfdGltZSk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIGlmKGFsZ289PTIpew0KICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiRW50ZXIgdGhlIG51bWJlciBvZiBwcm9jZXNzZXM6ICIpOw0KICAgICAgICAgICAgICAgIGludCBuID0gc2Nhbi5uZXh0SW50KCk7DQogICAgICAgICAgICAgICAgaW50W10gcHJvY2Vzc2VzID0gbmV3IGludFtuXTsNCiAgICAgICAgICAgICAgICBpbnRbXSBidXJzdF90aW1lID0gbmV3IGludFtuXTsNCiAgICAgICAgICAgICAgICBpbnRbXSBhcnJfdGltZSA9IG5ldyBpbnRbbl07DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJFbnRlciB0aGUgcHJvY2Vzc2VzOiAiKTsNCiAgICAgICAgICAgICAgICBmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKXsNCiAgICAgICAgICAgICAgICAgICAgcHJvY2Vzc2VzW2ldID0gc2Nhbi5uZXh0SW50KCk7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiRW50ZXIgdGhlIEJ1cnN0IFRpbWUgb2YgdGhlIHByb2Nlc3NlczogIik7DQogICAgICAgICAgICAgICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKyl7DQogICAgICAgICAgICAgICAgICAgIGJ1cnN0X3RpbWVbaV0gPSBzY2FuLm5leHRJbnQoKTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJFbnRlciB0aGUgQXJyaXZhbCBUaW1lIG9mIHRoZSBwcm9jZXNzZXM6ICIpOw0KICAgICAgICAgICAgICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspew0KICAgICAgICAgICAgICAgICAgICBhcnJfdGltZVtpXSA9IHNjYW4ubmV4dEludCgpOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBQcm9jZXNzW10gcHJvYyA9IG5ldyBQcm9jZXNzW25dOw0KICAgICAgICAgICAgICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspew0KICAgICAgICAgICAgICAgICAgICBQcm9jZXNzIGluZF9wciA9IG5ldyBQcm9jZXNzKHByb2Nlc3Nlc1tpXSwgYnVyc3RfdGltZVtpXSwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcnJfdGltZVtpXSk7DQogICAgICAgICAgICAgICAgICAgIHByb2NbaV0gPSBpbmRfcHI7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIHNqZi5maW5kYXZnVGltZShwcm9jLCBwcm9jLmxlbmd0aCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIGlmKGFsZ289PTMpew0KICAgICAgICAgICAgICAgIGludCBxdWFudHVtOw0KICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiRW50ZXIgdGhlIG51bWJlciBvZiBwcm9jZXNzZXM6ICIpOw0KICAgICAgICAgICAgICAgIGludCBuID0gc2Nhbi5uZXh0SW50KCk7DQogICAgICAgICAgICAgICAgaW50W10gcHJvY2Vzc2VzID0gbmV3IGludFtuXTsNCi8vQnVyc3QgdGltZSBvZiBhbGwgcHJvY2Vzc2VzDQogICAgICAgICAgICAgICAgaW50W10gYnVyc3RfdGltZSA9IG5ldyBpbnRbbl07DQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJFbnRlciB0aGUgcHJvY2Vzc2VzOiAiKTsNCiAgICAgICAgICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKyl7DQogICAgICAgICAgICAgICAgICAgIHByb2Nlc3Nlc1tpXSA9IHNjYW4ubmV4dEludCgpOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkVudGVyIHRoZSBCdXJzdCB0aW1lIGZvciB0aGUgcHJvY2Vzc2VzOiAiKTsNCiAgICAgICAgICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKyl7DQogICAgICAgICAgICAgICAgICAgIGJ1cnN0X3RpbWVbaV0gPSBzY2FuLm5leHRJbnQoKTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgcXVhbnR1bSA9IHNjYW4ubmV4dEludCgpOw0KICAgICAgICAgICAgICAgIHJyLmZpbmRhdmdUaW1lKHByb2Nlc3NlcywgbiwgYnVyc3RfdGltZSwgcXVhbnR1bSk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIGlmKGFsZ289PTQpew0KICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiRW50ZXIgdGhlIG51bWJlciBvZiBwcm9jZXNzZXM6ICIpOw0KICAgICAgICAgICAgICAgIGludCBuID0gc2Nhbi5uZXh0SW50KCk7DQogICAgICAgICAgICAgICAgU3RyaW5nIHByb2Nlc3Nlc1tdID0gbmV3IFN0cmluZ1tuXTsNCiAgICAgICAgICAgICAgICBpbnQgYnVyc3RUaW1lW10gPSBuZXcgaW50W25dOw0KICAgICAgICAgICAgICAgIGludCBwcmlvcml0eVtdID0gbmV3IGludFtuXTsNCiAgICAgICAgICAgICAgICBpbnQgcCA9IDE7DQogICAgICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsNCiAgICAgICAgICAgICAgICAgICAgcHJvY2Vzc2VzW2ldID0gIlAiICsgcDsNCiAgICAgICAgICAgICAgICAgICAgcCsrOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50KCJFbnRlciB0aGUgQnVyc3QgdGltZSBmb3IgdGhlIHByb2Nlc3NlczogIik7DQogICAgICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsNCiAgICAgICAgICAgICAgICAgICAgYnVyc3RUaW1lW2ldID0gc2Nhbi5uZXh0SW50KCk7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnQoIkVudGVyIFByaW9yaXR5IGZvciB0aGUgcHJvY2Vzc2VzOiAiKTsNCiAgICAgICAgICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykgew0KICAgICAgICAgICAgICAgICAgICBwcmlvcml0eVtpXSA9IHNjYW4ubmV4dEludCgpOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBwci5wcmlvcml0eShwcm9jZXNzZXMsIG4sIGJ1cnN0VGltZSwgcHJpb3JpdHkpOw0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSBpZihhbGdvPT01KXsNCiAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkV4aXRpbmcgdGhlIGNvZGUuLi4iKTsNCiAgICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIGVsc2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BDSE9JQ0U6ICIpOw0KICAgICAgICAgICAgY2g9SW50ZWdlci5wYXJzZUludChvYmoucmVhZExpbmUoKSk7DQogICAgICAgICAgICBzd2l0Y2goY2gpDQogICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgY2FzZSAxOg0KICAgICAgICAgICAgICAgICAgICBpbnQgcHQ9MDsNCg0KICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oImVudGVyIG5vLiBvZiBmcmFtZXM6ICIpOw0KICAgICAgICAgICAgICAgICAgICBmPUludGVnZXIucGFyc2VJbnQob2JqLnJlYWRMaW5lKCkpOw0KICAgICAgICAgICAgICAgICAgICBpbnQgZnJhbWVbXT1uZXcgaW50W2ZdOw0KICAgICAgICAgICAgICAgICAgICBmb3IoaW50IGk9MDtpPGY7aSsrKQ0KICAgICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICAgICBmcmFtZVtpXT0tMTsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oImVudGVyIHRoZSBubyBvZiBwYWdlcyAiKTsNCiAgICAgICAgICAgICAgICAgICAgbj1JbnRlZ2VyLnBhcnNlSW50KG9iai5yZWFkTGluZSgpKTsNCiAgICAgICAgICAgICAgICAgICAgcGFnZXM9bmV3IGludFtuXTsNCiAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJlbnRlciB0aGUgcGFnZSBubyAiKTsNCiAgICAgICAgICAgICAgICAgICAgZm9yKGludCBqPTA7ajxuO2orKykNCiAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VzW2pdPUludGVnZXIucGFyc2VJbnQob2JqLnJlYWRMaW5lKCkpOw0KICAgICAgICAgICAgICAgICAgICBkb3sNCiAgICAgICAgICAgICAgICAgICAgICAgIGludCBwZz0wOw0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yKHBnPTA7cGc8bjtwZysrKQ0KICAgICAgICAgICAgICAgICAgICAgICAgew0KDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZT1wYWdlc1twZ107DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZmxhZz10cnVlOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcihpbnQgaj0wO2o8ZjtqKyspDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZihwYWdlPT1mcmFtZVtqXSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmxhZz1mYWxzZTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKGZsYWcpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcmFtZVtwdF09cGFnZTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHQrKzsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYocHQ9PWYpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdD0wOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50KCJmcmFtZSA6Iik7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcihpbnQgaj0wO2o8ZjtqKyspDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50KGZyYW1lW2pdKyIgICAiKTsNCg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGdmKys7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnQoImZyYW1lIDoiKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yKGludCBqPTA7ajxmO2orKykNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnQoZnJhbWVbal0rIiAgIik7DQoNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2huKys7DQogICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIH13aGlsZShjaG4hPW4pOw0KICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIlBhZ2UgZmF1bHQ6IitwZ2YpOw0KICAgICAgICAgICAgICAgICAgICBicmVhazsNCg0KICAgICAgICAgICAgICAgIGNhc2UgMjoNCiAgICAgICAgICAgICAgICAgICAgU2Nhbm5lciBpbiA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7DQogICAgICAgICAgICAgICAgICAgIGludCBmcmFtZXMgPSAwOw0KICAgICAgICAgICAgICAgICAgICBpbnQgcG9pbnRlciA9IDA7DQogICAgICAgICAgICAgICAgICAgIGludCBudW1GYXVsdCA9IDA7DQogICAgICAgICAgICAgICAgICAgIGludCByZWZfbGVuOw0KICAgICAgICAgICAgICAgICAgICBib29sZWFuIGlzRnVsbCA9IGZhbHNlOw0KICAgICAgICAgICAgICAgICAgICBpbnQgYnVmZmVyW107DQogICAgICAgICAgICAgICAgICAgIGJvb2xlYW4gaGl0W107DQogICAgICAgICAgICAgICAgICAgIGludCBmYXVsdFtdOw0KICAgICAgICAgICAgICAgICAgICBpbnQgcmVmZXJlbmNlW107DQogICAgICAgICAgICAgICAgICAgIGludCBtZW1fbGF5b3V0W11bXTsNCg0KICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIlBsZWFzZSBlbnRlciB0aGUgbnVtYmVyIG9mIGZyYW1lczogIik7DQogICAgICAgICAgICAgICAgICAgIGZyYW1lcyA9IEludGVnZXIucGFyc2VJbnQoaW4ubmV4dExpbmUoKSk7DQoNCiAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJQbGVhc2UgZW50ZXIgdGhlIGxlbmd0aCBvZiB0aGUgcmVmZXJlbmNlIHN0cmluZzogIik7DQogICAgICAgICAgICAgICAgICAgIHJlZl9sZW4gPSBJbnRlZ2VyLnBhcnNlSW50KGluLm5leHRMaW5lKCkpOw0KDQogICAgICAgICAgICAgICAgICAgIHJlZmVyZW5jZSA9IG5ldyBpbnRbcmVmX2xlbl07DQogICAgICAgICAgICAgICAgICAgIG1lbV9sYXlvdXQgPSBuZXcgaW50W3JlZl9sZW5dW2ZyYW1lc107DQogICAgICAgICAgICAgICAgICAgIGJ1ZmZlciA9IG5ldyBpbnRbZnJhbWVzXTsNCiAgICAgICAgICAgICAgICAgICAgaGl0ID0gbmV3IGJvb2xlYW5bcmVmX2xlbl07DQogICAgICAgICAgICAgICAgICAgIGZhdWx0ID0gbmV3IGludFtyZWZfbGVuXTsNCiAgICAgICAgICAgICAgICAgICAgZm9yKGludCBqID0gMDsgaiA8IGZyYW1lczsgaisrKQ0KICAgICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICAgICBidWZmZXJbal0gPSAtMTsNCiAgICAgICAgICAgICAgICAgICAgfQ0KDQogICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiUGxlYXNlIGVudGVyIHRoZSByZWZlcmVuY2Ugc3RyaW5nIChoaXQgRW50ZXIvUmV0dXJuIGFmdGVyIGVhY2ggbnVtYmVyIGluIHRoZSBzdHJpbmcpOiAiKTsNCiAgICAgICAgICAgICAgICAgICAgZm9yKGludCBpID0gMDsgaSA8IHJlZl9sZW47IGkrKykNCiAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgcmVmZXJlbmNlW2ldID0gSW50ZWdlci5wYXJzZUludChpbi5uZXh0TGluZSgpKTsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oKTsNCiAgICAgICAgICAgICAgICAgICAgZm9yKGludCBpID0gMDsgaSA8IHJlZl9sZW47IGkrKykNCiAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgaW50IHNlYXJjaCA9IC0xOw0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yKGludCBqID0gMDsgaiA8IGZyYW1lczsgaisrKQ0KICAgICAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKGJ1ZmZlcltqXSA9PSByZWZlcmVuY2VbaV0pDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWFyY2ggPSBqOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaXRbaV0gPSB0cnVlOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmYXVsdFtpXSA9IG51bUZhdWx0Ow0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICB9DQoNCiAgICAgICAgICAgICAgICAgICAgICAgIGlmKHNlYXJjaCA9PSAtMSkNCiAgICAgICAgICAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZihpc0Z1bGwpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgaW5kZXhbXSA9IG5ldyBpbnRbZnJhbWVzXTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbGVhbiBpbmRleF9mbGFnW10gPSBuZXcgYm9vbGVhbltmcmFtZXNdOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IoaW50IGogPSBpICsgMTsgaiA8IHJlZl9sZW47IGorKykNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yKGludCBrID0gMDsgayA8IGZyYW1lczsgaysrKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKChyZWZlcmVuY2Vbal0gPT0gYnVmZmVyW2tdKSAmJiAoaW5kZXhfZmxhZ1trXSA9PSBmYWxzZSkpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRleFtrXSA9IGo7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4X2ZsYWdba10gPSB0cnVlOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IG1heCA9IGluZGV4WzBdOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludGVyID0gMDsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYobWF4ID09IDApDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1heCA9IDIwMDsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcihpbnQgaiA9IDA7IGogPCBmcmFtZXM7IGorKykNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYoaW5kZXhbal0gPT0gMCkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRleFtqXSA9IDIwMDsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYoaW5kZXhbal0gPiBtYXgpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4ID0gaW5kZXhbal07DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRlciA9IGo7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyW3BvaW50ZXJdID0gcmVmZXJlbmNlW2ldOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIG51bUZhdWx0Kys7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZmF1bHRbaV0gPSBudW1GYXVsdDsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZighaXNGdWxsKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRlcisrOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZihwb2ludGVyID09IGZyYW1lcykNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRlciA9IDA7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0Z1bGwgPSB0cnVlOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgfQ0KDQogICAgICAgICAgICAgICAgICAgICAgICBmb3IoaW50IGogPSAwOyBqIDwgZnJhbWVzOyBqKyspDQogICAgICAgICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVtX2xheW91dFtpXVtqXSA9IGJ1ZmZlcltqXTsNCiAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgfQ0KDQogICAgICAgICAgICAgICAgICAgIGZvcihpbnQgaSA9IDA7IGkgPCByZWZfbGVuOyBpKyspDQogICAgICAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnQocmVmZXJlbmNlW2ldICsgIjogTWVtb3J5IGlzOiAiKTsNCiAgICAgICAgICAgICAgICAgICAgICAgIGZvcihpbnQgaiA9IDA7IGogPCBmcmFtZXM7IGorKykNCiAgICAgICAgICAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobWVtX2xheW91dFtpXVtqXSA9PSAtMSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRmKCIlM3MgIiwgIioiKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRmKCIlM2QgIiwgbWVtX2xheW91dFtpXVtqXSk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludCgiOiAiKTsNCiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoaXRbaV0pIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50KCJIaXQiKTsNCiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZQ0KICAgICAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnQoIlBhZ2UgRmF1bHQiKTsNCiAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnQoIjogKE51bWJlciBvZiBQYWdlIEZhdWx0czogIiArIGZhdWx0W2ldICsgIikiKTsNCiAgICAgICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigpOw0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiVG90YWwgTnVtYmVyIG9mIFBhZ2UgRmF1bHRzOiAiICsgbnVtRmF1bHQpOw0KICAgICAgICAgICAgICAgICAgICBicmVhazsNCg0KICAgICAgICAgICAgICAgIGNhc2UgMzoNCiAgICAgICAgICAgICAgICAgICAgaW50IGs9MDsNCiAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJlbnRlciBuby4gb2YgZnJhbWVzOiAiKTsNCiAgICAgICAgICAgICAgICAgICAgZj1JbnRlZ2VyLnBhcnNlSW50KG9iai5yZWFkTGluZSgpKTsNCiAgICAgICAgICAgICAgICAgICAgaW50IGZyYW1lMVtdPW5ldyBpbnRbZl07DQogICAgICAgICAgICAgICAgICAgIGludCBhW109bmV3IGludFtmXTsNCiAgICAgICAgICAgICAgICAgICAgaW50IGJbXT1uZXcgaW50W2ZdOw0KICAgICAgICAgICAgICAgICAgICBmb3IoaW50IGk9MDtpPGY7aSsrKQ0KICAgICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICAgICBmcmFtZTFbaV09LTE7DQogICAgICAgICAgICAgICAgICAgICAgICBhW2ldPS0xOw0KICAgICAgICAgICAgICAgICAgICAgICAgYltpXT0tMTsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oImVudGVyIHRoZSBubyBvZiBwYWdlcyAiKTsNCiAgICAgICAgICAgICAgICAgICAgbj1JbnRlZ2VyLnBhcnNlSW50KG9iai5yZWFkTGluZSgpKTsNCiAgICAgICAgICAgICAgICAgICAgcGFnZXM9bmV3IGludFtuXTsNCiAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJlbnRlciB0aGUgcGFnZSBubyAiKTsNCiAgICAgICAgICAgICAgICAgICAgZm9yKGludCBqPTA7ajxuO2orKykNCiAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VzW2pdPUludGVnZXIucGFyc2VJbnQob2JqLnJlYWRMaW5lKCkpOw0KICAgICAgICAgICAgICAgICAgICBkb3sNCiAgICAgICAgICAgICAgICAgICAgICAgIGludCBwZz0wOw0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yKHBnPTA7cGc8bjtwZysrKQ0KICAgICAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2U9cGFnZXNbcGddOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZsYWc9dHJ1ZTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IoaW50IGo9MDtqPGY7aisrKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYocGFnZT09ZnJhbWUxW2pdKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7ZmxhZz1mYWxzZTsgYnJlYWs7fQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcihpbnQgaj0wO2o8ZiAmJiBmbGFnO2orKykNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKGZyYW1lMVtqXT09YVtmLTFdKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7az1qOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7fQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKGZsYWcpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcmFtZTFba109cGFnZTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJmcmFtZSA6IiApOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IoaW50IGo9MDtqPGY7aisrKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludChmcmFtZTFbal0rIiAgIik7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBnZisrOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJmcmFtZSA6IiApOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IoaW50IGo9MDtqPGY7aisrKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludChmcmFtZTFbal0rIiAgIik7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgcD0xOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJbMF09cGFnZTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IoaW50IGo9MDtqPGEubGVuZ3RoO2orKykNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKHBhZ2UhPWFbal0gJiYgcDxmKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiW3BdPWFbal07DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwKys7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yKGludCBqPTA7ajxmO2orKykNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFbal09YltqXTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2huKys7DQoNCiAgICAgICAgICAgICAgICAgICAgICAgIH0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VudCAuLi4iKTsNCiAgICAgICAgICAgIHNvY2tldCA9IHNlcnZlci5hY2NlcHQoKTsNCiAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiQ2xpZW50IGFjY2VwdGVkIik7DQovLyB0YWtlcyBpbnB1dCBmcm9tIHRoZSBjbGllbnQgc29ja2V0DQogICAgICAgICAgICBpbiA9IG5ldyBEYXRhSW5wdXRTdHJlYW0oDQogICAgICAgICAgICAgICAgICAgIG5ldyBCdWZmZXJlZElucHV0U3RyZWFtKHNvY2tldC5nZXRJbnB1dFN0cmVhbSgpKSk7DQogICAgICAgICAgICBTdHJpbmcgbGluZSA9ICIiOw0KLy8gcmVhZHMgbWVzc2FnZSBmcm9tIGNsaWVudCB1bnRpbCAiT3ZlciIgaXMgc2VudA0KICAgICAgICAgICAgd2hpbGUgKCFsaW5lLmVxdWFscygiT3ZlciIpKQ0KICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgIHRyeQ0KICAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgICAgbGluZSA9IGluLnJlYWRVVEYoKTsNCiAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKGxpbmUpOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBjYXRjaChJT0V4Y2VwdGlvbiBpKQ0KICAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKGkpOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiQ2xvc2luZyBjb25uZWN0aW9uIik7DQovLyBjbG9zZSBjb25uZWN0aW9uDQogICAgICAgICAgICBzb2NrZXQuY2xvc2UoKTsNCiAgICAgICAgICAgIGluLmNsb3NlKCk7DQogICAgICAgIH0NCiAgICAgICAgY2F0Y2goSU9FeGNlcHRpb24gaSkNCiAgICAgICAgew0KICAgICAgICAgICAgU3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NvY2tldC5nZXRPdXRwdXRTdHJlYW0oKSk7DQogICAgICAgIH0NCiAgICAgICAgY2F0Y2ggKFVua25vd25Ib3N0RXhjZXB0aW9uIHUpDQogICAgICAgIHsNCiAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbih1KTsNCiAgICAgICAgfSBjYXRjaCAoSU9FeGNlcHRpb24gZSkgew0KICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKGUpOw0KICAgICAgICB9DQogICAgICAgIC8vIHN0cmluZyB0byByZWFkIG1lc3NhZ2UgZnJvbSBpbnB1dA0KICAgICAgICBTdHJpbmcgbGluZSA9ICIiOw0KICAgICAgICAvLyBrZWVwIHJlYWRpbmcgdW50aWwgIk92ZXIiIGlzIGlucHV0DQogICAgICAgIHdoaWxlICghbGluZS5lcXVhbHMoIk92ZXIiKSl7DQogICAgICAgICAgICB0cnkgew0KICAgICAgICAgICAgICAgIGxpbmUgPSBpbnB1dC5yZWFkTGluZSgpOw0KICAgICAgICAgICAgICAgIG91dC53cml0ZVVURihsaW5lKTsNCiAgICAgICAgICAgIH0gY2F0Y2ggKElPRXhjZXB0aW9uIGUpIHsNCiAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oZSk7DQogICAgICAgICAgICB9DQogICAgICAgIH0NCg0KICAgICAgICAvL2Nsb3NlIHRoZSBjb25uZWN0aW9uDQogICAgICAgIHRyeSB7DQogICAgICAgICAgICBpbnB1dC5jbG9zZSgpOw0KICAgICAgICAgICAgb3V0LmNsb3NlKCk7DQogICAgICAgICAgICBzb2NrZXQuY2xvc2UoKTsNCiAgICAgICAgfSBjYXRjaCAoSU9FeGNlcHRpb24gZSkgew0KICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKGUpOw0KICAgICAgICB9DQoNCiAgICB9DQoNCiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmcgYXJnc1tdKXsNCiAgICAgICAgQ2xpZW50IGNsaWVudCA9IG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gIHByaW50ZigiXG5BbGl2ZS0tPiIpOw0KICAgZm9yKGk9MTtpPD1uO2krKykNCiAgICAgIHByaW50ZigiXHQgJWQiLGxpc3RbaV0pOw0KICAgcHJpbnRmKCJcbmNvb3JkaW5hdG9yIGlzOjolZCIsY2RyKTsNCn0NCnZvaWQgcmluZygpDQp7DQogICBpbnQgbXNnWzIwXSxyaW5nX24sayxpOw0KICAgaW50IGNoLGNyYXNoLGFjdGl2YXRlLGdpZCxmbGFnLHN1YmNkcjsNCiAgIGRvDQogICB7DQogICAgICAgICBwcmludGYoIlxuMS5DcmFzaFxuMi5BY3RpdmF0ZVxuMy5EaXNwbGF5XG40LkV4aXRcbkVudGVyIFlvdSBjaG9pY2U6OiIpOw0KICAgICAgICAgc2NhbmYoIiVkIiwmY2gpOw0KICAgICAgICAgc3dpdGNoKGNoKQ0KICAgICAgICAgew0KICAgICAgICAgICAgY2FzZSAxOg0KICAgICAgICAgICAgICAgcHJpbnRmKCJcbkVudGVyIFByb2Nlc3Mgbm8uIHRvIENyYXNoOjoiKTsNCiAgICAgICAgICAgICAgIHNjYW5mKCIlZCIsJmNyYXNoKTsNCiAgICAgICAgICAgICAgIGlmKGxpc3RbY3Jhc2hdKQ0KICAgICAgICAgICAgICAgICAgbGlzdFtjcmFzaF09MDsNCiAgICAgICAgICAgICAgIGVsc2UNCiAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgIHByaW50ZigiXG5Qcm9jZXNzIGlzIGFscmVhYWR5IGRlYWQhISIpOw0KICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICBkbw0KICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgcHJpbnRmKCJcbkVudGVyIGVsZWN0aW9uIGdlbmVyYXRvciBpZDo6Iik7DQogICAgICAgICAgICAgICAgICBzY2FuZigiJWQiLCZnaWQpOw0KICAgICAgICAgICAgICAgICAgaWYoZ2lkPT1jZHIpDQogICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICBwcmludGYoIlxuZW50ZXIgYSB2YWxpZCBnZW5lcmF0b3IgaWQ6OiIpOw0KICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgfXdoaWxlKGdpZD09Y3Jhc2gpOw0KICAgICAgICAgICAgICAgZmxhZz0wOw0KICAgICAgICAgICAgICAgaz0xOw0KICAgICAgICAgICAgICAgaWYoY3Jhc2g9PWNkcikNCiAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgIG1zZ1trKytdPWdpZDsNCiAgICAgICAgICAgICAgICAgIGZvcihpPShnaWQrMSklbjtpIT1naWQ7aT0oaSsxKSVuKQ0KICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgaWYobGlzdFtpXSkNCiAgICAgICAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ZigiXG5tZXNzYWdlIGlzIHNlbnQgdG8gJWQgayA9JWQiLGksayk7DQogICAgICAgICAgICAgICAgICAgICAgICBtc2dbaysrXT1pOw0KLy8gICAgICAgICAgICAgICAgICAgICAgcHJpbnRmKCJSZXNwb25zZSBpcyBzZW50IGZyb20gJWQgdG8gJWQiLGksZ2lkKTsNCg0KICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgc3ViY2RyPTA7DQogICAgICAgICAgICAgICAgICBmb3IoaT0xO2k8aztpKyspDQogICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICBwcmludGYoIm1zZzo6JWRcbiIsbXNnW2ldKTsNCiAgICAgICAgICAgICAgICAgICAgIGlmKHN1YmNkcjxtc2dbaV0pDQogICAgICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICAgICBzdWJjZHI9bXNnW2ldOw0KICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgY2RyPXN1YmNkcjsNCiAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgIGRpc3BsYXkoKTsNCiAgICAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICAgICAgY2FzZSAyOg0KICAgICAgICAgICAgICAgLy9hY3RpdmF0ZQ0KICAgICAgICAgICAgICAgcHJpbnRmKCJcbkVudGVyIFByb2Nlc3Mgbm8uIHRvIEFjdGl2YXRlZDo6Iik7DQogICAgICAgICAgICAgICBzY2FuZigiJWQiLCZhY3RpdmF0ZSk7DQogICAgICAgICAgICAgICBpZighbGlzdFthY3RpdmF0ZV0pDQogICAgICAgICAgICAgICAgICBsaXN0W2FjdGl2YXRlXT0xOw0KICAgICAgICAgICAgICAgICAgZWxzZQ0KICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgcHJpbnRmKCJcblByb2Nlc3MgaXMgYWxyZWFhZHkgYWxpdmUhISIpOw0KICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICB9ICAgICAgICAgICANCiAgICAgICAgICAgICAgIC8vDQogICAgICAgICAgICAgICBpZihhY3RpdmF0ZT09bikNCiAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgIGNkcj1uOw0KICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICBmb3IoaT1hY3RpdmF0ZSsxO2k8PW47aSsrKQ0KICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgcHJpbnRmKCJcbm1lc3NhZ2UgaXMgc2VudCBmcm9tICVkIHRvICVkIixhY3RpdmF0ZSxpKTsNCiAgICAgICAgICAgICAgICAgIGlmKGxpc3RbaV0pDQogICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICBzdWJjZHI9aTsNCiAgICAgICAgICAgICAgICAgICAgIHByaW50ZigiUmVzcG9uc2UgaXMgc2VudCBmcm9tICVkIHRvICVkIixpLGFjdGl2YXRlKTsNCiAgICAgICAgICAgICAgICAgICAgIGZsYWc9MTsNCiAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgIGlmKGZsYWc9PTEpDQogICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICBjZHI9c3ViY2RyOw0KICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgZWxzZQ0KICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgY2RyPWFjdGl2YXRlOw0KICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgDQogICAgICAgICAgICAgICANCiAgICAgICAgICAgIGRpc3BsYXkoKTsNCiAgICAgICAgICAgICAgIC8vDQogICAgICAgICAgICBicmVhazsNCiAgICAgICAgIGNhc2UgMzoNCiAgICAgICAgICAgIGRpc3BsYXkoKTsNCiAgICAgICAgIGJyZWFrOw0KICAgICAgICAgY2FzZSA0Og0KICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICB9DQogICB9d2hpbGUoY2ghPTQpOw0KICAgDQp9DQp2b2lkIGJ1bGx5KCkNCnsNCiAgIGludCBjaCxjcmFzaCxhY3RpdmF0ZSxpLGdpZCxmbGFnLHN1YmNkcjsNCiAgIGRvDQogICB7DQogICAgICAgICBwcmludGYoIlxuMS5DcmFzaFxuMi5BY3RpdmF0ZVxuMy5EaXNwbGF5XG40LkV4aXRcbkVudGVyIFlvdSBjaG9pY2U6OiIpOw0KICAgICAgICAgc2NhbmYoIiVkIiwmY2gpOw0KICAgICAgICAgc3dpdGNoKGNoKQ0KICAgICAgICAgew0KICAgICAgICAgICAgY2FzZSAxOg0KICAgICAgICAgICAgICAgcHJpbnRmKCJcbkVudGVyIFByb2Nlc3Mgbm8uIHRvIENyYXNoOjoiKTsNCiAgICAgICAgICAgICAgIHNjYW5mKCIlZCIsJmNyYXNoKTsNCiAgICAgICAgICAgICAgIGlmKGxpc3RbY3Jhc2hdKQ0KICAgICAgICAgICAgICAgICAgbGlzdFtjcmFzaF09MDsNCiAgICAgICAgICAgICAgIGVsc2UNCiAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgIHByaW50ZigiXG5Qcm9jZXNzIGlzIGFscmVhYWR5IGRlYWQhISIpOw0KICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICBkbw0KICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgcHJpbnRmKCJcbkVudGVyIGVsZWN0aW9uIGdlbmVyYXRvciBpZDo6Iik7DQogICAgICAgICAgICAgICAgICBzY2FuZigiJWQiLCZnaWQpOw0KICAgICAgICAgICAgICAgICAgaWYoZ2lkPT1jZHIpDQogICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICBwcmludGYoIlxuZW50ZXIgYSB2YWxpZCBnZW5lcmF0b3IgaWQ6OiIpOw0KICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgfXdoaWxlKGdpZD09Y3Jhc2gpOw0KICAgICAgICAgICAgICAgZmxhZz0wOw0KICAgICAgICAgICAgICAgaWYoY3Jhc2g9PWNkcikNCiAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgIGZvcihpPWdpZCsxO2k8PW47aSsrKQ0KICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgcHJpbnRmKCJcbm1lc3NhZ2UgaXMgc2VudCBmcm9tICVkIHRvICVkIixnaWQsaSk7DQogICAgICAgICAgICAgICAgICAgICBpZihsaXN0W2ldKQ0KICAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgc3ViY2RyPWk7DQogICAgICAgICAgICAgICAgICAgICAgICBwcmludGYoIlJlc3BvbnNlIGlzIHNlbnQgZnJvbSAlZCB0byAlZCIsaSxnaWQpOw0KICAgICAgICAgICAgICAgICAgICAgICAgZmxhZz0xOw0KICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgaWYoZmxhZz09MSkNCiAgICAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgICAgIGNkcj1zdWJjZHI7DQogICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICBlbHNlDQogICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICBjZHI9Z2lkOw0KICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgZGlzcGxheSgpOw0KICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICBjYXNlIDI6DQogICAgICAgICAgICAgICAvL2FjdGl2YXRlDQogICAgICAgICAgICAgICBwcmludGYoIlxuRW50ZXIgUHJvY2VzcyBuby4gdG8gQWN0aXZhdGVkOjoiKTsNCiAgICAgICAgICAgICAgIHNjYW5mKCIlZCIsJmFjdGl2YXRlKTsNCiAgICAgICAgICAgICAgIGlmKCFsaXN0W2FjdGl2YXRlXSkNCiAgICAgICAgICAgICAgICAgIGxpc3RbYWN0aXZhdGVdPTE7DQogICAgICAgICAgICAgICBlbHNlDQogICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICBwcmludGYoIlxuUHJvY2VzcyBpcyBhbHJlYWFkeSBhbGl2ZSEhIik7DQogICAgICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgICAgICAgIH0gICAgICAgICAgIA0KICAgICAgICAgICAgICAgLy8NCiAgICAgICAgICAgICAgIGlmKGFjdGl2YXRlPT1uKQ0KICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgY2RyPW47DQogICAgICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgIGZvcihpPWFjdGl2YXRlKzE7aTw9bjtpKyspDQogICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICBwcmludGYoIlxubWVzc2FnZSBpcyBzZW50IGZyb20gJWQgdG8gJWQiLGFjdGl2YXRlLGkpOw0KICAgICAgICAgICAgICAgICAgaWYobGlzdFtpXSkNCiAgICAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgICAgIHN1YmNkcj1pOw0KICAgICAgICAgICAgICAgICAgICAgcHJpbnRmKCJSZXNwb25zZSBpcyBzZW50IGZyb20gJWQgdG8gJWQiLGksYWN0aXZhdGUpOw0KICAgICAgICAgICAgICAgICAgICAgZmxhZz0xOw0KICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgaWYoZmxhZz09MSkNCiAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgIGNkcj1zdWJjZHI7DQogICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICBlbHNlDQogICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICBjZHI9YWN0aXZhdGU7DQogICAgICAgICAgICAgICB9DQogICAgICAgICAgICANCiAgICAgICAgICAgICAgIA0KICAgICAgICAgICAgZGlzcGxheSgpOw0KICAgICAgICAgICAgICAgLy8NCiAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICAgY2FzZSAzOg0KICAgICAgICAgICAgZGlzcGxheSgpOw0KICAgICAgICAgYnJlYWs7DQogICAgICAgICBjYXNlIDQ6DQogICAgICAgICAgICBicmVhazsNCiAgICAgICAgIH0NCiAgIH13aGlsZShjaCE9NCk7DQp9DQppbnQgbWFpbigpDQp7DQogICBpbnQgaSxqOw0KICAgcHJpbnRmKCJcbkVudGVyIG5vLiBvZiBwcm9jZXNzOjoiKTsNCiAgIHNjYW5mKCIlZCIsJm4pOw0KICAgZm9yKGk9MTtpPD1uO2krKykNCiAgIHsNCiAgICAgIHByaW50ZigiXG5FbnRlciBQcm9jZXNzICVkIGlzIEFsaXZlIG9yIG5vdCgwLzEpOjoiLGkpOw0KICAgICAgc2NhbmYoIiVkIiwmbGlzdFtpXSk7DQogICAgICBpZihsa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CiAgICAgICAgICAgIGlmIChtW2ldW2pdID09IDEpIHsNCiAgICAgICAgICAgICAgICBwMltqXSA9IG1heDEocDJbal0sIHAxW2ldICsgMSk7DQogICAgICAgICAgICAgICAgZm9yIChrID0gaiArIDE7IGsgPCBlMjsgaysrKQ0KICAgICAgICAgICAgICAgICAgICBwMltrXSA9IHAyW2sgLSAxXSArIDE7DQogICAgICAgICAgICB9DQogDQogICAgICAgICAgICAvLyBDaGFuZ2UgdGhlIHRpbWVzdGFtcCBpZiB0aGUNCiAgICAgICAgICAgIC8vIG1lc3NhZ2UgaXMgcmVjZWl2ZWQNCiAgICAgICAgICAgIGlmIChtW2ldW2pdID09IC0xKSB7DQogICAgICAgICAgICAgICAgcDFbaV0gPSBtYXgxKHAxW2ldLCBwMltqXSArIDEpOw0KICAgICAgICAgICAgICAgIGZvciAoayA9IGkgKyAxOyBrIDwgZTE7IGsrKykNCiAgICAgICAgICAgICAgICAgICAgcDFba10gPSBwMVtrIC0gMV0gKyAxOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9DQogICAgfQ0KIA0KICAgIC8vIEZ1bmN0aW9uIENhbGwNCiAgICBkaXNwbGF5KGUxLCBlMiwgcDEsIHAyKTsNCn0NCiANCi8vIERyaXZlciBDb2RlDQppbnQgbWFpbigpDQp7DQogICAgaW50IGUxID0gNSwgZTIgPSAzLCBtWzVdWzNdOw0KIA0KICAgIC8vIG1lc3NhZ2UgaXMgc2VudCBhbmQgcmVjZWl2ZWQNCiAgICAvLyBiZXR3ZWVuIHR3byBwcm9jZXNzDQogDQogICAgLypkZXBbaV1bal0gPSAxLCBpZiBtZXNzYWdlIGlzIHNlbnQNCiAgICAgICAgICAgICAgICAgICBmcm9tIGVpIHRvIGVqDQogICAgZGVwW2ldW2pdID0gLTEsIGlmIG1lc3NhZ2UgaXMgcmVjZWl2ZWQNCiAgICAgICAgICAgICAgICAgICAgYnkgZWkgZnJvbSBlag0KICAgIGRlcFtpXVtqXSA9IDAsIG90aGVyd2lzZSovDQogICAgbVswXVswXSA9IDA7DQogICAgbVswXVsxXSA9IDA7DQogICAgbVswXVsyXSA9IDA7DQogICAgbVsxXVswXSA9IDA7DQogICAgbVsxXVsxXSA9IDA7DQogICAgbVsxXVsyXSA9IDE7DQogICAgbVsyXVswXSA9IDA7DQogICAgbVsyXVsxXSA9IDA7DQogICAgbVsyXVsyXSA9IDA7DQogICAgbVszXVswXSA9IDA7DQogICAgbVszXVsxXSA9IDA7DQogICAgbVszXVsyXSA9IDA7DQogICAgbVs0XVswXSA9IDA7DQogICAgbVs0XVsxXSA9IC0xOw0KICAgIG1bNF1bMl0gPSAwOw0KIA0KICAgIC8vIEZ1bmN0aW9uIENhbGwNCiAgICBsYW1wb3J0TG9naWNhbENsb2NrKGUxLCBlMiwgbSk7DQogDQogICAgcmV0dXJuIDA7DQp9DQoNCk91dHB1dDoNCiAgICAgICAgZTIxICAgIGUyMiAgICBlMjMNCiBlMTEgICAgMCAgICAwICAgIDAgICAgDQogZTEyICAgIDAgICAgMCAgICAxICAgIA0KIGUxMyAgICAwICAgIDAgICAgMCAgICANCiBlMTQgICAgMCAgICAwICAgIDAgICAgDQogZTE1ICAgIDAgICAgLTEgICAgMCAgICANClRoZSB0aW1lIHN0YW1wcyBvZiBldmVudHMgaW4gUDE6DQoxIDIgMyA0IDUgDQpUaGUgdGltZSBzdGFtcHMgb2YgZXZlbnRzIGluIFAyOg0KMSAyIDMNCg==