Last active
April 2, 2021 23:59
-
-
Save cornhundred/6acefdb61cf4558d33c45930e3b3deec to your computer and use it in GitHub Desktop.
Clustergrammer2_on_Colab.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "Clustergrammer2_on_Colab.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"authorship_tag": "ABX9TyNpJly/Xc2aF2LT/zpPDIP+", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/cornhundred/6acefdb61cf4558d33c45930e3b3deec/clustergrammer2_on_colab.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "_QwF6ufqmyLP", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"outputId": "ecd00de9-00dd-49fe-89fe-3f644541bda9" | |
}, | |
"source": [ | |
"!pip install -q clustergrammer2" | |
], | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"\u001b[K |████████████████████████████████| 19.1MB 1.5MB/s \n", | |
"\u001b[?25h" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "nAaQJsF6BVny", | |
"outputId": "12b66012-1b53-4e62-e699-d59fec906687" | |
}, | |
"source": [ | |
"!curl https://raw.githubusercontent.com/ismms-himc/clustergrammer-gl/master/clustergrammer-gl.js > clustergrammer-gl.js" | |
], | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
" % Total % Received % Xferd Average Speed Time Time Time Current\n", | |
" Dload Upload Total Spent Left Speed\n", | |
"100 2615k 100 2615k 0 0 4935k 0 --:--:-- --:--:-- --:--:-- 4935k\n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "gUO8d_uqBL6C" | |
}, | |
"source": [ | |
"import numpy as np\n", | |
"import pandas as pd\n", | |
"from clustergrammer2 import net\n", | |
"\n", | |
"from google.colab.html import create_resource\n", | |
"clustergrammer_resource = create_resource(filepath='./clustergrammer-gl.js')\n", | |
"clustergrammer_url = clustergrammer_resource.url" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "mrKdbN5BBXEy" | |
}, | |
"source": [ | |
"# generate random matrix\n", | |
"num_rows = 50\n", | |
"num_cols = 50\n", | |
"np.random.seed(seed=100)\n", | |
"mat = np.random.rand(num_rows, num_cols)\n", | |
"\n", | |
"# make row and col labels\n", | |
"rows = range(num_rows)\n", | |
"cols = range(num_cols)\n", | |
"rows = [str(i) for i in rows]\n", | |
"cols = [str(i) for i in cols]\n", | |
"\n", | |
"# make dataframe \n", | |
"df = pd.DataFrame(data=mat, columns=cols, index=rows)" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "yYjzmQd_BYAM" | |
}, | |
"source": [ | |
"net.load_df(df)\n", | |
"net.cluster()\n", | |
"network = net.export_viz_to_widget()\n", | |
"\n", | |
"network_resource = create_resource(content=network)\n", | |
"network_url = network_resource.url" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"colab": { | |
"resources": { | |
"http://localhost:16231/71728877-7846-4cab-8f64-2e655b193a3c": { |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Mjc2NzczNzI3MTE3MDE5MywgNDguMF0sIFs3My4wLCA5Ny4wLCAwLjI4NTY1OTY3NDgwMTYzNTUsIDUwLjBdXX0sICJ2aWV3cyI6IFtdfQ==", | |
"ok": true, | |
"headers": [ | |
[ | |
"content-type", | |
"text/html; charset=UTF-8" | |
] | |
], | |
"status": 200, | |
"status_text": "" | |
}, | |
"http://localhost:16231/1f9931c0-6e1b-4259-9bc5-51ae884d96dc": { | |
"data": "dmFyIENHTSA9Ci8qKioqKiovIChmdW5jdGlvbihtb2R1bGVzKSB7IC8vIHdlYnBhY2tCb290c3RyYXAKLyoqKioqKi8gCS8vIFRoZSBtb2R1bGUgY2FjaGUKLyoqKioqKi8gCXZhciBpbnN0YWxsZWRNb2R1bGVzID0ge307Ci8qKioqKiovCi8qKioqKiovIAkvLyBUaGUgcmVxdWlyZSBmdW5jdGlvbgovKioqKioqLyAJZnVuY3Rpb24gX193ZWJwYWNrX3JlcXVpcmVfXyhtb2R1bGVJZCkgewovKioqKioqLwovKioqKioqLyAJCS8vIENoZWNrIGlmIG1vZHVsZSBpcyBpbiBjYWNoZQovKioqKioqLyAJCWlmKGluc3RhbGxlZE1vZHVsZXNbbW9kdWxlSWRdKSB7Ci8qKioqKiovIAkJCXJldHVybiBpbnN0YWxsZWRNb2R1bGVzW21vZHVsZUlkXS5leHBvcnRzOwovKioqKioqLyAJCX0KLyoqKioqKi8gCQkvLyBDcmVhdGUgYSBuZXcgbW9kdWxlIChhbmQgcHV0IGl0IGludG8gdGhlIGNhY2hlKQovKioqKioqLyAJCXZhciBtb2R1bGUgPSBpbnN0YWxsZWRNb2R1bGVzW21vZHVsZUlkXSA9IHsKLyoqKioqKi8gCQkJaTogbW9kdWxlSWQsCi8qKioqKiovIAkJCWw6IGZhbHNlLAovKioqKioqLyAJCQlleHBvcnRzOiB7fQovKioqKioqLyAJCX07Ci8qKioqKiovCi8qKioqKiovIAkJLy8gRXhlY3V0ZSB0aGUgbW9kdWxlIGZ1bmN0aW9uC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AJfTsKLyoqKioqKi8KLyoqKioqKi8gCS8vIE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbAovKioqKioqLyAJX193ZWJwYWNrX3JlcXVpcmVfXy5vID0gZnVuY3Rpb24ob2JqZWN0LCBwcm9wZXJ0eSkgeyByZXR1cm4gT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKG9iamVjdCwgcHJvcGVydHkpOyB9OwovKioqKioqLwovKioqKioqLyAJLy8gX193ZWJwYWNrX3B1YmxpY19wYXRoX18KLyoqKioqKi8gCV9fd2VicGFja19yZXF1aXJlX18ucCA9ICIiOwovKioqKioqLwovKioqKioqLwovKioqKioqLyAJLy8gTG9hZCBlbnRyeSBtb2R1bGUgYW5kIHJldHVybiBleHBvcnRzCi8qKioqKiovIAlyZXR1cm4gX193ZWJwYWNrX3JlcXVpcmVfXyhfX3dlYnBhY2tfcmVxdWlyZV9fLnMgPSAiLi9zcmMvbWFpbi5qcyIpOwovKioqKioqLyB9KQovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKioqKioqLyAoewoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2F4aW9zL2luZGV4LmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvYXhpb3MvaW5kZXguanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgbm8gc3RhdGljIGV4cG9ydHMgZm91bmQgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgZXhwb3J0cywgX193ZWJwYWNrX3JlcXVpcmVfXykgewoKbW9kdWxlLmV4cG9ydHMgPSBfX3dlYnBhY2tfcmVxdWlyZV9fKC8qISAuL2xpYi9heGlvcyAqLyAiLi9ub2RlX21vZHVsZXMvYXhpb3M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biBzb3VyY2UoKSB7CiAgdmFyIGNhbmNlbDsKICB2YXIgdG9rZW4gPSBuZXcgQ2FuY2VsVG9rZW4oZnVuY3Rpb24gZXhlY3V0b3IoYykgewogICAgY2FuY2VsID0gYzsKICB9KTsKICByZXR1cm4gewogICAgdG9rZW46IHRva2VuLAogICAgY2FuY2VsOiBjYW5jZWwKICB9Owp9OwoKbW9kdWxlLmV4cG9ydHMgPSBDYW5jZWxUb2tlbjsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9heGlvcy9saWIvY2FuY2VsL2lzQ2FuY2VsLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9heGlvcy9saWIvY2FuY2VsL2lzQ2FuY2VsLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgbm8gc3RhdGljIGV4cG9ydHMgZm91bmQgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgZXhwb3J0cywgX193ZWJwYWNrX3JlcXVpcmVfXykgewoKInVzZSBzdHJpY3QiOwoKCm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gaXNDYW5jZWwodmFsdWUpIHsKICByZXR1cm4gISEodmFsdWUgJiYgdmFsdWUuX19DQU5DRUxfXyk7Cn07CgoKLyoqKi8gfSksCgovKioqLyAiLi9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2NvcmUvQXhpb3MuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9heGlvcy9saWIvY29yZS9BeGlvcy5qcyAqKiohCiAgXCoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBubyBzdGF0aWMgZXhwb3J0cyBmb3VuZCAq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2UoY29uZmlnIHx8IHt9LCB7CiAgICAgIG1ldGhvZDogbWV0aG9kLAogICAgICB1cmw6IHVybAogICAgfSkpOwogIH07Cn0pOwoKdXRpbHMuZm9yRWFjaChbJ3Bvc3QnLCAncHV0JywgJ3BhdGNoJ10sIGZ1bmN0aW9uIGZvckVhY2hNZXRob2RXaXRoRGF0YShtZXRob2QpIHsKICAvKmVzbGludCBmdW5jLW5hbWVzOjAqLwogIEF4aW9zLnByb3RvdHlwZVttZXRob2RdID0gZnVuY3Rpb24odXJsLCBkYXRhLCBjb25maWcpIHsKICAgIHJldHVybiB0aGlzLnJlcXVlc3QodXRpbHMubWVyZ2UoY29uZmlnIHx8IHt9LCB7CiAgICAgIG1ldGhvZDogbWV0aG9kLAogICAgICB1cmw6IHVybCwKICAgICAgZGF0YTogZGF0YQogICAgfSkpOwogIH07Cn0pOwoKbW9kdWxlLmV4cG9ydHMgPSBBeGlvczsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9heGlvcy9saWIvY29yZS9JbnRlcmNlcHRvck1hbmFnZXIuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2NvcmUvSW50ZXJjZXB0b3JNYW5hZ2VyLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBubyBzdGF0aWMgZXhwb3J0cyBmb3VuZCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBleHBvcnRzLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7CgoKdmFyIHV0aWxzID0gX193ZWJwYWNrX3JlcXVpcmVfXygvKiEgLi8uLi91dGlscyAqLyAiLi9ub2RlX21vZHVsZXMvYXhpb3MvbGliL3V0aWxzLmpzIik7CgpmdW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gICAgcmVhc29uLnJlc3BvbnNlLmRhdGEgPSB0cmFuc2Zvcm1EYXRhKAogICAgICAgICAgcmVhc29uLnJlc3BvbnNlLmRhdGEsCiAgICAgICAgICByZWFzb24ucmVzcG9uc2UuaGVhZGVycywKICAgICAgICAgIGNvbmZpZy50cmFuc2Zvcm1SZXNwb25zZQogICAgICAgICk7CiAgICAgIH0KICAgIH0KCiAgICByZXR1cm4gUHJvbWlzZS5yZWplY3QocmVhc29uKTsKICB9KTsKfTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9heGlvcy9saWIvY29yZS9lbmhhbmNlRXJyb3IuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2NvcmUvZW5oYW5jZUVycm9yLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBubyBzdGF0aWMgZXhwb3J0cyBmb3VuZCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBleHBvcnRzLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7CgoKLyoqCiAqIFVwZGF0ZSBhbiBFcnJvciB3aXRoIHRoZSBzcGVjaWZpZWQgY29uZmlnLCBlcnJvciBjb2RlLCBhbmQgcmVzcG9uc2UuCiAqCiAqIEBwYXJhbSB7RXJyb3J9IGVycm9yIFRoZSBlcnJvciB0byB1cGRhdGUuCiAqIEBwYXJhbSB7T2JqZWN0fSBjb25maWcgVGhlIGNvbmZpZy4KICogQHBhcmFtIHtzdHJpbmd9IFtjb2RlXSBUaGUgZXJyb3IgY29kZSAoZm9yIGV4YW1wbGUsICdFQ09OTkFCT1JURUQnKS4KICogQHBhcmFtIHtPYmplY3R9IFtyZXF1ZXN0XSBUaGUgcmVxdWVzdC4KICogQHBhcmFtI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4Q29udGVudExlbmd0aCcsCiAgICAndmFsaWRhdGVTdGF0dXMnLCAnbWF4UmVkaXJlY3RzJywgJ2h0dHBBZ2VudCcsICdodHRwc0FnZW50JywgJ2NhbmNlbFRva2VuJywKICAgICdzb2NrZXRQYXRoJwogIF0sIGZ1bmN0aW9uIGRlZmF1bHRUb0NvbmZpZzIocHJvcCkgewogICAgaWYgKHR5cGVvZiBjb25maWcyW3Byb3BdICE9PSAndW5kZWZpbmVkJykgewogICAgICBjb25maWdbcHJvcF0gPSBjb25maWcyW3Byb3BdOwogICAgfSBlbHNlIGlmICh0eXBlb2YgY29uZmlnMVtwcm9wXSAhPT0gJ3VuZGVmaW5lZCcpIHsKICAgICAgY29uZmlnW3Byb3BdID0gY29uZmlnMVtwcm9wXTsKICAgIH0KICB9KTsKCiAgcmV0dXJuIGNvbmZpZzsKfTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9heGlvcy9saWIvY29yZS9zZXR0bGUuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2NvcmUvc2V0dGxlLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBubyBzdGF0aWMgZXhwb3J0cyBmb3VuZCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBleHBvcnRzLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7CgoKdmFyIGNyZWF0ZUVycm9yID0gX193ZWJwYWNrX3JlcXVpcmVfXygvKiEgLi9jcmVhdGVFcnJvciAqLyAiLi9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2NvcmUvY3JlYXRlRXJyb3IuanMiKTsKCi8qKgogKiBSZXNvbHZlIG9yIHJlamVjdCBhIFByb21pc2UgYmFzZWQgb24gcmVzcG9uc2Ugc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AgICAgIHV0aWxzLmlzRmlsZShkYXRhKSB8fAogICAgICB1dGlscy5pc0Jsb2IoZGF0YSkKICAgICkgewogICAgICByZXR1cm4gZGF0YTsKICAgIH0KICAgIGlmICh1dGlscy5pc0FycmF5QnVmZmVyVmlldyhkYXRhKSkgewogICAgICByZXR1cm4gZGF0YS5idWZmZXI7CiAgICB9CiAgICBpZiAodXRpbHMuaXNVUkxTZWFyY2hQYXJhbXMoZGF0YSkpIHsKICAgICAgc2V0Q29udGVudFR5cGVJZlVuc2V0KGhlYWRlcnMsICdhcHBsaWNhdGlvbi94LXd3dy1mb3JtLXVybGVuY29kZWQ7Y2hhcnNldD11dGYtOCcpOwogICAgICByZXR1cm4gZGF0YS50b1N0cmluZygpOwogICAgfQogICAgaWYgKHV0aWxzLmlzT2JqZWN0KGRhdGEpKSB7CiAgICAgIHNldENvbnRlbnRUeXBlSWZVbnNldChoZWFkZXJzLCAnYXBwbGljYXRpb24vanNvbjtjaGFyc2V0PXV0Zi04Jyk7CiAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeShkYXRhKTsKICAgIH0KICAgIHJldHVybiBkYXRhOwogIH1dLAoKICB0cmFuc2Zvcm1SZXNwb25zZTogW2Z1bmN0aW9uIHRyYW5zZm9ybVJlc3BvbnNlKGRhdGEpIHsKICAgIC8qZXNsaW50IG5vLXBhcmFtLXJlYXNzaWduOjAqLwogICAgaWYgKHR5cGVvZiBkYXRhID09PSAnc3RyaW5nJykgewogICAgICB0cnkgewogICAgICAgIGRhdGEgPSBKU09OLnBhcnNlKGRhdGEpOwogICAgICB9IGNhdGNoIChlKSB7IC8qIElnbm9yZSAqLyB9CiAgICB9CiAgICByZXR1cm4gZGF0YTsKICB9XSwKCiAgLyoqCiAgICogQSB0aW1lb3V0IGluIG1pbGxpc2Vjb25kcyB0byBhYm9ydCBhIHJlcXVlc3QuIElmIHNldCB0byAwIChkZWZhdWx0KSBhCiAgICogdGltZW91dCBpcyBub3QgY3JlYXRlZC4KICAgKi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qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2F4aW9zL2xpYi9oZWxwZXJzL2JpbmQuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBubyBzdGF0aWMgZXhwb3J0cyBmb3VuZCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBleHBvcnRzLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7CgoKbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiBiaW5kKGZuLCB0aGlzQXJnKSB7CiAgcmV0dXJuIGZ1bmN0aW9uIHdyYXAoKSB7CiAgICB2YXIgYXJncyA9IG5ldyBBcnJheShhcmd1bWVudHMubGVuZ3RoKTsKICAgIGZvciAodmFyIGkgPSAwOyBpIDwgYXJncy5sZW5ndGg7IGkrKykgewogICAgICBhcmdzW2ldID0gYXJndW1lbnRzW2ldOwogICAgfQogICAgcmV0dXJuIGZuLmFwcGx5KHRoaXNBcmcsIGFyZ3MpOwogIH07Cn07CgoKLyoqKi8gfSksCgovKioqLyAiLi9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2hlbHBlcnMvYnVpbGRVUkwuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9heGlvcy9saWIvaGVscGVycy9idWlsZFVSTC5qcyAqKiohCiAgXCoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBubyBzdGF0aWMgZXhwb3J0cyBmb3VuZCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBleHBvcnRzLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7CgoKdmFyIHV0aWxzID0gX193ZWJwYWNrX3Jl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ICAgc2VyaWFsaXplZFBhcmFtcyA9IHBhcmFtcy50b1N0cmluZygpOwogIH0gZWxzZSB7CiAgICB2YXIgcGFydHMgPSBbXTsKCiAgICB1dGlscy5mb3JFYWNoKHBhcmFtcywgZnVuY3Rpb24gc2VyaWFsaXplKHZhbCwga2V5KSB7CiAgICAgIGlmICh2YWwgPT09IG51bGwgfHwgdHlwZW9mIHZhbCA9PT0gJ3VuZGVmaW5lZCcpIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KCiAgICAgIGlmICh1dGlscy5pc0FycmF5KHZhbCkpIHsKICAgICAgICBrZXkgPSBrZXkgKyAnW10nOwogICAgICB9IGVsc2UgewogICAgICAgIHZhbCA9IFt2YWxdOwogICAgICB9CgogICAgICB1dGlscy5mb3JFYWNoKHZhbCwgZnVuY3Rpb24gcGFyc2VWYWx1ZSh2KSB7CiAgICAgICAgaWYgKHV0aWxzLmlzRGF0ZSh2KSkgewogICAgICAgICAgdiA9IHYudG9JU09TdHJpbmcoKTsKICAgICAgICB9IGVsc2UgaWYgKHV0aWxzLmlzT2JqZWN0KHYpKSB7CiAgICAgICAgICB2ID0gSlNPTi5zdHJpbmdpZnkodik7CiAgICAgICAgfQogICAgICAgIHBhcnRzLnB1c2goZW5jb2RlKGtleSkgKyAnPScgKyBlbmNvZGUodikpOwogICAgICB9KTsKICAgIH0pOwoKICAgIHNlcmlhbGl6ZWRQYXJhbXMgPSBwYXJ0cy5qb2luKCcmJyk7CiAgfQoKICBpZiAoc2VyaWFsaXplZFBhcmFtcykgewogICAgdmFyIGhhc2htYXJrSW5kZXggPSB1cmwuaW5kZXhPZignIycpOwogICAgaWYgKGhhc2htYXJrSW5kZXggIT09IC0xKSB7CiAgICAgIHVybCA9IHVybC5zbGljZSgwLCBoYXNobWFya0luZGV4KTsKICAgIH0KCiAgICB1cmwgKz0gKHVybC5pbmRleE9mKCc/JykgPT09IC0xID8gJz8nIDogJyYnKSArIHNlcmlhbGl6ZWRQYXJhbXM7CiAgfQoKICByZXR1cm4gdXJsOwp9OwoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2F4aW9zL2xpYi9oZWxwZXJzL2NvbWJpbmVVUkxzLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2hlbHBlcnMvY29tYmluZVVSTHMuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgbm8gc3RhdGljIGV4cG9ydHMgZm91bmQgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgZXhwb3J0cywgX193ZWJwYWNrX3JlcXVpcmVfXykgewoKInVzZSBzdHJpY3QiOwoKCi8qKgogKiBDcmVhdGVzIGEgbmV3IFVSTCBieSBjb21iaW5pbmcgdGhlIHNwZWNpZmllZCBVUkxzCiAqCiAqIEBwYXJhbSB7c3RyaW5nfSBiYXNlVVJMIFRoZSBiYXNlIFVSTAogKiBAcGFyYW0ge3N0cmluZ30gcmVsYXRpdmVVUkwgVGhlIHJlbGF0aXZlIFVSTAogKiBAcmV0dXJucyB7c3RyaW5nfSBUaGUgY29tYmluZWQgVVJMCiAqLwptb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIGNvbWJpbmVVUkxzKGJhc2VVUkwsIHJlbGF0aXZlVVJMKSB7CiAgcmV0dXJuIHJlbGF0aXZlVVJMCiAgICA/IGJhc2VVUkwucmVwbGFjZSgvXC8rJC8sICcnKSArICcvJyArIHJlbGF0aXZlVVJMLnJlcGxhY2UoL15cLysvLCAnJykKICAgIDogYmFzZVVSTDsKfTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9heGlvcy9saWIvaGVscGVycy9jb29raWVzLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9heGlvcy9saWIvaGVscGVycy9jb29raWVzLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgbm8gc3RhdGljIGV4cG9ydHMgZm91bmQgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgZXhwb3J0cywgX193ZWJwYWNrX3JlcXVpcmVfXykgewoKInVzZSBzdHJpY3QiOwoKCnZhciB1dGlscyA9IF9fd2VicGFja19yZXF1aXJlX18oLyohIC4vLi4vdXRpbHMgKi8gIi4vbm9kZV9tb2R1bGVzL2F4aW9zL2xpYi91dGlscy5qcyIpOwoKbW9kdWxlLmV4cG9ydHMgPSAoCiAgdXRpbHMuaXNTdGFuZGFyZEJyb3dzZXJFbnYoKSA/CgogIC8vIFN0YW5kYXJkIGJyb3dzZXIgZW52cyBzdXBwb3J0IGRvY3VtZW50LmNvb2tpZQogICAgKGZ1bmN0aW9uIHN0YW5kYXJkQnJvd3NlckVudigpIHsKICAgICAgcmV0dXJuIHsKICAgICAgICB3cml0ZTogZnVuY3Rpb24gd3JpdGUobmFtZSwgdmFsdWUsIGV4cGlyZXMsIHBhdGgsIGRvbWFpbiwgc2VjdXJlKSB7CiAgICAgICAgICB2YXIgY29va2llID0gW107CiAgICAgICAgICBjb29raWUucHVzaChuYW1lICsgJz0nICsgZW5jb2RlVVJJQ29tcG9uZW50KHZhbHVlKSk7CgogICAgICAgICAgaWYgKHV0aWxzLmlzTnVtYmVyKGV4cGlyZXMpKSB7CiAgICAgICAgICAgIGNvb2tpZS5wdXNoKCdleHBpcmVzPScgKyBuZXcgRGF0ZShleHBpcmVzKS50b0dNVFN0cmluZygpKTsKICAgICAgICAgIH0KCiAgICAgICAgICBpZiAodXRpbHMuaXNTdHJpbmcocGF0aCkpIHsKICAgICAgICAgICAgY29va2llLnB1c2goJ3BhdGg9JyArIHBhdGgpOwogICAgICAgICAgfQoKICAgICAgICAgIGlmICh1dGlscy5pc1N0cmluZyhkb21haW4pKSB7CiAgICAgICAgICAgIGNvb2tpZS5wdXNoKCdkb21haW49JyArIGRvbWFpbik7CiAgICAgICAgICB9CgogICAgICAgICAgaWYgKHNlY3VyZSA9PT0gdHJ1ZSkgewogICAgICAgICAgICBjb29raWUucHVzaCgnc2VjdXJlJyk7CiAgICAgICAgICB9CgogICAgICAgICAgZG9jdW1lbnQuY29va2llID0gY29va2llLmpvaW4oJzsgJyk7CiAgICAgICAgfSwKCiAgICAgICAgcmVhZDogZnVuY3Rpb24gcmVhZChuYW1lKSB7CiAgICAgICAgICB2YXIgbWF0Y2ggPSBkb2N1bWVudC5jb29raWUubWF0Y2gobmV3IFJlZ0V4cCgnKF58O1xccyopKCcgKyBuYW1lICsgJyk9KFteO10qKScpKTsKICAgICAgICAgIHJldHVybiAobWF0Y2ggPyBkZWNvZGVVUklDb21wb25lbnQobWF0Y2hbM10pIDogbnVsbCk7CiAgICAgICAgfSwKCiAgICAgICAgcmVtb3ZlOiBmdW5jdGlvbiByZW1vdmUobmFtZSkgewogICAgICAgICAgdGhpcy53cml0ZShuYW1lLCAnJywgRGF0ZS5ub3coKSAtIDg2NDAwMDAwKTsKICAgICAgICB9CiAgICAgIH07CiAgICB9KSgpIDoKCiAgLy8gTm9uIHN0YW5kYXJkIGJyb3dzZXIgZW52ICh3ZWIgd29ya2VycywgcmVhY3QtbmF0aXZlKSBsYWNrIG5lZWRlZCBzdXBwb3J0LgogICAgKGZ1bmN0aW9uIG5vblN0YW5kYXJkQnJvd3NlckVudigpIHsKICAgICAgcmV0dXJuIHsKICAgICAgICB3cml0ZTogZnVuY3Rpb24gd3JpdGUoKSB7fSwKICAgICAgICByZWFkOiBmdW5jdGlvbiByZWFkKCkgeyByZXR1cm4gbnVsbDsgfSwKICAgICAgICByZW1vdmU6IGZ1bmN0aW9uIHJlbW92ZSgpIHt9CiAgICAgIH07CiAgICB9KSgpCik7CgoKLyo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OwogICAgICB2YXIgdXJsUGFyc2luZ05vZGUgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdhJyk7CiAgICAgIHZhciBvcmlnaW5VUkw7CgogICAgICAvKioKICAgICogUGFyc2UgYSBVUkwgdG8gZGlzY292ZXIgaXQncyBjb21wb25lbnRzCiAgICAqCiAgICAqIEBwYXJhbSB7U3RyaW5nfSB1cmwgVGhlIFVSTCB0byBiZSBwYXJzZWQKICAgICogQHJldHVybnMge09iamVjdH0KICAgICovCiAgICAgIGZ1bmN0aW9uIHJlc29sdmVVUkwodXJsKSB7CiAgICAgICAgdmFyIGhyZWYgPSB1cmw7CgogICAgICAgIGlmIChtc2llKSB7CiAgICAgICAgLy8gSUUgbmVlZHMgYXR0cmlidXRlIHNldCB0d2ljZSB0byBub3JtYWxpemUgcHJvcGVydGllcwogICAgICAgICAgdXJsUGFyc2luZ05vZGUuc2V0QXR0cmlidXRlKCdocmVmJywgaHJlZik7CiAgICAgICAgICBocmVmID0gdXJsUGFyc2luZ05vZGUuaHJlZjsKICAgICAgICB9CgogICAgICAgIHVybFBhcnNpbmdOb2RlLnNldEF0dHJpYnV0ZSgnaHJlZicsIGhyZWYpOwoKICAgICAgICAvLyB1cmxQYXJzaW5nTm9kZSBwcm92aWRlcyB0aGUgVXJsVXRpbHMgaW50ZXJmYWNlIC0gaHR0cDovL3VybC5zcGVjLndoYXR3Zy5vcmcvI3VybHV0aWxzCiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGhyZWY6IHVybFBhcnNpbmdOb2RlLmhyZWYsCiAgICAgICAgICBwcm90b2NvbDogdXJsUGFyc2luZ05vZGUucHJvdG9jb2wgPyB1cmxQYXJzaW5nTm9kZS5wcm90b2NvbC5yZXBsYWNlKC86JC8sICcnKSA6ICcnLAogICAgICAgICAgaG9zdDogdXJsUGFyc2luZ05vZGUuaG9zdCwKICAgICAgICAgIHNlYXJjaDogdXJsUGFyc2luZ05vZGUuc2VhcmNoID8gdXJsUGFyc2luZ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HJpbShsaW5lLnN1YnN0cihpICsgMSkpOwoKICAgIGlmIChrZXkpIHsKICAgICAgaWYgKHBhcnNlZFtrZXldICYmIGlnbm9yZUR1cGxpY2F0ZU9mLmluZGV4T2Yoa2V5KSA+PSAwKSB7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGlmIChrZXkgPT09ICdzZXQtY29va2llJykgewogICAgICAgIHBhcnNlZFtrZXldID0gKHBhcnNlZFtrZXldID8gcGFyc2VkW2tleV0gOiBbXSkuY29uY2F0KFt2YWxdKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBwYXJzZWRba2V5XSA9IHBhcnNlZFtrZXldID8gcGFyc2VkW2tleV0gKyAnLCAnICsgdmFsIDogdmFsOwogICAgICB9CiAgICB9CiAgfSk7CgogIHJldHVybiBwYXJzZWQ7Cn07CgoKLyoqKi8gfSksCgovKioqLyAiLi9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2hlbHBlcnMvc3ByZWFkLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2F4aW9zL2xpYi9oZWxwZXJzL3NwcmVhZC5qcyAqKiohCiAgXCoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgbm8gc3RhdGljIGV4cG9ydHMgZm91bmQgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgZXhwb3J0cywgX193ZWJwYWNrX3JlcXVpcmVfXykgewoKInVzZSBzdHJpY3QiOwoKCi8qKgogKiBTeW50YWN0aWMgc3VnYXIgZm9yIGludm9raW5nIGEgZnVuY3Rpb24gYW5kIGV4cGFuZGluZyBhbiBhcnJheSBmb3IgYXJndW1lbnRzLgogKgogKiBDb21tb24gdXNlIGNhc2Ugd291bGQgYmUgdG8gdXNlIGBGdW5jdGlvbi5wcm90b3R5cGUuYXBwbHlgLgogKgogKiAgYGBganMKICogIGZ1bmN0aW9uIGYoeCwgeSwgeikge30KICogIHZhciBhcmdzID0gWzEsIDIsIDNdOwogKiAgZi5hcHBseShudWxsLCBhcmdzKTsKICogIGBgYAogKgogKiBXaXRoIGBzcHJlYWRgIHRoaXMgZXhhbXBsZSBjYW4gYmUgcmUtd3JpdHRlbi4KICoKICogIGBgYGpzCiAqICBzcHJlYWQoZnVuY3Rpb24oeCwgeSwgeikge30pKFsxLCAyLCAzXSk7CiAqICBgYGAKICoKICogQHBhcmFtIHtGdW5jdGlvbn0gY2FsbGJhY2sKICogQHJldHVybnMge0Z1bmN0aW9ufQogKi8KbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiBzcHJlYWQoY2FsbGJhY2spIHsKICByZXR1cm4gZnVuY3Rpb24gd3JhcChhcnIpIHsKICAgIHJldHVybiBjYWxsYmFjay5hcHBseShudWxsLCBhcnIpOwogIH07Cn07CgoKLyoqKi8gfSksCgovKioqLyAiLi9ub2RlX21vZHVsZXMvYXhpb3MvbGliL3V0aWxzLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2F4aW9zL2xpYi91dGlscy5qcyAqKiohCiAgXCoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgbm8gc3RhdGljIGV4cG9ydHMgZm91bmQgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgZXhwb3J0cywgX193ZWJwYWNrX3JlcXVpcmVfXykgewoKInVzZSBzdHJpY3QiOwoKCnZhciBiaW5kID0gX193ZWJwYWNrX3JlcXVpcmVfXygvKiEgLi9oZWxwZXJzL2JpbmQgKi8gIi4vbm9kZV9tb2R1bGVzL2F4aW9zL2xpYi9oZWxwZXJzL2JpbmQuanMiKTsKdmFyIGlzQnVmZmVyID0gX193ZWJwYWNrX3JlcXVpcmVfXygvKiEgaXMtYnVmZmVyICovICIuL25vZ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ICAgICc9PScKICAgICkKICB9IGVsc2UgaWYgKGV4dHJhQnl0ZXMgPT09IDIpIHsKICAgIHRtcCA9ICh1aW50OFtsZW4gLSAyXSA8PCA4KSArIHVpbnQ4W2xlbiAtIDFdCiAgICBwYXJ0cy5wdXNoKAogICAgICBsb29rdXBbdG1wID4+IDEwXSArCiAgICAgIGxvb2t1cFsodG1wID4+IDQpICYgMHgzRl0gKwogICAgICBsb29rdXBbKHRtcCA8PCAyKSAmIDB4M0ZdICsKICAgICAgJz0nCiAgICApCiAgfQoKICByZXR1cm4gcGFydHMuam9pbignJykKfQoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2JpZy1yYXQvYWRkLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvYmlnLXJhdC9hZGQuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgbm8gc3RhdGljIGV4cG9ydHMgZm91bmQgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgZXhwb3J0cywgX193ZWJwYWNrX3JlcXVpcmVfXykgewoKInVzZSBzdHJpY3QiOwoKCnZhciByYXRpb25hbGl6ZSA9IF9fd2VicGFja19yZXF1aXJlX18oLyohIC4vbGliL3JhdGlvbmFsaXplICovICIuL25vZGVfbW9kdWxlcy9iaWctcmF0L2xpYi9yYXRpb25hbGl6ZS5qcyIpCgptb2R1bGUuZXhwb3J0cyA9IGFkZAoKZnVuY3Rpb24gYWRkKGEsIGIpIHsKICByZXR1cm4gcmF0aW9uYWxpemUoCiAgICBhWzBdLm11bChiWzFdKS5hZGQoYlswXS5tdWwoYVsxXSkpLAogICAgYVsxXS5tdWwoYlsxXSkpCn0KCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9iaWctcmF0L2NtcC5qcyI6Ci8qISoqKioqKioqKioqKioqKioqKioqK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CgpmdW5jdGlvbiBtYWtlUmF0aW9uYWwobnVtZXIsIGRlbm9tKSB7CiAgaWYoaXNSYXQobnVtZXIpKSB7CiAgICBpZihkZW5vbSkgewogICAgICByZXR1cm4gZGl2KG51bWVyLCBtYWtlUmF0aW9uYWwoZGVub20pKQogICAgfQogICAgcmV0dXJuIFtudW1lclswXS5jbG9uZSgpLCBudW1lclsxXS5jbG9uZSgpXQogIH0KICB2YXIgc2hpZnQgPSAwCiAgdmFyIGEsIGIKICBpZihpc0JOKG51bWVyKSkgewogICAgYSA9IG51bWVyLmNsb25lKCkKICB9IGVsc2UgaWYodHlwZW9mIG51bWVyID09PSAnc3RyaW5nJykgewogICAgYSA9IHN0cjJibihudW1lcikKICB9IGVsc2UgaWYobnVtZXIgPT09IDApIHsKICAgIHJldHVybiBbbnVtMmJuKDApLCBudW0yYm4oMSldCiAgfSBlbHNlIGlmKG51bWVyID09PSBNYXRoLmZsb29yKG51bWVyKSkgewogICAgYSA9IG51bTJibihudW1lcikKICB9IGVsc2UgewogICAgd2hpbGUobnVtZXIgIT09IE1hdGguZmxvb3IobnVtZXIpKSB7CiAgICAgIG51bWVyID0gbnVtZXIgKiBNYXRoLnBvdygyLCAyNTYpCiAgICAgIHNoaWZ0IC09IDI1NgogICAgfQogICAgYSA9IG51bTJibihudW1lcikKICB9CiAgaWYoaXNSYXQoZGVub20pKSB7CiAgICBhLm11bChkZW5vbVsxXSkKICAgIGIgPSBkZW5vbVswXS5jbG9uZSgpCiAgfSBlbHNlIGlmKGlzQk4oZGVub20pKSB7CiAgICBiID0gZGVub20uY2xvbmUoKQogIH0gZWxzZSBpZih0eXBlb2YgZGVub20gPT09ICdzdHJpbmcnKSB7CiAgICBiID0gc3RyMmJuKGRlbm9tKQogIH0gZWxzZSBpZighZGVub20pIHsKICAgIGIgPSBudW0yYm4oMSkKICB9IGVsc2UgaWYoZGVub20gPT09IE1hdGguZmxvb3IoZGVub20pKSB7CiAgICBiID0gbnVtMmJuKGRlbm9tKQ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KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9iaWctcmF0L2xpYi9ibi1zaWduLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgbm8gc3RhdGljIGV4cG9ydHMgZm91bmQgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgZXhwb3J0cywgX193ZWJwYWNrX3JlcXVpcmVfXykgewoKInVzZSBzdHJpY3QiOwoKCnZhciBCTiA9IF9fd2VicGFja19yZXF1aXJlX18oLyohIGJuLmpzICovICIuL25vZGVfbW9kdWxlcy9ibi5qcy9saWIvYm4uanMiKQoKbW9kdWxlLmV4cG9ydHMgPSBzaWduCgpmdW5jdGlvbiBzaWduICh4KSB7CiAgcmV0dXJuIHguY21wKG5ldyBCTigwKSkKfQoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2JpZy1yYXQvbGliL2JuLXRvLW51bS5qcyI6Ci8qISoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9iaWctcmF0L2xpYi9ibi10by1udW0uanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohIG5vIHN0YXRpYyBleHBvcnRzIGZvdW5kICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIGV4cG9ydHMsIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKCgp2YXIgc2lnbiA9IF9fd2VicGFja19yZXF1aXJlX18oLyohIC4vYm4tc2lnbiAqLyAiLi9ub2RlX21vZHVsZXMvYmlnLXJhdC9saWIvYm4tc2lnbi5qcyIpCgptb2R1bGUuZXhwb3J0cyA9IGJuMm51bQoKLy9UT0RPOiBNYWtlIHRoaXMgYmV0dGVyCmZ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ioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvYmlnLXJhdC9saWIvbnVtLXRvLWJuLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBubyBzdGF0aWMgZXhwb3J0cyBmb3VuZCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBleHBvcnRzLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7CgoKdmFyIEJOID0gX193ZWJwYWNrX3JlcXVpcmVfXygvKiEgYm4uanMgKi8gIi4vbm9kZV9tb2R1bGVzL2JuLmpzL2xpYi9ibi5qcyIpCnZhciBkYiA9IF9fd2VicGFja19yZXF1aXJlX18oLyohIGRvdWJsZS1iaXRzICovICIuL25vZGVfbW9kdWxlcy9kb3VibGUtYml0cy9kb3VibGUuanMiKQoKbW9kdWxlLmV4cG9ydHMgPSBudW0yYm4KCmZ1bmN0aW9uIG51bTJibih4KSB7CiAgdmFyIGUgPSBkYi5leHBvbmVudCh4KQogIGlmKGUgPCA1MikgewogICAgcmV0dXJuIG5ldyBCTih4KQogIH0gZWxzZSB7CiAgICByZXR1cm4gKG5ldyBCTih4ICogTWF0aC5wb3coMiwgNTItZSkpKS51c2hsbihlLTUyKQogIH0KfQoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2JpZy1yYXQvbGliL3JhdGlvbmFsaXplLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvYmlnLXJhdC9saWIvcmF0aW9uYWxpemUuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgbm8gc3RhdGljIGV4cG9ydHMgZm91bmQgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgZXhwb3J0cywgX193ZWJwYWNrX3JlcXVpcmVfXykgewoKInVzZSBzdHJpY3QiOwoKCnZhciBudW0yYm4gPSBfX3dlYnBhY2tfcmVxdWlyZV9fKC8qISAuL251bS10by1ibiAqLyAiLi9ub2RlX21vZHVsZXMvYmlnLXJhdC9saWIvbnVtLXRvLWJuLmpzIikKdmFyIHNpZ24gPSBfX3dlYnBhY2tfcmVxdWlyZV9fKC8qISAuL2JuLXNpZ24gKi8gIi4vbm9kZV9tb2R1bGVzL2JpZy1yYXQvbGliL2JuLXNpZ24uanMiKQoKbW9kdWxlLmV4cG9ydHMgPSByYXRpb25hbGl6ZQoKZnVuY3Rpb24gcmF0aW9uYWxpemUobnVtZXIsIGRlbm9tKSB7CiAgdmFyIHNudW1lciA9IHNpZ24obnVtZXIpCiAgdmFyIHNkZW5vbSA9IHNpZ24oZGVub20pCiAgaWYoc251bWVyID09PSAwKSB7CiAgICByZXR1cm4gW251bTJibigwKSwgbnVtMmJuKDEpXQogIH0KICBpZihzZGVub20gPT09IDApIHsKICAgIHJldHVybiBbbnVtMmJuKDApLCBudW0yYm4oMCldCiAgfQogIGlmKHNkZW5vbSA8IDApIHsKICAgIG51bWVyID0gbnVtZXIubmVnKCkKICAgIGRlbm9tID0gZGVub20ubmVnKCkKICB9CiAgdmFyIGQgPSBudW1lci5nY2QoZGVub20pCiAgaWYoZC5jbXBuKDEpKSB7CiAgICByZXR1cm4gWyBudW1lci5kaXYoZCksIGRlbm9tLmRpdihkKSBdCiAgfQogIHJldHVybiBbIG51bWVyLCBkZW5vbSBdCn0KCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9iaWctcmF0L2xpYi9zdHItdG8tYm4uanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvYmlnLXJhdC9saWIvc3RyLXRvLWJuLmpzICoqKiEKICBcKioqKioqKioqKioq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8qISoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9iaWctcmF0L3NpZ24uanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohIG5vIHN0YXRpYyBleHBvcnRzIGZvdW5kICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIGV4cG9ydHMsIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKCgp2YXIgYm5zaWduID0gX193ZWJwYWNrX3JlcXVpcmVfXygvKiEgLi9saWIvYm4tc2lnbiAqLyAiLi9ub2RlX21vZHVsZXMvYmlnLXJhdC9saWIvYm4tc2lnbi5qcyIpCgptb2R1bGUuZXhwb3J0cyA9IHNpZ24KCmZ1bmN0aW9uIHNpZ24oeCkgewogIHJldHVybiBibnNpZ24oeFswXSkgKiBibnNpZ24oeFsxXSkKfQoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2JpZy1yYXQvc3ViLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvYmlnLXJhdC9zdWIuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgbm8gc3RhdGljIGV4cG9ydHMgZm91bmQgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgZXhwb3J0cywgX193ZWJwYWNrX3JlcXVpcmVfXykgewoKInVzZSBzdHJpY3QiOwoKCnZhciByYXRpb25hbGl6ZSA9IF9fd2VicGFja19yZXF1aXJlX18oLyohIC4vbGliL3JhdGlvbmFsaXplICovICIuL25vZGVfbW9kdWxlcy9iaWctcmF0L2xpYi9yYXRpb25hbGl6ZS5qcyIpCgptb2R1bGUuZXhwb3J0cyA9IHN1YgoKZnVuY3Rpb24gc3ViKGEsIGIpIHsKICByZX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yZHNbaV07CiAgICAgICAgdmFyIHdvcmQgPSAoKCh3IDw8IG9mZikgfCBjYXJyeSkgJiAweGZmZmZmZikudG9TdHJpbmcoMTYpOwogICAgICAgIGNhcnJ5ID0gKHcgPj4+ICgyNCAtIG9mZikpICYgMHhmZmZmZmY7CiAgICAgICAgaWYgKGNhcnJ5ICE9PSAwIHx8IGkgIT09IHRoaXMubGVuZ3RoIC0gMSkgewogICAgICAgICAgb3V0ID0gemVyb3NbNiAtIHdvcmQubGVuZ3RoXSArIHdvcmQgKyBvdXQ7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIG91dCA9IHdvcmQgKyBvdXQ7CiAgICAgICAgfQogICAgICAgIG9mZiArPSAyOwogICAgICAgIGlmIChvZmYgPj0gMjYpIHsKICAgICAgICAgIG9mZiAtPSAyNjsKICAgICAgICAgIGktLTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKGNhcnJ5ICE9PSAwKSB7CiAgICAgICAgb3V0ID0gY2FycnkudG9TdHJpbmcoMTYpICsgb3V0OwogICAgICB9CiAgICAgIHdoaWxlIChvdXQubGVuZ3RoICUgcGFkZGluZyAhPT0gMCkgewogICAgICAgIG91dCA9ICcwJyArIG91dDsKICAgICAgfQogICAgICBpZiAodGhpcy5uZWdhdGl2ZSAhPT0gMCkgewogICAgICAgIG91dCA9ICctJyArIG91dDsKICAgICAgfQogICAgICByZXR1cm4gb3V0OwogICAgfQoKICAgIGlmIChiYXNlID09PSAoYmFzZSB8IDApICYmIGJhc2UgPj0gMiAmJiBiYXNlIDw9IDM2KSB7CiAgICAgIC8vIHZhciBncm91cFNpemUgPSBNYXRoLmZsb29yKEJOLndvcmRTaXplICogTWF0aC5MTjIgLyBNYXRoLmxvZyhiYXNlKSk7CiAgICAgIHZhciBncm91cFNpemUgPSBncm91cFNpemVzW2Jhc2VdOwogICAgICAvLyB2YXIgZ3JvdXBCYXNlID0gTWF0aC5wb3coYmFzZSwgZ3JvdXBTaXplKTsKICAgICAgdmFyIGdyb3VwQmFzZSA9IGdyb3VwQmFzZXNbYmFzZV07CiAgICAgIG91dCA9ICcnOwogICAgICB2YXIgYyA9IHRoaXMuY2xvbmUoKTsKICAgICAgYy5uZWdhdGl2ZSA9IDA7CiAgICAgIHdoaWxlICghYy5pc1plcm8oKSkgewogICAgICAgIHZhciByID0gYy5tb2RuKGdyb3VwQmFzZSkudG9TdHJpbmcoYmFzZSk7CiAgICAgICAgYyA9IGMuaWRpdm4oZ3JvdXBCYXNlKTsKCiAgICAgICAgaWYgKCFjLmlzWmVybygpKSB7CiAgICAgICAgICBvdXQgPSB6ZXJvc1tncm91cFNpemUgLSByLmxlbmd0aF0gKyByICsgb3V0OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBvdXQgPSByICsgb3V0OwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAodGhpcy5pc1plcm8oKSkgewogICAgICAgIG91dCA9ICcwJyArIG91dDsKICAgICAgfQogICAgICB3aGlsZSAob3V0Lmxlbmd0aCAlIHBhZGRpbmcgIT09IDApIHsKICAgICAgICBvdXQgPSAnMCcgKyBvdXQ7CiAgICAgIH0KICAgICAgaWYgKHRoaXMubmVnYXRpdmUgIT09IDApIHsKICAgICAgICBvdXQgPSAnLScgKyBvdXQ7CiAgICAgIH0KICAgICAgcmV0dXJuIG91dDsKICAgIH0KCiAgICBhc3NlcnQoZmFsc2UsICdCYXNlIHNob3VsZCBiZSBiZXR3ZWVuIDIgYW5kIDM2Jyk7CiAgfTsKCiAgQk4ucHJvdG90eXBlLnRvTnVtYmVyID0gZnVuY3Rpb24gdG9OdW1iZXIgKCkgewogICAgdmFyIHJldCA9IHRoaXMud29yZHNbMF07CiAgICBpZiAodGhpcy5sZW5ndGggPT09IDIpIHsKICAgICAgcmV0ICs9IHRoaXMud29yZHNbMV0gKiAweDQwMDAwMDA7CiAgICB9IGVsc2UgaWYgKHRoaXMubGVuZ3RoID09PSAzICYmIHRoaXMud29yZHNbMl0gPT09IDB4MDEpIHsK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50Qml0cyAodykgewogICAgICByZXR1cm4gMzIgLSBNYXRoLmNsejMyKHcpOwogICAgfTsKICB9IGVsc2UgewogICAgQk4ucHJvdG90eXBlLl9jb3VudEJpdHMgPSBmdW5jdGlvbiBfY291bnRCaXRzICh3KSB7CiAgICAgIHZhciB0ID0gdzsKICAgICAgdmFyIHIgPSAwOwogICAgICBpZiAodCA+PSAweDEwMDApIHsKICAgICAgICByICs9IDEzOwogICAgICAgIHQgPj4+PSAxMzsKICAgICAgfQogICAgICBpZiAodCA+PSAweDQwKSB7CiAgICAgICAgciArPSA3OwogICAgICAgIHQgPj4+PSA3OwogICAgICB9CiAgICAgIGlmICh0ID49IDB4OCkgewogICAgICAgIHIgKz0gNDsKICAgICAgICB0ID4+Pj0gNDsKICAgICAgfQogICAgICBpZiAodCA+PSAweDAyKSB7CiAgICAgICAgciArPSAyOwogICAgICAgIHQgPj4+PSAyOwogICAgICB9CiAgICAgIHJldHVybiByICsgdDsKICAgIH07CiAgfQoKICBCTi5wcm90b3R5cGUuX3plcm9CaXRzID0gZnVuY3Rpb24gX3plcm9CaXRzICh3KSB7CiAgICAvLyBTaG9ydC1jdXQKICAgIGlmICh3ID09PSAwKSByZXR1cm4gMjY7CgogICAgdmFyIHQgPSB3OwogICAgdmFyIHIgPSAwOwogICAgaWYgKCh0ICYgMHgxZmZmKSA9PT0gMCkgewogICAgICByICs9IDEzOwogICAgICB0ID4+Pj0gMTM7CiAgICB9CiAgICBpZiAoKHQgJiAweDdmKSA9PT0gMCkgewogICAgICByICs9IDc7CiAgICAgIHQgPj4+PSA3OwogICAgfQogICAgaWYgKCh0ICYgMHhmKSA9PT0gMCkgewogICAgICByICs9IDQ7CiAgICAgIHQgPj4+PSA0OwogICAgfQogICAgaWYgKCh0ICYgMHgzKSA9PT0gMCkgewogICAgICByICs9IDI7CiAgICAgIHQgPj4+PSAyOwogICAgfQogICAgaWYgKCh0ICYgMHgxKSA9PT0gMCkgewogICAgICByKys7CiAgICB9CiAgICByZXR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iID0gdGhpczsKICAgIH0KCiAgICB2YXIgY2FycnkgPSAwOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBiLmxlbmd0aDsgaSsrKSB7CiAgICAgIHIgPSAoYS53b3Jkc1tpXSB8IDApICsgKGIud29yZHNbaV0gfCAwKSArIGNhcnJ5OwogICAgICB0aGlzLndvcmRzW2ldID0gciAmIDB4M2ZmZmZmZjsKICAgICAgY2FycnkgPSByID4+PiAyNjsKICAgIH0KICAgIGZvciAoOyBjYXJyeSAhPT0gMCAmJiBpIDwgYS5sZW5ndGg7IGkrKykgewogICAgICByID0gKGEud29yZHNbaV0gfCAwKSArIGNhcnJ5OwogICAgICB0aGlzLndvcmRzW2ldID0gciAmIDB4M2ZmZmZmZjsKICAgICAgY2FycnkgPSByID4+PiAyNjsKICAgIH0KCiAgICB0aGlzLmxlbmd0aCA9IGEubGVuZ3RoOwogICAgaWYgKGNhcnJ5ICE9PSAwKSB7CiAgICAgIHRoaXMud29yZHNbdGhpcy5sZW5ndGhdID0gY2Fycnk7CiAgICAgIHRoaXMubGVuZ3RoKys7CiAgICAvLyBDb3B5IHRoZSByZXN0IG9mIHRoZSB3b3JkcwogICAgfSBlbHNlIGlmIChhICE9PSB0aGlzKSB7CiAgICAgIGZvciAoOyBpIDwgYS5sZW5ndGg7IGkrKykgewogICAgICAgIHRoaXMud29yZHNbaV0gPSBhLndvcmRzW2ldOwogICAgICB9CiAgICB9CgogICAgcmV0dXJuIHRoaXM7CiAgfTsKCiAgLy8gQWRkIGBudW1gIHRvIGB0aGlzYAogIEJOLnByb3RvdHlwZS5hZGQgPSBmdW5jdGlvbiBhZGQgKG51bSkgewogICAgdmFyIHJlczsKICAgIGlmIChudW0ubmVnYXRpdmUgIT09IDAgJiYgdGhpcy5uZWdhdGl2ZSA9PT0gMCkgewogICAgICBudW0ubmVnYXRpdmUgPSAwOwogICAgICByZXMgPSB0aGlzLnN1YihudW0pOwogICAgICBudW0ubmVnYXRpdmUgXj0gMTsKICAgICA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YXRoLm1pbihrLCBudW0ubGVuZ3RoIC0gMSk7CiAgICAgIGZvciAodmFyIGogPSBNYXRoLm1heCgwLCBrIC0gc2VsZi5sZW5ndGggKyAxKTsgaiA8PSBtYXhKOyBqKyspIHsKICAgICAgICB2YXIgaSA9IChrIC0gaikgfCAwOwogICAgICAgIGEgPSBzZWxmLndvcmRzW2ldIHwgMDsKICAgICAgICBiID0gbnVtLndvcmRzW2pdIHwgMDsKICAgICAgICByID0gYSAqIGIgKyByd29yZDsKICAgICAgICBuY2FycnkgKz0gKHIgLyAweDQwMDAwMDApIHwgMDsKICAgICAgICByd29yZCA9IHIgJiAweDNmZmZmZmY7CiAgICAgIH0KICAgICAgb3V0LndvcmRzW2tdID0gcndvcmQgfCAwOwogICAgICBjYXJyeSA9IG5jYXJyeSB8IDA7CiAgICB9CiAgICBpZiAoY2FycnkgIT09IDApIHsKICAgICAgb3V0LndvcmRzW2tdID0gY2FycnkgfCAwOwogICAgfSBlbHNlIHsKICAgICAgb3V0Lmxlbmd0aC0tOwogICAgfQoKICAgIHJldHVybiBvdXQuc3RyaXAoKTsKICB9CgogIC8vIFRPRE8oaW5kdXRueSk6IGl0IG1heSBiZSByZWFzb25hYmxlIHRvIG9taXQgaXQgZm9yIHVzZXJzIHdobyBkb24ndCBuZWVkCiAgLy8gdG8gd29yayB3aXRoIDI1Ni1iaXQgbnVtYmVycywgb3RoZXJ3aXNlIGl0IGdpdmVzIDIwJSBpbXByb3ZlbWVudCBmb3IgMjU2LWJpdAogIC8vIG11bHRpcGxpY2F0aW9uIChsaWtlIGVsbGlwdGljIHNlY3AyNTZrMSkuCiAgdmFyIGNvbWIxME11bFRvID0gZnVuY3Rpb24gY29tYjEwTXVsVG8gKHNlbGYsIG51bSwgb3V0KSB7CiAgICB2YXIgYSA9IHNlbGYud29yZHM7CiAgICB2YXIgYiA9IG51bS53b3JkczsKICAgIHZhciBvID0gb3V0LndvcmRzOwogICAgdmFyIGMgPSAwOwogICAgdmFyIGxvOwogIC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JoMikpIHwgMDsKICAgIG1pZCA9IChtaWQgKyBNYXRoLmltdWwoYWg1LCBibDIpKSB8IDA7CiAgICBoaSA9IChoaSArIE1hdGguaW11bChhaDUsIGJoMikpIHwgMDsKICAgIGxvID0gKGxvICsgTWF0aC5pbXVsKGFsNCwgYmwzKSkgfCAwOwogICAgbWlkID0gKG1pZCArIE1hdGguaW11bChhbDQsIGJoMykpIHwgMDsKICAgIG1pZCA9IChtaWQgKyBNYXRoLmltdWwoYWg0LCBibDMpKSB8IDA7CiAgICBoaSA9IChoaSArIE1hdGguaW11bChhaDQsIGJoMykpIHwgMDsKICAgIGxvID0gKGxvICsgTWF0aC5pbXVsKGFsMywgYmw0KSkgfCAwOwogICAgbWlkID0gKG1pZCArIE1hdGguaW11bChhbDMsIGJoNCkpIHwgMDsKICAgIG1pZCA9IChtaWQgKyBNYXRoLmltdWwoYWgzLCBibDQpKSB8IDA7CiAgICBoaSA9IChoaSArIE1hdGguaW11bChhaDMsIGJoNCkpIHwgMDsKICAgIGxvID0gKGxvICsgTWF0aC5pbXVsKGFsMiwgYmw1KSkgfCAwOwogICAgbWlkID0gKG1pZCArIE1hdGguaW11bChhbDIsIGJoNSkpIHwgMDsKICAgIG1pZCA9IChtaWQgKyBNYXRoLmltdWwoYWgyLCBibDUpKSB8IDA7CiAgICBoaSA9IChoaSArIE1hdGguaW11bChhaDIsIGJoNSkpIHwgMDsKICAgIGxvID0gKGxvICsgTWF0aC5pbXVsKGFsMSwgYmw2KSkgfCAwOwogICAgbWlkID0gKG1pZCArIE1hdGguaW11bChhbDEsIGJoNikpIHwgMDsKICAgIG1pZCA9IChtaWQgKyBNYXRoLmltdWwoYWgxLCBibDYpKSB8IDA7CiAgICBoaSA9IChoaSArIE1hdGguaW11bChhaDEsIGJoNikpIHwgMDsKICAgIGxvID0gKGxvICsgTWF0aC5pbXVsKGFsMCwgYmw3KSkgfCAwOwogICAgbWlkID0gKG1pZCArIE1hdGguaW11bChhbDAsIGJoNykpIHwgMD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9IDE0ICovCiAgICBsbyA9IE1hdGguaW11bChhbDksIGJsNSk7CiAgICBtaWQgPSBNYXRoLmltdWwoYWw5LCBiaDUpOwogICAgbWlkID0gKG1pZCArIE1hdGguaW11bChhaDksIGJsNSkpIHwgMDsKICAgIGhpID0gTWF0aC5pbXVsKGFoOSwgYmg1KTsKICAgIGxvID0gKGxvICsgTWF0aC5pbXVsKGFsOCwgYmw2KSkgfCAwOwogICAgbWlkID0gKG1pZCArIE1hdGguaW11bChhbDgsIGJoNikpIHwgMDsKICAgIG1pZCA9IChtaWQgKyBNYXRoLmltdWwoYWg4LCBibDYpKSB8IDA7CiAgICBoaSA9IChoaSArIE1hdGguaW11bChhaDgsIGJoNikpIHwgMDsKICAgIGxvID0gKGxvICsgTWF0aC5pbXVsKGFsNywgYmw3KSkgfCAwOwogICAgbWlkID0gKG1pZCArIE1hdGguaW11bChhbDcsIGJoNykpIHwgMDsKICAgIG1pZCA9IChtaWQgKyBNYXRoLmltdWwoYWg3LCBibDcpKSB8IDA7CiAgICBoaSA9IChoaSArIE1hdGguaW11bChhaDcsIGJoNykpIHwgMDsKICAgIGxvID0gKGxvICsgTWF0aC5pbXVsKGFsNiwgYmw4KSkgfCAwOwogICAgbWlkID0gKG1pZCArIE1hdGguaW11bChhbDYsIGJoOCkpIHwgMDsKICAgIG1pZCA9IChtaWQgKyBNYXRoLmltdWwoYWg2LCBibDgpKSB8IDA7CiAgICBoaSA9IChoaSArIE1hdGguaW11bChhaDYsIGJoOCkpIHwgMDsKICAgIGxvID0gKGxvICsgTWF0aC5pbXVsKGFsNSwgYmw5KSkgfCAwOwogICAgbWlkID0gKG1pZCArIE1hdGguaW11bChhbDUsIGJoOSkpIHwgMDsKICAgIG1pZCA9IChtaWQgKyBNYXRoLmltdWwoYWg1LCBibDkpKSB8IDA7CiAgICBoaSA9IChoaSArIE1hdGguaW11bChhaDUsIGJoOSkpIHwgMDsKICAgIHZhciB3MTQgPSAoKChjICsgbG8pIHwgMCkgKyAoKG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gdmFyIGlvID0gaXR3c1twICsgaiArIHNdOwoKICAgICAgICAgIHZhciByeCA9IHJ0d2RmXyAqIHJvIC0gaXR3ZGZfICogaW87CgogICAgICAgICAgaW8gPSBydHdkZl8gKiBpbyArIGl0d2RmXyAqIHJvOwogICAgICAgICAgcm8gPSByeDsKCiAgICAgICAgICBydHdzW3AgKyBqXSA9IHJlICsgcm87CiAgICAgICAgICBpdHdzW3AgKyBqXSA9IGllICsgaW87CgogICAgICAgICAgcnR3c1twICsgaiArIHNdID0gcmUgLSBybzsKICAgICAgICAgIGl0d3NbcCArIGogKyBzXSA9IGllIC0gaW87CgogICAgICAgICAgLyoganNoaW50IG1heGRlcHRoIDogZmFsc2UgKi8KICAgICAgICAgIGlmIChqICE9PSBsKSB7CiAgICAgICAgICAgIHJ4ID0gcnR3ZGYgKiBydHdkZl8gLSBpdHdkZiAqIGl0d2RmXzsKCiAgICAgICAgICAgIGl0d2RmXyA9IHJ0d2RmICogaXR3ZGZfICsgaXR3ZGYgKiBydHdkZl87CiAgICAgICAgICAgIHJ0d2RmXyA9IHJ4OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfQogIH07CgogIEZGVE0ucHJvdG90eXBlLmd1ZXNzTGVuMTNiID0gZnVuY3Rpb24gZ3Vlc3NMZW4xM2IgKG4sIG0pIHsKICAgIHZhciBOID0gTWF0aC5tYXgobSwgbikgfCAxOwogICAgdmFyIG9kZCA9IE4gJiAxOwogICAgdmFyIGkgPSAwOwogICAgZm9yIChOID0gTiAvIDIgfCAwOyBOOyBOID0gTiA+Pj4gMSkgewogICAgICBpKys7CiAgICB9CgogICAgcmV0dXJuIDEgPDwgaSArIDEgKyBvZGQ7CiAgfTsKCiAgRkZUTS5wcm90b3R5cGUuY29uanVnYXRlID0gZnVuY3Rpb24gY29uanVnYXRlIChyd3MsIGl3cywgTikgewogICAgaWYgKE4gPD0gMSkgcmV0dXJuOwoKICAgIGZvciAodmFyIGkgPSAwOyBpIDwgTiAvIDI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5ID0gY2FycnkgPj4+IDEzOwogICAgfQoKICAgIC8vIFBhZCB3aXRoIHplcm9lcwogICAgZm9yIChpID0gMiAqIGxlbjsgaSA8IE47ICsraSkgewogICAgICByd3NbaV0gPSAwOwogICAgfQoKICAgIGFzc2VydChjYXJyeSA9PT0gMCk7CiAgICBhc3NlcnQoKGNhcnJ5ICYgfjB4MWZmZikgPT09IDApOwogIH07CgogIEZGVE0ucHJvdG90eXBlLnN0dWIgPSBmdW5jdGlvbiBzdHViIChOKSB7CiAgICB2YXIgcGggPSBuZXcgQXJyYXkoTik7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IE47IGkrKykgewogICAgICBwaFtpXSA9IDA7CiAgICB9CgogICAgcmV0dXJuIHBoOwogIH07CgogIEZGVE0ucHJvdG90eXBlLm11bHAgPSBmdW5jdGlvbiBtdWxwICh4LCB5LCBvdXQpIHsKICAgIHZhciBOID0gMiAqIHRoaXMuZ3Vlc3NMZW4xM2IoeC5sZW5ndGgsIHkubGVuZ3RoKTsKCiAgICB2YXIgcmJ0ID0gdGhpcy5tYWtlUkJUKE4pOwoKICAgIHZhciBfID0gdGhpcy5zdHViKE4pOwoKICAgIHZhciByd3MgPSBuZXcgQXJyYXkoTik7CiAgICB2YXIgcndzdCA9IG5ldyBBcnJheShOKTsKICAgIHZhciBpd3N0ID0gbmV3IEFycmF5KE4pOwoKICAgIHZhciBucndzID0gbmV3IEFycmF5KE4pOwogICAgdmFyIG5yd3N0ID0gbmV3IEFycmF5KE4pOwogICAgdmFyIG5pd3N0ID0gbmV3IEFycmF5KE4pOwoKICAgIHZhciBybXdzID0gb3V0LndvcmRzOwogICAgcm13cy5sZW5ndGggPSBOOwoKICAgIHRoaXMuY29udmVydDEzYih4LndvcmRzLCB4Lmxlbmd0aCwgcndzLCBOKTsKICAgIHRoaXMuY29udmVydDEzYih5LndvcmRzLCB5Lmxlbmd0aCwgbnJ3cywgTik7CgogICAgdGhpcy50cmFuc2Zvcm0ocndzLCBfLCByd3N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WNlKQogIEJOLnByb3RvdHlwZS5pbWFza24gPSBmdW5jdGlvbiBpbWFza24gKGJpdHMpIHsKICAgIGFzc2VydCh0eXBlb2YgYml0cyA9PT0gJ251bWJlcicgJiYgYml0cyA+PSAwKTsKICAgIHZhciByID0gYml0cyAlIDI2OwogICAgdmFyIHMgPSAoYml0cyAtIHIpIC8gMjY7CgogICAgYXNzZXJ0KHRoaXMubmVnYXRpdmUgPT09IDAsICdpbWFza24gd29ya3Mgb25seSB3aXRoIHBvc2l0aXZlIG51bWJlcnMnKTsKCiAgICBpZiAodGhpcy5sZW5ndGggPD0gcykgewogICAgICByZXR1cm4gdGhpczsKICAgIH0KCiAgICBpZiAociAhPT0gMCkgewogICAgICBzKys7CiAgICB9CiAgICB0aGlzLmxlbmd0aCA9IE1hdGgubWluKHMsIHRoaXMubGVuZ3RoKTsKCiAgICBpZiAociAhPT0gMCkgewogICAgICB2YXIgbWFzayA9IDB4M2ZmZmZmZiBeICgoMHgzZmZmZmZmID4+PiByKSA8PCByKTsKICAgICAgdGhpcy53b3Jkc1t0aGlzLmxlbmd0aCAtIDFdICY9IG1hc2s7CiAgICB9CgogICAgcmV0dXJuIHRoaXMuc3RyaXAoKTsKICB9OwoKICAvLyBSZXR1cm4gb25seSBsb3dlcnMgYml0cyBvZiBudW1iZXIKICBCTi5wcm90b3R5cGUubWFza24gPSBmdW5jdGlvbiBtYXNrbiAoYml0cykgewogICAgcmV0dXJuIHRoaXMuY2xvbmUoKS5pbWFza24oYml0cyk7CiAgfTsKCiAgLy8gQWRkIHBsYWluIG51bWJlciBgbnVtYCB0byBgdGhpc2AKICBCTi5wcm90b3R5cGUuaWFkZG4gPSBmdW5jdGlvbiBpYWRkbiAobnVtKSB7CiAgICBhc3NlcnQodHlwZW9mIG51bSA9PT0gJ251bWJlcicpOwogICAgYXNzZXJ0KG51bSA8IDB4NDAwMDAwMCk7CiAgICBpZiAobnVtIDwgMCkgcmV0dXJuIHRoaXMuaXN1Ym4oLW51bSk7C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ID0gMDsKICAgICAgfQogICAgfQoKICAgIHZhciBkaWZmID0gYS5jbG9uZSgpLl9pc2hsbnN1Ym11bChiLCAxLCBtKTsKICAgIGlmIChkaWZmLm5lZ2F0aXZlID09PSAwKSB7CiAgICAgIGEgPSBkaWZmOwogICAgICBpZiAocSkgewogICAgICAgIHEud29yZHNbbV0gPSAxOwogICAgICB9CiAgICB9CgogICAgZm9yICh2YXIgaiA9IG0gLSAxOyBqID49IDA7IGotLSkgewogICAgICB2YXIgcWogPSAoYS53b3Jkc1tiLmxlbmd0aCArIGpdIHwgMCkgKiAweDQwMDAwMDAgKwogICAgICAgIChhLndvcmRzW2IubGVuZ3RoICsgaiAtIDFdIHwgMCk7CgogICAgICAvLyBOT1RFOiAocWogLyBiaGkpIGlzICgweDNmZmZmZmYgKiAweDQwMDAwMDAgKyAweDNmZmZmZmYpIC8gMHgyMDAwMDAwIG1heAogICAgICAvLyAoMHg3ZmZmZmZmKQogICAgICBxaiA9IE1hdGgubWluKChxaiAvIGJoaSkgfCAwLCAweDNmZmZmZmYpOwoKICAgICAgYS5faXNobG5zdWJtdWwoYiwgcWosIGopOwogICAgICB3aGlsZSAoYS5uZWdhdGl2ZSAhPT0gMCkgewogICAgICAgIHFqLS07CiAgICAgICAgYS5uZWdhdGl2ZSA9IDA7CiAgICAgICAgYS5faXNobG5zdWJtdWwoYiwgMSwgaik7CiAgICAgICAgaWYgKCFhLmlzWmVybygpKSB7CiAgICAgICAgICBhLm5lZ2F0aXZlIF49IDE7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChxKSB7CiAgICAgICAgcS53b3Jkc1tqXSA9IHFqOwogICAgICB9CiAgICB9CiAgICBpZiAocSkgewogICAgICBxLnN0cmlwKCk7CiAgICB9CiAgICBhLnN0cmlwKCk7CgogICAgLy8gRGVub3JtYWxpemUKICAgIGlmIChtb2RlICE9PSAnZGl2JyAmJiBzaGlmdCAhPT0gMCkgewogICAgICBhLml1c2hybihzaGlmdCk7CiAgICB9CgogICAgcmV0dXJuIHsKICAgICAgZGl2OiBxIHx8IG51bGwsCiAgICAgIG1vZDogYQogICAgfTsKICB9OwoKICAvLyBOT1RFOiAxKSBgbW9kZWAgY2FuIGJlIHNldCB0byBgbW9kYCB0byByZXF1ZXN0IG1vZCBvbmx5LAogIC8vICAgICAgIHRvIGBkaXZgIHRvIHJlcXVlc3QgZGl2IG9ubHksIG9yIGJlIGFic2VudCB0bwogIC8vICAgICAgIHJlcXVlc3QgYm90aCBkaXYgJiBtb2QKICAvLyAgICAgICAyKSBgcG9zaXRpdmVgIGlzIHRydWUgaWYgdW5zaWduZWQgbW9kIGlzIHJlcXVlc3RlZAogIEJOLnByb3RvdHlwZS5kaXZtb2QgPSBmdW5jdGlvbiBkaXZtb2QgKG51bSwgbW9kZSwgcG9zaXRpdmUpIHsKICAgIGFzc2VydCghbnVtLmlzWmVybygpKTsKCiAgICBpZiAodGhpcy5pc1plcm8oKSkgewogICAgICByZXR1cm4gewogICAgICAgIGRpdjogbmV3IEJOKDApLAogICAgICAgIG1vZDogbmV3IEJOKDApCiAgICAgIH07CiAgICB9CgogICAgdmFyIGRpdiwgbW9kLCByZXM7CiAgICBpZiAodGhpcy5uZWdhdGl2ZSAhPT0gMCAmJiBudW0ubmVnYXRpdmUgPT09IDApIHsKICAgICAgcmVzID0gdGhpcy5uZWcoKS5kaXZtb2QobnVtLCBtb2RlKTsKCiAgICAgIGlmIChtb2RlICE9PSAnbW9kJykgewogICAgICAgIGRpdiA9IHJlcy5kaXYubmVnKCk7CiAgICAgIH0KCiAgICAgIGlmIChtb2RlICE9PSAnZGl2JykgewogICAgICAgIG1vZCA9IHJlcy5tb2QubmVnKCk7CiAgICAgICAgaWYgKHBvc2l0aXZlICYmIG1vZC5uZWdhdGl2ZSAhPT0gMCkgewogICAgICAgICAgbW9kLmlhZGQobnVtKTsKICAgICAgICB9CiAgICAgIH0KCiAgICAgIHJldHVybiB7CiAgICAgICAgZGl2OiBkaXYsCiAgICAgICAgbW9kOiB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lbmd0aCAtIDE7IGkgPj0gMDsgaS0tKSB7CiAgICAgIHZhciB3ID0gKHRoaXMud29yZHNbaV0gfCAwKSArIGNhcnJ5ICogMHg0MDAwMDAwOwogICAgICB0aGlzLndvcmRzW2ldID0gKHcgLyBudW0pIHwgMDsKICAgICAgY2FycnkgPSB3ICUgbnVtOwogICAgfQoKICAgIHJldHVybiB0aGlzLnN0cmlwKCk7CiAgfTsKCiAgQk4ucHJvdG90eXBlLmRpdm4gPSBmdW5jdGlvbiBkaXZuIChudW0pIHsKICAgIHJldHVybiB0aGlzLmNsb25lKCkuaWRpdm4obnVtKTsKICB9OwoKICBCTi5wcm90b3R5cGUuZWdjZCA9IGZ1bmN0aW9uIGVnY2QgKHApIHsKICAgIGFzc2VydChwLm5lZ2F0aXZlID09PSAwKTsKICAgIGFzc2VydCghcC5pc1plcm8oKSk7CgogICAgdmFyIHggPSB0aGlzOwogICAgdmFyIHkgPSBwLmNsb25lKCk7CgogICAgaWYgKHgubmVnYXRpdmUgIT09IDApIHsKICAgICAgeCA9IHgudW1vZChwKTsKICAgIH0gZWxzZSB7CiAgICAgIHggPSB4LmNsb25lKCk7CiAgICB9CgogICAgLy8gQSAqIHggKyBCICogeSA9IHgKICAgIHZhciBBID0gbmV3IEJOKDEpOwogICAgdmFyIEIgPSBuZXcgQk4oMCk7CgogICAgLy8gQyAqIHggKyBEICogeSA9IHkKICAgIHZhciBDID0gbmV3IEJOKDApOwogICAgdmFyIEQgPSBuZXcgQk4oMSk7CgogICAgdmFyIGcgPSAwOwoKICAgIHdoaWxlICh4LmlzRXZlbigpICYmIHkuaXNFdmVuKCkpIHsKICAgICAgeC5pdXNocm4oMSk7CiAgICAgIHkuaXVzaHJuKDEpOwogICAgICArK2c7CiAgICB9CgogICAgdmFyIHlwID0geS5jbG9uZSgpOwogICAgdmFyIHhwID0geC5jbG9uZSgpOwoKICAgIHdoaWxlICgheC5pc1plcm8oKSkgewogICAgICBmb3IgKHZhciBpID0gMCwgaW0gPSAxOyAoeC53b3Jkc1swXSAmIGltKSA9PT0gMCAmJiBpIDwgMjY7ICsraSwgaW0gPDw9IDEpOwogICAgICBpZiAoaSA+IDApIHsKICAgICAgICB4Lml1c2hybihpKTsKICAgICAgICB3aGlsZSAoaS0tID4gMCkgewogICAgICAgICAgaWYgKEEuaXNPZGQoKSB8fCBCLmlzT2RkKCkpIHsKICAgICAgICAgICAgQS5pYWRkKHlwKTsKICAgICAgICAgICAgQi5pc3ViKHhwKTsKICAgICAgICAgIH0KCiAgICAgICAgICBBLml1c2hybigxKTsKICAgICAgICAgIEIuaXVzaHJuKDEpOwogICAgICAgIH0KICAgICAgfQoKICAgICAgZm9yICh2YXIgaiA9IDAsIGptID0gMTsgKHkud29yZHNbMF0gJiBqbSkgPT09IDAgJiYgaiA8IDI2OyArK2osIGptIDw8PSAxKTsKICAgICAgaWYgKGogPiAwKSB7CiAgICAgICAgeS5pdXNocm4oaik7CiAgICAgICAgd2hpbGUgKGotLSA+IDApIHsKICAgICAgICAgIGlmIChDLmlzT2RkKCkgfHwgRC5pc09kZCgpKSB7CiAgICAgICAgICAgIEMuaWFkZCh5cCk7CiAgICAgICAgICAgIEQuaXN1Yih4cCk7CiAgICAgICAgICB9CgogICAgICAgICAgQy5pdXNocm4oMSk7CiAgICAgICAgICBELml1c2hybigxKTsKICAgICAgICB9CiAgICAgIH0KCiAgICAgIGlmICh4LmNtcCh5KSA+PSAwKSB7CiAgICAgICAgeC5pc3ViKHkpOwogICAgICAgIEEuaXN1YihDKTsKICAgICAgICBCLmlzdWIoRCk7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgeS5pc3ViKHgpOwogICAgICAgIEMuaXN1YihBKTsKICAgICAgICBELmlzdWIoQik7CiAgICAgIH0KICAgIH0KCiAgICByZXR1cm4gewogICAgICBhOiBDLAogICAgICBiOiBELAogICAgICBnY2Q6IHkuaXVzaGxuKGcpCiAgICB9OwogIH07CgogIC8vIFRoaXMgaXMgcmVkdWNlZCBpbmNhcm5hdGlvbiBvZiB0aGUgYmluYXJ5IEVFQQogIC8vIGFib3ZlLCBkZXNpZ25hdGVkIHRvIGludmVydCBtZW1iZXJzIG9mIHRoZQogIC8vIF9wcmltZV8gZmllbGRzIEYocCkgYXQgYSBtYXhpbWFsIHNwZWVkCiAgQk4ucHJvdG90eXBlLl9pbnZtcCA9IGZ1bmN0aW9uIF9pbnZtcCAocCkgewogICAgYXNzZXJ0KHAubmVnYXRpdmUgPT09IDApOwogICAgYXNzZXJ0KCFwLmlzWmVybygpKTsKCiAgICB2YXIgYSA9IHRoaXM7CiAgICB2YXIgYiA9IHAuY2xvbmUoKTsKCiAgICBpZiAoYS5uZWdhdGl2ZSAhPT0gMCkgewogICAgICBhID0gYS51bW9kKHApOwogICAgfSBlbHNlIHsKICAgICAgYSA9IGEuY2xvbmUoKTsKICAgIH0KCiAgICB2YXIgeDEgPSBuZXcgQk4oMSk7CiAgICB2YXIgeDIgPSBuZXcgQk4oMCk7CgogICAgdmFyIGRlbHRhID0gYi5jbG9uZSgpOwoKICAgIHdoaWxlIChhLmNtcG4oMSkgPiAwICYmIGIuY21wbigxKSA+IDApIHsKICAgICAgZm9yICh2YXIgaSA9IDAsIGltID0gMTsgKGEud29yZHNbMF0gJiBpbSkgPT09IDAgJiYgaSA8IDI2OyArK2ksIGltIDw8PSAxKTsKICAgICAgaWYgKGkgPiAwKSB7CiAgICAgICAgYS5pdXNocm4oaSk7CiAgICAgICAgd2hpbGUgKGktLSA+IDApIHsKICAgICAgICAgIGlmICh4MS5pc09kZCgpKSB7CiAgICAgICAgICAgIHgxLmlhZGQoZGVsdGEpOwogICAgICAgICAgfQoKICAgICAgICAgIHgxLml1c2hybigxKTsKICAgICAgICB9CiAgICAgIH0KCiAgICAgIGZvciAodmFyIGogPSAwLCBqbSA9IDE7IChiLndvcmRzWzBdICYgam0pID09PSAwICYmIGogPCAyNjsgKytqLCBqbSA8PD0gMSk7CiAgICAgIGlmIChqID4gMCkgewogICAgICAgIGIuaXVzaHJuKGopOwogICAgICAgIHdoaWxlIChqLS0gPiAwKSB7CiAgICAgICAgICBpZiAoeDIuaXNPZGQoKSkgewogICAgICAgICAgICB4Mi5pYWRkKGRlbHRhKTsKICAgICAgICAgIH0KCiAgICAgICAgICB4Mi5pdXNocm4oMSk7CiAgICAgICAgfQogICAgICB9CgogICAgICBpZiAoYS5jbXAoYikgPj0gMCkgewogICAgICAgIGEuaXN1YihiKTsKICAgICAgICB4MS5pc3ViKHgyKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBiLmlzdWIoYSk7CiAgICAgICAgeDIuaXN1Yih4MSk7CiAgICAgIH0KICAgIH0KCiAgICB2YXIgcmVzOwogICAgaWYgKGEuY21wbigxKSA9PT0gMCkgewogICAgICByZXMgPSB4MTsKICAgIH0gZWxzZSB7CiAgICAgIHJlcyA9IHgyOwogICAgfQoKICAgIGlmIChyZXMuY21wbigwKSA8IDApIHsKICAgICAgcmVzLmlhZGQocCk7CiAgICB9CgogICAgcmV0dXJuIHJlczsKICB9OwoKICBCTi5wcm90b3R5cGUuZ2NkID0gZnVuY3Rpb24gZ2NkIChudW0pIHsKICAgIGlmICh0aGlzLmlzWmVybygpKSByZXR1cm4gbnVtLmFicygpOwogICAgaWYgKG51bS5pc1plcm8oKSkgcmV0dXJuIHRoaXMuYWJzKCk7CgogICAgdmFyIGEgPSB0aGlzLmNsb25lKCk7CiAgICB2YXIgYiA9IG51bS5jbG9uZSgpOwogICAgYS5uZWdhdGl2ZSA9IDA7CiAgICBiLm5lZ2F0aXZlID0gMDsKCiAgICAvLyBSZW1vdmUgY29tbW9uIGZhY3RvciBvZiB0d28KICAgIGZvciAodmFyIHNoaWZ0ID0gMDsgYS5pc0V2ZW4oKSAmJiBiLmlzRXZlbigpOyBzaGlmdCsrKSB7CiAgICAgIGEuaXVzaHJuKDEpOwogICAgICBiLml1c2hybigxKTsKICAgIH0KCiAgICBkbyB7CiAgICAgIHdoaWxlIChhLmlzRXZlbigpKSB7CiAgICAgICAgYS5pdX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AgICAvLyBBc3N1bWVzIHRoYXQgYG51bWAgaXMgbGVzcyB0aGFuIGBQXjJgCiAgICAvLyBudW0gPSBISSAqICgyIF4gTiAtIEspICsgSEkgKiBLICsgTE8gPSBISSAqIEsgKyBMTyAobW9kIFApCiAgICB2YXIgciA9IG51bTsKICAgIHZhciBybGVuOwoKICAgIGRvIHsKICAgICAgdGhpcy5zcGxpdChyLCB0aGlzLnRtcCk7CiAgICAgIHIgPSB0aGlzLmltdWxLKHIpOwogICAgICByID0gci5pYWRkKHRoaXMudG1wKTsKICAgICAgcmxlbiA9IHIuYml0TGVuZ3RoKCk7CiAgICB9IHdoaWxlIChybGVuID4gdGhpcy5uKTsKCiAgICB2YXIgY21wID0gcmxlbiA8IHRoaXMubiA/IC0xIDogci51Y21wKHRoaXMucCk7CiAgICBpZiAoY21wID09PSAwKSB7CiAgICAgIHIud29yZHNbMF0gPSAwOwogICAgICByLmxlbmd0aCA9IDE7CiAgICB9IGVsc2UgaWYgKGNtcCA+IDApIHsKICAgICAgci5pc3ViKHRoaXMucCk7CiAgICB9IGVsc2UgewogICAgICByLnN0cmlwKCk7CiAgICB9CgogICAgcmV0dXJuIHI7CiAgfTsKCiAgTVByaW1lLnByb3RvdHlwZS5zcGxpdCA9IGZ1bmN0aW9uIHNwbGl0IChpbnB1dCwgb3V0KSB7CiAgICBpbnB1dC5pdXNocm4odGhpcy5uLCAwLCBvdXQpOwogIH07CgogIE1QcmltZS5wcm90b3R5cGUuaW11bEsgPSBmdW5jdGlvbiBpbXVsSyAobnVtKSB7CiAgICByZXR1cm4gbnVtLmltdWwodGhpcy5rKTsKICB9OwoKICBmdW5jdGlvbiBLMjU2ICgpIHsKICAgIE1QcmltZS5jYWxsKAogICAgICB0aGlzLAogICAgICAnazI1NicsCiAgICAgICdmZmZmZmZmZiBmZmZmZmZmZiBmZmZmZmZmZiBmZmZmZmZmZiBmZmZmZmZmZiBmZmZmZmZmZiBmZmZmZmZmZSBmZmZmZmMyZicpOwogIH0KIC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Gh5cG90aGVzaXMuCiAgICB2YXIgbHBvdyA9IHRoaXMubS5zdWJuKDEpLml1c2hybigxKTsKICAgIHZhciB6ID0gdGhpcy5tLmJpdExlbmd0aCgpOwogICAgeiA9IG5ldyBCTigyICogeiAqIHopLnRvUmVkKHRoaXMpOwoKICAgIHdoaWxlICh0aGlzLnBvdyh6LCBscG93KS5jbXAobk9uZSkgIT09IDApIHsKICAgICAgei5yZWRJQWRkKG5PbmUpOwogICAgfQoKICAgIHZhciBjID0gdGhpcy5wb3coeiwgcSk7CiAgICB2YXIgciA9IHRoaXMucG93KGEsIHEuYWRkbigxKS5pdXNocm4oMSkpOwogICAgdmFyIHQgPSB0aGlzLnBvdyhhLCBxKTsKICAgIHZhciBtID0gczsKICAgIHdoaWxlICh0LmNtcChvbmUpICE9PSAwKSB7CiAgICAgIHZhciB0bXAgPSB0OwogICAgICBmb3IgKHZhciBpID0gMDsgdG1wLmNtcChvbmUpICE9PSAwOyBpKyspIHsKICAgICAgICB0bXAgPSB0bXAucmVkU3FyKCk7CiAgICAgIH0KICAgICAgYXNzZXJ0KGkgPCBtKTsKICAgICAgdmFyIGIgPSB0aGlzLnBvdyhjLCBuZXcgQk4oMSkuaXVzaGxuKG0gLSBpIC0gMSkpOwoKICAgICAgciA9IHIucmVkTXVsKGIpOwogICAgICBjID0gYi5yZWRTcXIoKTsKICAgICAgdCA9IHQucmVkTXVsKGMpOwogICAgICBtID0gaTsKICAgIH0KCiAgICByZXR1cm4gcjsKICB9OwoKICBSZWQucHJvdG90eXBlLmludm0gPSBmdW5jdGlvbiBpbnZtIChhKSB7CiAgICB2YXIgaW52ID0gYS5faW52bXAodGhpcy5tKTsKICAgIGlmIChpbnYubmVnYXRpdmUgIT09IDApIHsKICAgICAgaW52Lm5lZ2F0aXZlID0gMDsKICAgICAgcmV0dXJuIHRoaXMuaW1vZChpbnYpLnJlZE5lZygpOwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuIHRoaXMuaW1vZChpbnYpOwogICAgfQogIH07CgogIFJlZC5wcm90b3R5cGUucG93ID0gZnVuY3Rpb24gcG93IChhLCBudW0pIHsKICAgIGlmIChudW0uaXNaZXJvKCkpIHJldHVybiBuZXcgQk4oMSkudG9SZWQodGhpcyk7CiAgICBpZiAobnVtLmNtcG4oMSkgPT09IDApIHJldHVybiBhLmNsb25lKCk7CgogICAgdmFyIHdpbmRvd1NpemUgPSA0OwogICAgdmFyIHduZCA9IG5ldyBBcnJheSgxIDw8IHdpbmRvd1NpemUpOwogICAgd25kWzBdID0gbmV3IEJOKDEpLnRvUmVkKHRoaXMpOwogICAgd25kWzFdID0gYTsKICAgIGZvciAodmFyIGkgPSAyOyBpIDwgd25kLmxlbmd0aDsgaSsrKSB7CiAgICAgIHduZFtpXSA9IHRoaXMubXVsKHduZFtpIC0gMV0sIGEpOwogICAgfQoKICAgIHZhciByZXMgPSB3bmRbMF07CiAgICB2YXIgY3VycmVudCA9IDA7CiAgICB2YXIgY3VycmVudExlbiA9IDA7CiAgICB2YXIgc3RhcnQgPSBudW0uYml0TGVuZ3RoKCkgJSAyNjsKICAgIGlmIChzdGFydCA9PT0gMCkgewogICAgICBzdGFydCA9IDI2OwogICAgfQoKICAgIGZvciAoaSA9IG51bS5sZW5ndGggLSAxOyBpID49IDA7IGktLSkgewogICAgICB2YXIgd29yZCA9IG51bS53b3Jkc1tpXTsKICAgICAgZm9yICh2YXIgaiA9IHN0YXJ0IC0gMTsgaiA+PSAwOyBqLS0pIHsKICAgICAgICB2YXIgYml0ID0gKHdvcmQgPj4gaikgJiAxOwogICAgICAgIGlmIChyZXMgIT09IHduZFswXSkgewogICAgICAgICAgcmVzID0gdGhpcy5zcXIocmVzKTsKICAgICAgICB9CgogICAgICAgIGlmIChiaXQgPT09IDAgJiYgY3VycmVudCA9PT0gMCkgewogICAgICAgICAgY3VycmVudExlbiA9IDA7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CgogICAgICAgIGN1cnJlbnQgPDw9IDE7CiAgICAgICA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cy5yMiA9IHRoaXMuaW1vZCh0aGlzLnIuc3FyKCkpOwogICAgdGhpcy5yaW52ID0gdGhpcy5yLl9pbnZtcCh0aGlzLm0pOwoKICAgIHRoaXMubWludiA9IHRoaXMucmludi5tdWwodGhpcy5yKS5pc3VibigxKS5kaXYodGhpcy5tKTsKICAgIHRoaXMubWludiA9IHRoaXMubWludi51bW9kKHRoaXMucik7CiAgICB0aGlzLm1pbnYgPSB0aGlzLnIuc3ViKHRoaXMubWludik7CiAgfQogIGluaGVyaXRzKE1vbnQsIFJlZCk7CgogIE1vbnQucHJvdG90eXBlLmNvbnZlcnRUbyA9IGZ1bmN0aW9uIGNvbnZlcnRUbyAobnVtKSB7CiAgICByZXR1cm4gdGhpcy5pbW9kKG51bS51c2hsbih0aGlzLnNoaWZ0KSk7CiAgfTsKCiAgTW9udC5wcm90b3R5cGUuY29udmVydEZyb20gPSBmdW5jdGlvbiBjb252ZXJ0RnJvbSAobnVtKSB7CiAgICB2YXIgciA9IHRoaXMuaW1vZChudW0ubXVsKHRoaXMucmludikpOwogICAgci5yZWQgPSBudWxsOwogICAgcmV0dXJuIHI7CiAgfTsKCiAgTW9udC5wcm90b3R5cGUuaW11bCA9IGZ1bmN0aW9uIGltdWwgKGEsIGIpIHsKICAgIGlmIChhLmlzWmVybygpIHx8IGIuaXNaZXJvKCkpIHsKICAgICAgYS53b3Jkc1swXSA9IDA7CiAgICAgIGEubGVuZ3RoID0gMTsKICAgICAgcmV0dXJuIGE7CiAgICB9CgogICAgdmFyIHQgPSBhLmltdWwoYik7CiAgICB2YXIgYyA9IHQubWFza24odGhpcy5zaGlmdCkubXVsKHRoaXMubWludikuaW1hc2tuKHRoaXMuc2hpZnQpLm11bCh0aGlzLm0pOwogICAgdmFyIHUgPSB0LmlzdWIoYykuaXVzaHJuKHRoaXMuc2hpZnQpOwogICAgdmFyIHJlcyA9IHU7CgogICAgaWYgKHUuY21wKHRoaXMubSkgPj0gMCkgewogICAgICByZXMgPSB1LmlzdWI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oLyohIC4vLi4vLi4vd2VicGFjay9idWlsZGluL21vZHVsZS5qcyAqLyAiLi9ub2RlX21vZHVsZXMvd2VicGFjay9idWlsZGluL21vZHVsZS5qcyIpKG1vZHVsZSkpKQoKLyoqKi8gfSksCgovKioqLyAiLi9ub2RlX21vZHVsZXMvYm94LWludGVyc2VjdC9pbmRleC5qcyI6Ci8qISoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvYm94LWludGVyc2VjdC9pbmRleC5qcyAqKiohCiAgXCoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohIG5vIHN0YXRpYyBleHBvcnRzIGZvdW5kICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIGV4cG9ydHMsIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKCgptb2R1bGUuZXhwb3J0cyA9IGJveEludGVyc2VjdFdyYXBwZXIKCnZhciBwb29sID0gX193ZWJwYWNrX3JlcXVpcmVfXygvKiEgdHlwZWRhcnJheS1wb29sICovICIuL25vZGVfbW9kdWxlcy90eXBlZGFycmF5LXBvb2wvcG9vbC5qcyIpCnZhciBzd2VlcCA9IF9fd2VicGFja19yZXF1aXJlX18oLyohIC4vbGliL3N3ZWVwICovICIuL25vZGVfbW9kdWxlcy9ib3gtaW50ZXJzZWN0L2xpYi9zd2VlcC5qcyIpCnZhciBib3hJbnRlcnNlY3RJdGVyID0gX193ZWJwYWNrX3JlcXVpcmVfXygvKiEgLi9saWIvaW50ZXJzZWN0ICovICIuL25vZGVfbW9kdWxlcy9ib3gtaW50ZXJzZWN0L2xpYi9pbnRlcnNlY3QuanMiKQoKZnVuY3Rpb24gYm94RW1wdHkoZCwgYm94KSB7CiAgZm9yKHZhciBqPTA7IGo8ZDsgKytqKSB7CiAgICBpZighKGJveFtqXSA8PSBib3hbaitkXSkpIHsKICAgICAgcmV0d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xvY0ludDMyKG4pCiAgbiA9IGNvbnZlcnRCb3hlcyhyZWQsIGQsIHJlZExpc3QsIHJlZElkcykKCiAgaWYobiA+IDApIHsKICAgIGlmKGQgPT09IDEgJiYgZnVsbCkgewogICAgICAvL1NwZWNpYWwgY2FzZTogMWQgY29tcGxldGUKICAgICAgc3dlZXAuaW5pdChuKQogICAgICByZXR2YWwgPSBzd2VlcC5zd2VlcENvbXBsZXRlKAogICAgICAgIGQsIHZpc2l0LCAKICAgICAgICAwLCBuLCByZWRMaXN0LCByZWRJZHMsCiAgICAgICAgMCwgbiwgcmVkTGlzdCwgcmVkSWRzKQogICAgfSBlbHNlIHsKCiAgICAgIC8vQ29udmVydCBibHVlIGJveGVzCiAgICAgIHZhciBibHVlTGlzdCA9IHBvb2wubWFsbG9jRG91YmxlKDIqZCptKQogICAgICB2YXIgYmx1ZUlkcyAgPSBwb29sLm1hbGxvY0ludDMyKG0pCiAgICAgIG0gPSBjb252ZXJ0Qm94ZXMoYmx1ZSwgZCwgYmx1ZUxpc3QsIGJsdWVJZHMpCgogICAgICBpZihtID4gMCkgewogICAgICAgIHN3ZWVwLmluaXQobittKQoKICAgICAgICBpZihkID09PSAxKSB7CiAgICAgICAgICAvL1NwZWNpYWwgY2FzZTogMWQgYmlwYXJ0aXRlCiAgICAgICAgICByZXR2YWwgPSBzd2VlcC5zd2VlcEJpcGFydGl0ZSgKICAgICAgICAgICAgZCwgdmlzaXQsIAogICAgICAgICAgICAwLCBuLCByZWRMaXN0LCAgcmVkSWRzLAogICAgICAgICAgICAwLCBtLCBibHVlTGlzdCwgYmx1ZUlkcykKICAgICAgICB9IGVsc2UgewogICAgICAgICAgLy9HZW5lcmFsIGNhc2U6ICBkPjEKICAgICAgICAgIHJldHZhbCA9IGJveEludGVyc2VjdEl0ZXIoCiAgICAgICAgICAgIGQsIHZpc2l0LCAgICBmdWxsLAogICAgICAgICAgICBuLCByZWRMaXN0LCAgcmVkSWRzLAogICAgICAgICAgICBtLCBibHVlT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ICAgICAgfQogICAgY2FzZSAzOgogICAgICByZXR1cm4gYm94SW50ZXJzZWN0KGFyZzAsIGFyZzEsIGFyZzIsIGZhbHNlKQogICAgZGVmYXVsdDoKICAgICAgdGhyb3cgbmV3IEVycm9yKCdib3gtaW50ZXJzZWN0OiBJbnZhbGlkIGFyZ3VtZW50cycpCiAgfQp9CgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9ib3gtaW50ZXJzZWN0L2xpYi9icnV0ZS5qcyI6Ci8qISoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2JveC1pbnRlcnNlY3QvbGliL2JydXRlLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohIG5vIHN0YXRpYyBleHBvcnRzIGZvdW5kICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIGV4cG9ydHMsIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKCgp2YXIgRElNRU5TSU9OICAgPSAnZCcKdmFyIEFYSVMgICAgICAgID0gJ2F4Jwp2YXIgVklTSVQgICAgICAgPSAndnYnCnZhciBGTElQICAgICAgICA9ICdmcCcKCnZhciBFTEVNX1NJWkUgICA9ICdlcycKCnZhciBSRURfU1RBUlQgICA9ICdycycKdmFyIFJFRF9FTkQgICAgID0gJ3JlJwp2YXIgUkVEX0JPWEVTICAgPSAncmInCnZhciBSRURfSU5ERVggICA9ICdyaScKdmFyIFJFRF9QVFIgICAgID0gJ3JwJwoKdmFyIEJMVUVfU1RBUlQgID0gJ2JzJwp2YXIgQkxVRV9FTkQgICAgPSAnYmUnCnZhciBCTFVFX0JPWEVTICA9ICdiYicKdmFyIEJMVUVfSU5ERVggID0gJ2JpJwp2YXIgQkxVRV9QVFIgICAgPSAnYnAnCgp2YXIgUkVUVkFMICAgICAgPSAncnYnCgp2YXIgSU5ORVJfTEFCRUwgPSAnUScKCnZhciBBUkdTID0gWwogIERJTUVOU0lPTiwKICBBWElTLAogIFZJU0lULAogIFJFRF9TVEFSVCwKICBSRURfRU5ELAogIFJFRF9CT1hFUywKICBSRURfSU5ERVgsCiAgQkxVRV9TVEFSVCwKICBCTFVFX0VORCwKICBCTFVFX0JPWEVTLAogIEJMVUVfSU5ERVgKXQoKZnVuY3Rpb24gZ2VuZXJhdGVCcnV0ZUZvcmNlKHJlZE1ham9yLCBmbGlwLCBmdWxsKSB7CiAgdmFyIGZ1bmNOYW1lID0gJ2JydXRlRm9yY2UnICsgCiAgICAocmVkTWFqb3IgPyAnUmVkJyA6ICdCbHVlJykgKyAKICAgIChmbGlwID8gJ0ZsaXAnIDogJycpICsKICAgIChmdWxsID8gJ0Z1bGwnIDogJycpCgogIHZhciBjb2RlID0gWydmdW5jdGlvbiAnLCBmdW5jTmFtZSwgJygnLCBBUkdTLmpvaW4oKSwgJyl7JywKICAgICd2YXIgJywgRUxFTV9TSVpFLCAnPTIqJywgRElNRU5TSU9OLCAnOyddCgogIHZhciByZWRMb29wID0gCiAgICAnZm9yKHZhciBpPScgKyBSRURfU1RBUlQgKyAnLCcgKyBSRURfUFRSICsgJz0nICsgRUxFTV9TSVpFICsgJyonICsgUkVEX1NUQVJUICsgJzsnICsKICAgICAgICAnaTwnICsgUkVEX0VORCArJzsnICsKICAgICAgICAnKytpLCcgKyBSRURfUFRSICsgJys9JyArIEVMRU1fU0laRSArICcpeycgKwogICAgICAgICd2YXIgeDA9JyArIFJFRF9CT1hFUyArICdbJyArIEFYSVMgKyAnKycgKyBSRURfUFRSICsgJ10sJyArCiAgICAgICAgICAgICd4MT0nICsgUkVEX0JPWEVTICsgJ1snICsgQVhJUyArICcrJyArIFJFRF9QVFIgKyAnKycgKyBESU1FTlNJT04gKyAnXSwnICsKICAgICAgICAgICAgJ3hpPScgKyBSRURfSU5ERVggKyAnW2ldOycKCiAgdmFyIGJsdWVMb29wID0gCiAgICAnZm9yKHZhciBqPScgKyBCTFVFX1NUQVJUICsgJywnICsgQkxVRV9QVFIgKyAnPScgKyBFTEVNX1NJWkUgKyAnKicgKyBCTFVFX1NUQVJUICsgJzsnICsKICAgICAgICAnajwnICsgQkxVRV9FTkQgKyAnOycgKwogICAgICAgICcrK2osJyArIEJMVUVfUFRSICsgJys9JyArIEVMRU1fU0laRSArICcpeycgKwogICAgICAgICd2YXIgeTA9JyArIEJMVUVfQk9YRVMgKyAnWycgKyBBWElTICsgJysnICsgQkxVRV9QVFIgKyAnXSwnICsKICAgICAgICAgICAgKGZ1bGwgPyAneTE9JyArIEJMVUVfQk9YRVMgKyAnWycgKyBBWElTICsgJysnICsgQkxVRV9QVFIgKyAnKycgKyBESU1FTlNJT04gKyAnXSwnIDogJycpICsKICAgICAgICAgICAgJ3lpPScgKyBCTFVFX0lOREVYICsgJ1tqXTsnCgogIGlmKHJlZE1ham9yKSB7CiAgICBjb2RlLnB1c2gocmVkTG9vcCwgSU5ORVJfTEFCRUwsICc6JywgYmx1ZUxvb3ApCiAgfSBlbHNlIHsKICAgIGNvZGUucHVzaChibHVlTG9vcCwgSU5ORVJfTEFCRUwsICc6JywgcmVkTG9vcCkKICB9CgogIGlmKGZ1bGwpIHsKICAgIGNvZGUucHVzaCgnaWYoeTE8eDB8fHgxPHkwKWNvbnRpbnVlOycpCiAgfSBlbHNlIGlmKGZsaXApIHsKICAgIGNvZGUucHVzaCgnaWYoeTA8PXgwfHx4MTx5MCljb250aW51ZTsnKQogIH0gZWxzZSB7CiAgICBjb2RlLnB1c2goJ2lmKHkwPHgwfHx4MTx5MCljb250aW51ZTsnKQogIH0KCiAgY29kZS5wdXNoKCdmb3IodmFyIGs9JytBWElTKycrMTtrPCcrRElNRU5TSU9OKyc7KytrKXsnKwogICAgJ3ZhciByMD0nK1JFRF9CT1hFUysnW2srJytSRURfUFRSKyddLCcrCiAgICAgICAgJ3IxPScrUkVEX0JPWEVTKydbaysnK0RJTUVOU0l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cmVzLm5hbWUgKyAnKCcgKyBBUkdTLmpvaW4oKSArICcpOycpCiAgfQoKICBjb2RlLnB1c2goJ2lmKCcgKyBSRURfRU5EICsgJy0nICsgUkVEX1NUQVJUICsgJz4nICsKICAgICAgICAgICAgICAgICAgICBCTFVFX0VORCArICctJyArIEJMVUVfU1RBUlQgKyAnKXsnKQoKICBpZihmdWxsKSB7CiAgICBpbnZva2UodHJ1ZSwgZmFsc2UpCiAgICBjb2RlLnB1c2goJ31lbHNleycpCiAgICBpbnZva2UoZmFsc2UsIGZhbHNlKQogIH0gZWxzZSB7CiAgICBjb2RlLnB1c2goJ2lmKCcgKyBGTElQICsgJyl7JykKICAgIGludm9rZSh0cnVlLCB0cnVlKQogICAgY29kZS5wdXNoKCd9ZWxzZXsnKQogICAgaW52b2tlKHRydWUsIGZhbHNlKQogICAgY29kZS5wdXNoKCd9fWVsc2V7aWYoJyArIEZMSVAgKyAnKXsnKQogICAgaW52b2tlKGZhbHNlLCB0cnVlKQogICAgY29kZS5wdXNoKCd9ZWxzZXsnKQogICAgaW52b2tlKGZhbHNlLCBmYWxzZSkKICAgIGNvZGUucHVzaCgnfScpCiAgfQogIGNvZGUucHVzaCgnfX1yZXR1cm4gJyArIGZ1bmNOYW1lKQoKICB2YXIgY29kZVN0ciA9IHByZWZpeC5qb2luKCcnKSArIGNvZGUuam9pbignJykKICB2YXIgcHJvYyA9IG5ldyBGdW5jdGlvbihjb2RlU3RyKQogIHJldHVybiBwcm9jKCkKfQoKCmV4cG9ydHMucGFydGlhbCA9IGJydXRlRm9yY2VQbGFubmVyKGZhbHNlKQpleHBvcnRzLmZ1bGwgICAgPSBicnV0ZUZvcmNlUGxhbm5lcih0cnVlKQoKLyoqKi8gfSksCgovKioqLyAiLi9ub2RlX21vZHVsZXMvYm94LWludGVyc2VjdC9saWIvaW50ZXJzZWN0LmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhK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GlzXQogICAgdmFyIHIxID0gcmVkW3JlZFB0citheGlzK2RdCiAgICBpZihibHVlWCA8IHIwIHx8IHIxIDwgYmx1ZVgpIHsKICAgICAgY29udGludWUKICAgIH0KICAgIGZvcih2YXIgaj1heGlzKzE7IGo8ZDsgKytqKSB7CiAgICAgIHZhciByMCA9IHJlZFtyZWRQdHIral0KICAgICAgdmFyIHIxID0gcmVkW3JlZFB0citqK2RdCiAgICAgIHZhciBiMCA9IGJsdWVbYmx1ZVB0citqXQogICAgICB2YXIgYjEgPSBibHVlW2JsdWVQdHIraitkXQogICAgICBpZihyMSA8IGIwIHx8IGIxIDwgcjApIHsKICAgICAgICBjb250aW51ZSByZWRfbG9vcAogICAgICB9CiAgICB9CiAgICB2YXIgcmV0dmFsID0gdmlzaXQocmVkSWQsIGJsdWVJZCkKICAgIGlmKHJldHZhbCAhPT0gdm9pZCAwKSB7CiAgICAgIHJldHVybiByZXR2YWwKICAgIH0KICB9Cn0KCi8vVGhlIG1haW4gYm94IGludGVyc2VjdGlvbiByb3V0aW5lCmZ1bmN0aW9uIGJveEludGVyc2VjdEl0ZXIoCiAgZCwgdmlzaXQsIGluaXRGdWxsLAogIHhTaXplLCB4Qm94ZXMsIHhJbmRleCwKICB5U2l6ZSwgeUJveGVzLCB5SW5kZXgpIHsKCiAgLy9SZXNlcnZlIG1lbW9yeSBmb3Igc3RhY2sKICBpdGVySW5pdChkLCB4U2l6ZSArIHlTaXplKQoKICB2YXIgdG9wICA9IDAKICB2YXIgZWxlbVNpemUgPSAyICogZAogIHZhciByZXR2YWwKCiAgaXRlclB1c2godG9wKyssCiAgICAgIDAsCiAgICAgIDAsIHhTaXplLAogICAgICAwLCB5U2l6ZSwKICAgICAgaW5pdEZ1bGwgPyAxNiA6IDAsIAogICAgICAtSW5maW5pdHksIEluZmluaXR5KQogIGlmKCFpbml0RnVsbCkgewogICAgaXRlclB1c2godG9wKyssCiAgICAgIDAsCiAgICAgIDAsIHlTaXplLAogICAgICAwLCB4U2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9GRikgewogICAgICAgIC8vSWYgaW5wdXQgc21hbGwsIHRoZW4gdXNlIGJydXRlIGZvcmNlCiAgICAgICAgcmV0dmFsID0gYnJ1dGVGb3JjZVBhcnRpYWwoCiAgICAgICAgICAgIGQsIGF4aXMsIHZpc2l0LCBmbGlwLAogICAgICAgICAgICByZWRTdGFydCwgIHJlZEVuZCwgIHJlZCwgIHJlZEluZGV4LAogICAgICAgICAgICBibHVlU3RhcnQsIGJsdWVFbmQsIGJsdWUsIGJsdWVJbmRleCkKICAgICAgICBpZihyZXR2YWwgIT09IHZvaWQgMCkgewogICAgICAgICAgcmV0dXJuIHJldHZhbAogICAgICAgIH0KICAgICAgICBjb250aW51ZQogICAgICB9IGVsc2UgaWYoZCAqIHJlZENvdW50ICogYmx1ZUNvdW50IDwgU0NBTl9DVVRPRkYpIHsKICAgICAgICAvL0lmIGlucHV0IG1lZGl1bSBzaXplZCwgdGhlbiB1c2Ugc3dlZXAgYW5kIHBydW5lCiAgICAgICAgcmV0dmFsID0gc3dlZXAuc2NhbkJpcGFydGl0ZSgKICAgICAgICAgIGQsIGF4aXMsIHZpc2l0LCBmbGlwLCAKICAgICAgICAgIHJlZFN0YXJ0LCByZWRFbmQsIHJlZCwgcmVkSW5kZXgsCiAgICAgICAgICBibHVlU3RhcnQsIGJsdWVFbmQsIGJsdWUsIGJsdWVJbmRleCkKICAgICAgICBpZihyZXR2YWwgIT09IHZvaWQgMCkgewogICAgICAgICAgcmV0dXJuIHJldHZhbAogICAgICAgIH0KICAgICAgICBjb250aW51ZQogICAgICB9CiAgICB9CiAgICAKICAgIC8vRmlyc3QsIGZpbmQgYWxsIHJlZCBpbnRlcnZhbHMgd2hvc2UgaW50ZXJpb3IgY29udGFpbnMgKGxvLGhpKQogICAgdmFyIHJlZDAgPSBwYXJ0aXRpb25JbnRlcmlvckNvbnRhaW5zSW50ZXJ2YWwoCiAgICAgIGQsIGF4aXMsIAogICAgICByZWRTdGFydCwgcmVkRW5kLCByZWQsIHJlZEluZGV4LAogICAgICBsbywgaGkpCgogICAgLy9Mb3dlciBkaW1lbnNpb25hbCBjYXNlCiAgICBpZihyZWRTdGFydCA8IHJlZDApIHsKCiAgICAgIGlmKGQgKiAocmVkMCAtIHJlZFN0YXJ0KSA8IEJSVVRFX0ZPUkNFX0NVVE9GRikgewogICAgICAgIC8vU3BlY2lhbCBjYXNlIGZvciBzbWFsbCBpbnB1dHM6IHVzZSBicnV0ZSBmb3JjZQogICAgICAgIHJldHZhbCA9IGJydXRlRm9yY2VGdWxsKAogICAgICAgICAgZCwgYXhpcysxLCB2aXNpdCwKICAgICAgICAgIHJlZFN0YXJ0LCByZWQwLCByZWQsIHJlZEluZGV4LAogICAgICAgICAgYmx1ZVN0YXJ0LCBibHVlRW5kLCBibHVlLCBibHVlSW5kZXgpCiAgICAgICAgaWYocmV0dmFsICE9PSB2b2lkIDApIHsKICAgICAgICAgIHJldHVybiByZXR2YWwKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZihheGlzID09PSBkLTIpIHsKICAgICAgICBpZihmbGlwKSB7CiAgICAgICAgICByZXR2YWwgPSBzd2VlcC5zd2VlcEJpcGFydGl0ZSgKICAgICAgICAgICAgZCwgdmlzaXQsCiAgICAgICAgICAgIGJsdWVTdGFydCwgYmx1ZUVuZCwgYmx1ZSwgYmx1ZUluZGV4LAogICAgICAgICAgICByZWRTdGFydCwgcmVkMCwgcmVkLCByZWRJbmRleCkKICAgICAgICB9IGVsc2UgewogICAgICAgICAgcmV0dmFsID0gc3dlZXAuc3dlZXBCaXBhcnRpdGUoCiAgICAgICAgICAgIGQsIHZpc2l0LAogICAgICAgICAgICByZWRTdGFydCwgcmVkMCwgcmVkLCByZWRJbmRleCwKICAgICAgICAgICAgYmx1ZVN0YXJ0LCBibHVlRW5kLCBibHVlLCBibHVlSW5kZXgpCiAgICAgICAgfQogICAgICAgIGlmKHJldHZhbCAhPT0gdm9pZCAwKSB7CiAgICAgICAgICByZXR1cm4gcmV0dmFsCiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGl0ZXJQdXNoKHRvcCsrLAogICAgICAgICAgYXhpcysxLAogICAgICAgICAgcmVkU3RhcnQsIHJlZDAsCiAgICAgICAgICBibHVlU3RhcnQsIGJsdWVFbmQsCiAgICAgICAgICBmbGlwLAogICAgICAgICAgLUluZmluaXR5LCBJbmZpbml0eSkKICAgICAgICBpdGVyUHVzaCh0b3ArKywKICAgICAgICAgIGF4aXMrMSwKICAgICAgICAgIGJsdWVTdGFydCwgYmx1ZUVuZCwKICAgICAgICAgIHJlZFN0YXJ0LCByZWQwLAogICAgICAgICAgZmxpcF4xLAogICAgICAgICAgLUluZmluaXR5LCBJbmZpbml0eSkKICAgICAgfQogICAgfQoKICAgIC8vRGl2aWRlIGFuZCBjb25xdWVyIHBoYXNlCiAgICBpZihyZWQwIDwgcmVkRW5kKSB7CgogICAgICAvL0N1dCBibHVlIGludG8gMyBwYXJ0czoKICAgICAgLy8KICAgICAgLy8gIFBvaW50cyA8IG1pZCBwb2ludAogICAgICAvLyAgUG9pbnRzID0gbWlkIHBvaW50CiAgICAgIC8vICBQb2ludHMgPiBtaWQgcG9pbnQKICAgICAgLy8KICAgICAgdmFyIGJsdWUwID0gZmluZE1lZGlhbigKICAgICAgICBkLCBheGlzLCAKICAgICAgICBibHVlU3RhcnQsIGJsdWVFbmQsIGJsdWUsIGJsdWVJbmRleCkKICAgICAgdmFyIG1pZCA9IGJsdWVbZWxlbVNpemUgKiBibHVlMCArIGF4aXNdCiAgICAgIHZhciBibHVlMSA9IHBhcnRpdGlvblN0YXJ0RXF1YWwoCiAgICAgICAgZCwgYXhpcywKICAgICAgICBibHVlMCwgYmx1ZUVuZCwgYmx1ZSwgYmx1ZUluZGV4LAogICAgICAgIG1pZCkKCiAgICAgIC8vUmlnaHQgY2FzZQogICAgICBpZihibHVlMSA8IGJsdWVFbmQpIHsKICAgICAgICBpdGVyUHVzaCh0b3ArKywKICAgICAgICAgIGF4aXMsCiAgICAgICAgICByZWQwLCByZWRFbmQsCiAgICAgICAgICBibHVlMSwgYmx1ZUVuZCwKICAgICAgICAgIChmbGlwfDQpICsgKGZ1bGwgPyAxNiA6IDApLAogICAgICAgICAgbWlkLCBoaSkKICAgICAgfQoKICAgICAgLy9MZWZ0IGNhc2UKICAgICAgaWYoYmx1ZVN0YXJ0IDwgYmx1ZTApIHsKICAgICAgICBpdGVyUHVzaCh0b3ArKywKICAgICAgICAgIGF4aXMsCiAgICAgICAgICByZWQwLCByZWRFbmQsCiAgICAgICAgICBibHVlU3RhcnQsIGJsdWUwLAogICAgICAgICAgKGZsaXB8MikgKyAoZnVsbCA/IDE2IDogMCksCiAgICAgICAgICBsbywgbWlkKQogICAgICB9CgogICAgICAvL0NlbnRlciBjYXNlICh0aGUgaGFyZCBwYXJ0KQogICAgICBpZihibHVlMCArIDEgPT09IGJsdWUxKSB7CiAgICAgICAgLy9PcHRpbWl6YXRpb246IFJhbmdlIHdpdGggZXhhY3RseSAxIHBvaW50LCB1c2UgYSBicnV0ZSBmb3JjZSBzY2FuCiAgICAgICAgaWYoZnVsbCkgewogICAgICAgICAgcmV0dmFsID0gb25lUG9pbnRGdWxsKAogICAgICAgICAgICBkLCBheGlzLCB2aXNpdCwKICAgICAgICAgICAgcmVkMCwgcmVkRW5kLCByZWQsIHJlZEluZGV4LAogICAgICAgICAgICBibHVlMCwgYmx1ZSwgYmx1ZUluZGV4W2JsdWUwXSkKICAgICAgICB9IGVsc2UgewogICAgICAgICAgcmV0dmFsID0gb25lUG9pbnRQYXJ0aWFsKAogICAgICAgICAgICBkLCBheGlzLCB2aXNpdCwgZmxpcCwKICAgICAgICAgICAgcmVkMCwgcmVkRW5kLCByZWQsIHJlZEluZGV4LAogICAgICAgICAgICBibHVlMCwgYmx1ZSwgYmx1ZUluZGV4W2JsdWUwXSkKICAgICAgICB9CiAgICAgICAgaWYocmV0dmFsICE9PSB2b2lkIDApIHsKICAgICAgICAgIHJldHVybiByZXR2YWwKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZihibHVlMCA8IGJsdWUxKSB7CiAgICAgICAgdmFyIHJlZDEKICAgICAgICBpZihmdWxsKSB7CiAgICAgICAgICAvL0lmIGZ1bGwgaW50ZXJzZWN0aW9uLCBuZWVkIHRvIGhhbmRsZSBzcGVjaWFsIGNhc2UKICAgICAgICAgIHJlZDEgPSBwYXJ0aXRpb25Db250YWluc1BvaW50KAogICAgICAgICAgICBkLCBheGlzLAogICAgICAgICAgICByZWQwLCByZWRFbmQsIHJlZCwgcmVkSW5kZXgsCiAgICAgICAgICAgIG1pZCkKICAgICAgICAgIGlmKHJlZDAgPCByZWQxKSB7CiAgICAgICAgICAgIHZhciByZWRYID0gcGFydGl0aW9uU3RhcnRFcXVhbCgKICAgICAgICAgICAgICBkLCBheGlzLAogICAgICAgICAgICAgIHJlZDAsIHJlZDEsIHJlZCwgcmVkSW5kZXgsCiAgICAgICAgICAgICAgbWlkKQogICAgICAgICAgICBpZihheGlzID09PSBkLTIpIHsKICAgICAgICAgICAgICAvL0RlZ2VuZXJhdGUgc3dlZXAgaW50ZXJzZWN0aW9uOgogICAgICAgICAgICAgIC8vICBbcmVkMCwgcmVkWF0gd2l0aCBbYmx1ZTAsIGJsdWUxXQogICAgICAgICAgICAgIGlmKHJlZDAgPCByZWRYKSB7CiAgICAgICAgICAgICAgICByZXR2YWwgPSBzd2VlcC5zd2VlcENvbXBsZXRlKAogICAgICAgICAgICAgICAgICBkLCB2aXNpdCwKICAgICAgICAgICAgICAgICAgcmVkMCwgcmVkWCwgcmVkLCByZWRJbmRleCwKICAgICAgICAgICAgICAgICAgYmx1ZTAsIGJsdWUxLCBibHVlLCBibHVlSW5kZXgpCiAgICAgICAgICAgICAgICBpZihyZXR2YWwgIT09IHZvaWQgMCkgewogICAgICAgICAgICAgICAgICByZXR1cm4gcmV0dmFsCiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAvL05vcm1hbCBzd2VlcCBpbnRlcnNlY3Rpb246CiAgICAgICAgICAgICAgLy8gIFtyZWRYLCByZWQxXSB3aXRoIFtibHVlMCwgYmx1ZTFdCiAgICAgICAgICAgICAgaWYocmVkWCA8IHJlZDEpIHsKICAgICAgICAgICAgICAgIHJldHZhbCA9IHN3ZWVwLnN3ZWVwQmlwYXJ0aXRlKAogICAgICAgICAgICAgICAgICBkLCB2aXNpdCwKICAgICAgICAgICAgICAgICAgcmVkWCwgcmVkMSwgcmVkLCByZWRJbmRleCwKICAgICAgICAgICAgICAgICAgYmx1ZTAsIGJsdWUxLCBibHVlLCBibHVlSW5kZXgpCiAgICAgICAgICAgICAgICBpZihyZXR2YWwgIT09IHZvaWQgMCkgewogICAgICAgICAgICAgICAgICByZXR1cm4gcmV0dmFsCiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGlmKHJlZDAgPCByZWRYKSB7CiAgICAgICAgICAgICAgICBpdGVyUHVzaCh0b3ArKywKICAgICAgICAgICAgICAgICAgYXhpcysxLAogICAgICAgICAgICAgICAgICByZWQwLCByZWRYLAogICAgICAgICAgICAgICAgICBibHVlMCwgYmx1ZTEsCiAgICAgICAgICAgICAgICAgIDE2LAogICAgICAgICAgICAgICAgICAtSW5maW5pdHksIEluZmluaXR5KQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZihyZWRYIDwgcmVkMSkgewogICAgICAgICAgICAgICAgaXRlclB1c2godG9wKyssCiAgICAgICAgICAgICAgICAgIGF4aXMrMSwKICAgICAgICAgICAgICAgICAgcmVkWCwgcmVkMSwKICAgICAgICAgICAgICAgICAgYmx1ZTAsIGJsdWUxLAogICAgICAgICAgICAgICAgICAwLAogICAgICAgICAgICAgICAgICAtSW5maW5pdHksIEluZmluaXR5KQogICAgICAgICAgICAgICAgaXRlclB1c2godG9wKyssCiAgICAgICAgICAgICAgICAgIGF4aXMrMSwKICAgICAgICAgICAgICAgICAgYmx1ZTAsIGJsdWUxLAogICAgICAgICAgICAgICAgICByZWRYLCByZWQxLAogICAgICAgICAgICAgICAgICAxLAogICAgICAgICAgICAgICAgICAtSW5maW5pdHksIEluZmluaXR5KQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBpZihmbGlwKSB7CiAgICAgICAgICAgIHJlZDEgPSBwYXJ0aXRpb25Db250YWluc1BvaW50UHJvcGVyKAogICAgICAgICAgICAgIGQsIGF4aXMsCiAgICAgICAgICAgICAgcmVkMCwgcmVkRW5kLCByZWQsIHJlZEluZGV4LAogICAgICAgICAgICAgIG1pZCkKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHJlZDEgPSBwYXJ0aXRpb25Db250YWluc1BvaW50KAogICAgICAgICAgICAgIGQsIGF4aXMsCiAgICAgICAgICAgICAgcmVkMCwgcmVkRW5kLCByZWQsIHJlZEluZGV4LAogICAgICAgICAgICAgIG1pZCkKICAgICAgICAgIH0KICAgICAgICAgIGlmKHJlZDAgPCByZWQxKSB7CiAgICAgICAgICAgIGlmKGF4aXMgPT09IGQtMikgewogICAgICAgICAgICAgIGlmKGZsaXApIHsKICAgICAgICAgICAgICAgIHJldHZhbCA9IHN3ZWVwLnN3ZWVwQmlwYXJ0aXRlKAogICAgICAgICAgICAgICAgICBkLCB2aXNpdCwKICAgICAgICAgICAgICAgICAgYmx1ZTAsIGJsdWUxLCBibHVlLCBibHVlSW5kZXgsCiAgICAgICAgICAgICAgICAgIHJlZDAsIHJlZDEsIHJlZCwgcmVkSW5kZXgpCiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHJldHZhbCA9IHN3ZWVwLnN3ZWVwQmlwYXJ0aXRlKAogICAgICAgICAgICAgICAgICBkLCB2aXNpdCwKICAgICAgICAgICAgICAgICAgcmVkMCwgcmVkMSwgcmVkLCByZWRJbmRleCwKICAgICAgICAgICAgICAgICAgYmx1ZTAsIGJsdWUxLCBibHVlLCBibHVlSW5kZXgpCiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGl0ZXJQdXNoKHRvcCsrLAogICAgICAgICAgICAgICAgYXhpcysxLAogICAgICAgICAgICAgICAgcmVkMCwgcmVkMSwKICAgICAgICAgICAgICAgIGJsdWUwLCBibHVlMSwKICAgICAgICAgICAgICAgIGZsaXAsCiAgICAgICAgICAgICAgICAtSW5maW5pdHksIEluZmluaXR5KQogICAgICAgICAgICAgIGl0ZXJQdXNoKHRvcCsrLAogICAgICAgICAgICAgICAgYXhpcysxLAogICAgICAgICAgICAgICAgYmx1ZTAsIGJsdWUxLAogICAgICAgICAgICAgICAgcmVkMCwgcmVkMSwKICAgICAgICAgICAgICAgIGZsaXBeMSwKICAgICAgICAgICAgICAgIC1JbmZpbml0eSwgSW5maW5pdHkpCiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9Cn0KCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2JveC1pbnRlcnNlY3QvbGliL21lZGlhbi5qcyI6Ci8qISoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9ib3gtaW50ZXJzZWN0L2xpYi9tZWRpYW4uanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohIG5vIHN0YXRpYyBleHBvcnRzIGZvdW5kICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIGV4cG9ydHMsIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKCgptb2R1bGUuZXhwb3J0cyA9IGZpbmRNZWRpYW4KCnZhciBnZW5QYXJ0aXRpb24gPSBfX3dlYnBhY2tfcmVxdWlyZV9fKC8qISAuL3BhcnRpdGlvbiAqLyAi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ciB2YWx1ZTIgPSBib3hlc1tlbGVtU2l6ZSpwaXZvdDIgKyBheGlzXQogICAgaWYodmFsdWUwIDw9IHZhbHVlMSkgewogICAgICBpZih2YWx1ZTIgPj0gdmFsdWUxKSB7CiAgICAgICAgcGl2b3QgPSBwaXZvdDEKICAgICAgICB2YWx1ZSA9IHZhbHVlMQogICAgICB9IGVsc2UgaWYodmFsdWUwID49IHZhbHVlMikgewogICAgICAgIHBpdm90ID0gcGl2b3QwCiAgICAgICAgdmFsdWUgPSB2YWx1ZTAKICAgICAgfSBlbHNlIHsKICAgICAgICBwaXZvdCA9IHBpdm90MgogICAgICAgIHZhbHVlID0gdmFsdWUyCiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGlmKHZhbHVlMSA+PSB2YWx1ZTIpIHsKICAgICAgICBwaXZvdCA9IHBpdm90MQogICAgICAgIHZhbHVlID0gdmFsdWUxCiAgICAgIH0gZWxzZSBpZih2YWx1ZTIgPj0gdmFsdWUwKSB7CiAgICAgICAgcGl2b3QgPSBwaXZvdDAKICAgICAgICB2YWx1ZSA9IHZhbHVlMAogICAgICB9IGVsc2UgewogICAgICAgIHBpdm90ID0gcGl2b3QyCiAgICAgICAgdmFsdWUgPSB2YWx1ZTIKICAgICAgfQogICAgfQoKICAgIC8vU3dhcCBwaXZvdCB0byBlbmQgb2YgYXJyYXkKICAgIHZhciBhUHRyID0gZWxlbVNpemUgKiAoaGktMSkKICAgIHZhciBiUHRyID0gZWxlbVNpemUgKiBwaXZvdAogICAgZm9yKHZhciBpPTA7IGk8ZWxlbVNpemU7ICsraSwgKythUHRyLCArK2JQdHIpIHsKICAgICAgdmFyIHggPSBib3hlc1thUHRyXQogICAgICBib3hlc1thUHRyXSA9IGJveGVzW2JQdHJdCiAgICAgIGJveGVzW2JQdHJdID0geAogICAgfQogICAgdmFyIHkgPSBpZHNbaGktMV0KICAgIGlkc1toaS0xXSA9IGlkc1twaXZvdF0KICAgIGlkc1twaXZvdF0gPSB5CgogICAg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ArK2kpIHsKICAgIHZhciBlICAgICA9IFNXRUVQX0VWRU5UU1syKmkrMV18MAogICAgdmFyIGNvbG9yID0gZSYxCiAgICBpZihpIDwgbi0xICYmIChlPj4xKSA9PT0gKFNXRUVQX0VWRU5UU1syKmkrM10+PjEpKSB7CiAgICAgIGNvbG9yID0gMgogICAgICBpICs9IDEKICAgIH0KICAgIAogICAgaWYoZSA8IDApIHsKICAgICAgLy9DcmVhdGUgZXZlbnQKICAgICAgdmFyIGlkID0gLShlPj4xKSAtIDEKCiAgICAgIC8vSW50ZXJzZWN0IHdpdGggY29tbW9uCiAgICAgIGZvcih2YXIgaj0wOyBqPGNvbW1vbkFjdGl2ZTsgKytqKSB7CiAgICAgICAgdmFyIHJldHZhbCA9IHZpc2l0KENPTU1PTl9TV0VFUF9RVUVVRVtqXSwgaWQpCiAgICAgICAgaWYocmV0dmFsICE9PSB2b2lkIDApIHsKICAgICAgICAgIHJldHVybiByZXR2YWwKICAgICAgICB9CiAgICAgIH0KCiAgICAgIGlmKGNvbG9yICE9PSAwKSB7CiAgICAgICAgLy9JbnRlcnNlY3Qgd2l0aCByZWQKICAgICAgICBmb3IodmFyIGo9MDsgajxyZWRBY3RpdmU7ICsraikgewogICAgICAgICAgdmFyIHJldHZhbCA9IHZpc2l0KFJFRF9TV0VFUF9RVUVVRVtqXSwgaWQpCiAgICAgICAgICBpZihyZXR2YWwgIT09IHZvaWQgMCkgewogICAgICAgICAgICByZXR1cm4gcmV0dmFsCiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CgogICAgICBpZihjb2xvciAhPT0gMSkgewogICAgICAgIC8vSW50ZXJzZWN0IHdpdGggYmx1ZQogICAgICAgIGZvcih2YXIgaj0wOyBqPGJsdWVBY3RpdmU7ICsraikgewogICAgICAgICAgdmFyIHJldHZhbCA9IHZpc2l0KEJMVUVfU1dFRVBfUVVFVUVbal0sIGlkKQogICAgICAgICAgaWYocmV0dmFsICE9PSB2b2lkIDApIHsKICAgICAgICAgICAgc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kW3JlZFB0citheGlzKzFdIHx8IAogICAgICAgICAgICAgcmVkW3JlZFB0citheGlzKzErZF0gPCBiMCkgewogICAgICAgICAgICBjb250aW51ZQogICAgICAgICAgfQoKICAgICAgICAgIGZvcih2YXIgaz1heGlzKzI7IGs8ZDsgKytrKSB7CiAgICAgICAgICAgIGlmKGJsdWVbYmx1ZVB0ciArIGsgKyBkXSA8IHJlZFtyZWRQdHIgKyBrXSB8fCAKICAgICAgICAgICAgICAgcmVkW3JlZFB0ciArIGsgKyBkXSA8IGJsdWVbYmx1ZVB0ciArIGtdKSB7CiAgICAgICAgICAgICAgY29udGludWUgcmVkX2xvb3AKICAgICAgICAgICAgfQogICAgICAgICAgfQoKICAgICAgICAgIHZhciByZWRJZCAgPSByZWRJbmRleFtvaWR4XQogICAgICAgICAgdmFyIHJldHZhbAogICAgICAgICAgaWYoZmxpcCkgewogICAgICAgICAgICByZXR2YWwgPSB2aXNpdChibHVlSWQsIHJlZElkKQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcmV0dmFsID0gdmlzaXQocmVkSWQsIGJsdWVJZCkKICAgICAgICAgIH0KICAgICAgICAgIGlmKHJldHZhbCAhPT0gdm9pZCAwKSB7CiAgICAgICAgICAgIHJldHVybiByZXR2YWwgCiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9IGVsc2UgewogICAgICBzcVBvcChSRURfU1dFRVBfUVVFVUUsIFJFRF9TV0VFUF9JTkRFWCwgcmVkQWN0aXZlLS0sIGUgLSByZWRTaGlmdCkKICAgIH0KICB9Cn0KCmZ1bmN0aW9uIHNjYW5Db21wbGV0ZSgKICBkLCBheGlzLCB2aXNpdCwKICByZWRTdGFydCwgIHJlZEVuZCwgcmVkLCByZWRJbmRleCwKICBibHVlU3RhcnQsIGJsdWVFbmQsIGJsdWUsIGJsdWVJbmRleCkgewoKICB2YXIgcHRyICAgICAgPSAwCiAgdmFyIGVsZW1TaXplID0gMipkCiAgdmFyIGlzdGFydCAg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kZXhbaWR4XQogICAgICAgIHZhciBibHVlUHRyID0gZWxlbVNpemUgKiBpZHgKCiAgICAgICAgdmFyIGIwID0gYmx1ZVtibHVlUHRyK2F4aXMrMV0KICAgICAgICB2YXIgYjEgPSBibHVlW2JsdWVQdHIrYXhpcysxK2RdCgpyZWRfbG9vcDoKICAgICAgICBmb3IodmFyIGo9MDsgajxyZWRBY3RpdmU7ICsraikgewogICAgICAgICAgdmFyIG9pZHggICA9IFJFRF9TV0VFUF9RVUVVRVtqXQogICAgICAgICAgdmFyIHJlZElkICA9IHJlZEluZGV4W29pZHhdCgogICAgICAgICAgaWYocmVkSWQgPT09IGJsdWVJZCkgewogICAgICAgICAgICBicmVhawogICAgICAgICAgfQoKICAgICAgICAgIHZhciByZWRQdHIgPSBlbGVtU2l6ZSAqIG9pZHgKICAgICAgICAgIGlmKGIxIDwgcmVkW3JlZFB0citheGlzKzFdIHx8IAogICAgICAgICAgICByZWRbcmVkUHRyK2F4aXMrMStkXSA8IGIwKSB7CiAgICAgICAgICAgIGNvbnRpbnVlCiAgICAgICAgICB9CiAgICAgICAgICBmb3IodmFyIGs9YXhpcysyOyBrPGQ7ICsraykgewogICAgICAgICAgICBpZihibHVlW2JsdWVQdHIgKyBrICsgZF0gPCByZWRbcmVkUHRyICsga10gfHwgCiAgICAgICAgICAgICAgIHJlZFtyZWRQdHIgKyBrICsgZF0gICA8IGJsdWVbYmx1ZVB0ciArIGtdKSB7CiAgICAgICAgICAgICAgY29udGludWUgcmVkX2xvb3AKICAgICAgICAgICAgfQogICAgICAgICAgfQoKICAgICAgICAgIHZhciByZXR2YWwgPSB2aXNpdChyZWRJZCwgYmx1ZUlkKQogICAgICAgICAgaWYocmV0dmFsICE9PSB2b2lkIDApIHsKICAgICAgICAgICAgcmV0dXJuIHJldHZhbCAKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIHZhciBpZHggPSBlIC0gQkxVRV9GTEFHCiAgICAgIGZ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gwKSB7CiAgICAgICAgICAgIHRlbXBDb2RlUG9pbnQgPSAoZmlyc3RCeXRlICYgMHhGKSA8PCAweEMgfCAoc2Vjb25kQnl0ZSAmIDB4M0YpIDw8IDB4NiB8ICh0aGlyZEJ5dGUgJiAweDNGKQogICAgICAgICAgICBpZiAodGVtcENvZGVQb2ludCA+IDB4N0ZGICYmICh0ZW1wQ29kZVBvaW50IDwgMHhEODAwIHx8IHRlbXBDb2RlUG9pbnQgPiAweERGRkYpKSB7CiAgICAgICAgICAgICAgY29kZVBvaW50ID0gdGVtcENvZGVQb2ludAogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBicmVhawogICAgICAgIGNhc2UgNDoKICAgICAgICAgIHNlY29uZEJ5dGUgPSBidWZbaSArIDFdCiAgICAgICAgICB0aGlyZEJ5dGUgPSBidWZbaSArIDJdCiAgICAgICAgICBmb3VydGhCeXRlID0gYnVmW2kgKyAzXQogICAgICAgICAgaWYgKChzZWNvbmRCeXRlICYgMHhDMCkgPT09IDB4ODAgJiYgKHRoaXJkQnl0ZSAmIDB4QzApID09PSAweDgwICYmIChmb3VydGhCeXRlICYgMHhDMCkgPT09IDB4ODApIHsKICAgICAgICAgICAgdGVtcENvZGVQb2ludCA9IChmaXJzdEJ5dGUgJiAweEYpIDw8IDB4MTIgfCAoc2Vjb25kQnl0ZSAmIDB4M0YpIDw8IDB4QyB8ICh0aGlyZEJ5dGUgJiAweDNGKSA8PCAweDYgfCAoZm91cnRoQnl0ZSAmIDB4M0YpCiAgICAgICAgICAgIGlmICh0ZW1wQ29kZVBvaW50ID4gMHhGRkZGICYmIHRlbXBDb2RlUG9pbnQgPCAweDExMDAwMCkgewogICAgICAgICAgICAgIGNvZGVQb2ludCA9IHRlbXBDb2RlUG9pbnQKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICB9CiAgICB9CgogICAgaWYgKGNvZGVQb2ludCA9PT0gbnVsbCkgewogICAgICAvLyB3ZSBkaWQgbm90IGdlbmVy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0aXZlLCBuZXh0LCBib3VuZGFyeSkgewogIHRoaXMuY2VsbHMgICAgICAgPSBjZWxscwogIHRoaXMubmVpZ2hib3IgICAgPSBuZWlnaGJvcgogIHRoaXMuZmxhZ3MgICAgICAgPSBmbGFncwogIHRoaXMuY29uc3RyYWludCAgPSBjb25zdHJhaW50CiAgdGhpcy5hY3RpdmUgICAgICA9IGFjdGl2ZQogIHRoaXMubmV4dCAgICAgICAgPSBuZXh0CiAgdGhpcy5ib3VuZGFyeSAgICA9IGJvdW5kYXJ5Cn0KCnZhciBwcm90byA9IEZhY2VJbmRleC5wcm90b3R5cGUKCmZ1bmN0aW9uIGNvbXBhcmVDZWxsKGEsIGIpIHsKICByZXR1cm4gYVswXSAtIGJbMF0gfHwKICAgICAgICAgYVsxXSAtIGJbMV0gfHwKICAgICAgICAgYVsyXSAtIGJbMl0KfQoKcHJvdG8ubG9jYXRlID0gKGZ1bmN0aW9uKCkgewogIHZhciBrZXkgPSBbMCwwLDBdCiAgcmV0dXJuIGZ1bmN0aW9uKGEsIGIsIGMpIHsKICAgIHZhciB4ID0gYSwgeSA9IGIsIHogPSBjCiAgICBpZihiIDwgYykgewogICAgICBpZihiIDwgYSkgewogICAgICAgIHggPSBiCiAgICAgICAgeSA9IGMKICAgICAgICB6ID0gYQogICAgICB9CiAgICB9IGVsc2UgaWYoYyA8IGEpIHsKICAgICAgeCA9IGMKICAgICAgeSA9IGEKICAgICAgeiA9IGIKICAgIH0KICAgIGlmKHggPCAwKSB7CiAgICAgIHJldHVybiAtMQogICAgfQogICAga2V5WzBdID0geAogICAga2V5WzFdID0geQogICAga2V5WzJdID0gegogICAgcmV0dXJuIGJzZWFyY2guZXEodGhpcy5jZWxscywga2V5LCBjb21wYXJlQ2VsbCkKICB9Cn0pKCkKCmZ1bmN0aW9uIGluZGV4Q2VsbHModHJpYW5ndWxhdGlvbiwgaW5maW5pdHkpIHsKICAvL0ZpcnN0IGdldCBjZWxscyBhbmQgY2Fub25pY2FsaXplCiAgdmFyIGNlbGxzID0gdHJpYW5ndWxhdGlvbi5jZWxscygpCiAgdmFyIG5jID0gY2VsbHMubGVuZ3RoCiAgZm9yKHZhciBpPTA7IGk8bmM7ICsraSkgewogICAgdmFyIGMgPSBjZWxsc1tpXQogICAgdmFyIHggPSBjWzBdLCB5ID0gY1sxXSwgeiA9IGNbMl0KICAgIGlmKHkgPCB6KSB7CiAgICAgIGlmKHkgPCB4KSB7CiAgICAgICAgY1swXSA9IHkKICAgICAgICBjWzFdID0gegogICAgICAgIGNbMl0gPSB4CiAgICAgIH0KICAgIH0gZWxzZSBpZih6IDwgeCkgewogICAgICBjWzBdID0gegogICAgICBjWzFdID0geAogICAgICBjWzJdID0geQogICAgfQogIH0KICBjZWxscy5zb3J0KGNvbXBhcmVDZWxsKQoKICAvL0luaXRpYWxpemUgZmxhZyBhcnJheQogIHZhciBmbGFncyA9IG5ldyBBcnJheShuYykKICBmb3IodmFyIGk9MDsgaTxmbGFncy5sZW5ndGg7ICsraSkgewogICAgZmxhZ3NbaV0gPSAwCiAgfQoKICAvL0J1aWxkIG5laWdoYm9yIGluZGV4LCBpbml0aWFsaXplIHF1ZXVlcwogIHZhciBhY3RpdmUgPSBbXQogIHZhciBuZXh0ICAgPSBbXQogIHZhciBuZWlnaGJvciA9IG5ldyBBcnJheSgzKm5jKQogIHZhciBjb25zdHJhaW50ID0gbmV3IEFycmF5KDMqbmMpCiAgdmFyIGJvdW5kYXJ5ID0gbnVsbAogIGlmKGluZmluaXR5KSB7CiAgICBib3VuZGFyeSA9IFtdCiAgfQogIHZhciBpbmRleCA9IG5ldyBGYWNlSW5kZXgoCiAgICBjZWxscywKICAgIG5laWdoYm9yLAogICAgY29uc3RyYWludCwKICAgIGZsYWdzLAogICAgYWN0aXZlLAogICAgbmV4dCwKICAgIGJvdW5kYXJ5KQogIGZvcih2YXIgaT0wOyBpPG5jOyArK2kpIHsKICAgIHZhciBjID0gY2VsbHNbaV0KICAgIGZvcih2YXIgaj0wOyBqPDM7ICsraikgewogICAgICB2YXIgeCA9IGNbal0sIHkgPSBjWyhqKzEpJTNdCiAgICAgIHZhciBhID0gbmVpZ2hib3JbMyppK2pdID0gaW5kZXgubG9jYXRlKHksIHgsIHRyaWFuZ3VsYXRpb24ub3Bwb3NpdGUoeSwgeCkpCiAgICAgIHZhciBiID0gY29uc3RyYWludFszKmkral0gPSB0cmlhbmd1bGF0aW9uLmlzQ29uc3RyYWludCh4LCB5KQogICAgICBpZihhIDwgMCkgewogICAgICAgIGlmKGIpIHsKICAgICAgICAgIG5leHQucHVzaChpKQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBhY3RpdmUucHVzaChpKQogICAgICAgICAgZmxhZ3NbaV0gPSAxCiAgICAgICAgfQogICAgICAgIGlmKGluZmluaXR5KSB7CiAgICAgICAgICBib3VuZGFyeS5wdXNoKFt5LCB4LCAtMV0pCiAgICAgICAgfQogICAgICB9CiAgICB9CiAgfQogIHJldHVybiBpbmRleAp9CgpmdW5jdGlvbiBmaWx0ZXJDZWxscyhjZWxscywgZmxhZ3MsIHRhcmdldCkgewogIHZhciBwdHIgPSAwCiAgZm9yKHZhciBpPTA7IGk8Y2VsbHMubGVuZ3RoOyArK2kpIHsKICAgIGlmKGZsYWdzW2ldID09PSB0YXJnZXQpIHsKICAgICAgY2VsbHNbcHRyKytdID0gY2VsbHNbaV0KICAgIH0KICB9CiAgY2VsbHMubGVuZ3RoID0gcHRyCiAgcmV0dXJuIGNlbGxzCn0KCmZ1bmN0aW9uIGNsYXNzaWZ5RmFjZXModHJpYW5ndWxhdGlvbiwgdGFyZ2V0LCBpbmZpbml0eSkgewogIHZhciBpbmRleCA9IGluZGV4Q2VsbHModHJpYW5ndWxhdGlvbiwgaW5maW5pdHkpCgogIGlmKHRhcmdldCA9PT0gMCkgewogICAgaWYoaW5maW5pdHkpIHsKICAgICAgcmV0dXJuIGluZGV4LmNlbGxzLmNvbmNhdChpbmRleC5ib3VuZGFyeSkKICAgIH0gZWxzZSB7CiAgICAgIHJldHVybiBpbmRleC5jZWxscwogICAgfQogIH0KCiAgdmFyIHNpZGUgPSAxCiAgdmFyIGFjdGl2ZSA9IGluZGV4LmFjdGl2ZQogIHZhciBuZXh0ID0gaW5kZXgubmV4dAogIHZhciBmbGFncyA9IGluZGV4LmZsYWdzCiAgdmFyIGNlbGxzID0gaW5kZXguY2VsbHMKICB2YXIgY29uc3RyYWludCA9IGluZGV4LmNvbnN0cmFpbnQKICB2YXIgbmVpZ2hib3IgPSBpbmRleC5uZWlnaGJvcgoKICB3aGlsZShhY3RpdmUubGVuZ3RoID4gMCB8fCBuZXh0Lmxlbmd0aCA+IDApIHsKICAgIHdoaWxlKGFjdGl2ZS5sZW5ndGggPiAwKSB7CiAgICAgIHZhciB0ID0gYWN0aXZlLnBvcCgpCiAgICAgIGlmKGZsYWdzW3RdID09PSAtc2lkZSkgewogICAgICAgIGNvbnRpbnVlCiAgICAgIH0KICAgICAgZmxhZ3NbdF0gPSBzaWRlCiAgICAgIHZhciBjID0gY2VsbHNbdF0KICAgICAgZm9yKHZhciBqPTA7IGo8MzsgKytqKSB7CiAgICAgICAgdmFyIGYgPSBuZWlnaGJvclszKnQral0KICAgICAgICBpZihmID49IDAgJiYgZmxhZ3NbZl0gPT09IDApIHsKICAgICAgICAgIGlmKGNvbnN0cmFpbnRbMyp0K2pdKSB7CiAgICAgICAgICAgIG5leHQucHVzaChmKQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgYWN0aXZlLnB1c2goZikKICAgICAgICAgICAgZmxhZ3NbZl0gPSBzaWRlCiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CgogICAgLy9Td2FwIGFycmF5cyBhbmQgbG9vcAogICAgdmFyIHRtcCA9IG5leHQKICAgIG5leHQgPSBhY3RpdmUKICAgIGFjdGl2ZSA9IHRtcAogICAgbmV4dC5sZW5ndGggPSAwCiAgICBzaWRlID0gLXNpZGUKICB9CgogIHZhciByZXN1bHQgPSBmaWx0ZXJDZ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2ludChjZWxscywgaHVsbHMsIHBvaW50cywgcCwgaWR4KSB7CiAgdmFyIGxvID0gYnNlYXJjaC5sdChodWxscywgcCwgdGVzdFBvaW50KQogIHZhciBoaSA9IGJzZWFyY2guZ3QoaHVsbHMsIHAsIHRlc3RQb2ludCkKICBmb3IodmFyIGk9bG87IGk8aGk7ICsraSkgewogICAgdmFyIGh1bGwgPSBodWxsc1tpXQoKICAgIC8vSW5zZXJ0IHAgaW50byBsb3dlciBodWxsCiAgICB2YXIgbG93ZXJJZHMgPSBodWxsLmxvd2VySWRzCiAgICB2YXIgbSA9IGxvd2VySWRzLmxlbmd0aAogICAgd2hpbGUobSA+IDEgJiYgb3JpZW50KAogICAgICAgIHBvaW50c1tsb3dlcklkc1ttLTJdXSwKICAgICAgICBwb2ludHNbbG93ZXJJZHNbbS0xXV0sCiAgICAgICAgcCkgPiAwKSB7CiAgICAgIGNlbGxzLnB1c2goCiAgICAgICAgW2xvd2VySWRzW20tMV0sCiAgICAgICAgIGxvd2VySWRzW20tMl0sCiAgICAgICAgIGlkeF0pCiAgICAgIG0gLT0gMQogICAgfQogICAgbG93ZXJJZHMubGVuZ3RoID0gbQogICAgbG93ZXJJZHMucHVzaChpZHgpCgogICAgLy9JbnNlcnQgcCBpbnRvIHVwcGVyIGh1bGwKICAgIHZhciB1cHBlcklkcyA9IGh1bGwudXBwZXJJZHMKICAgIHZhciBtID0gdXBwZXJJZHMubGVuZ3RoCiAgICB3aGlsZShtID4gMSAmJiBvcmllbnQoCiAgICAgICAgcG9pbnRzW3VwcGVySWRzW20tMl1dLAogICAgICAgIHBvaW50c1t1cHBlcklkc1ttLTFdXSwKICAgICAgICBwKSA8IDApIHsKICAgICAgY2VsbHMucHVzaCgKICAgICAgICBbdXBwZXJJZHNbbS0yXSwKICAgICAgICAgdXBwZXJJZHNbbS0xXSwKICAgICAgICAgaWR4XSkKICAgICAgbSAtPSAxCiAgICB9CiAgICB1cHBlcklkcy5sZW5ndGggPSBtCiAgICB1cHB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nB1c2goZVsyXSkKICAgIH0KICB9CgogIHJldHVybiBtb2RpZmllZAp9CgoKLyoqKi8gfSksCgovKioqLyAiLi9ub2RlX21vZHVsZXMvY2xlYW4tcHNsZy9saWIvcmF0LXNlZy1pbnRlcnNlY3QuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9jbGVhbi1wc2xnL2xpYi9yYXQtc2VnLWludGVyc2VjdC5qcyAqKiohCiAgXCoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBubyBzdGF0aWMgZXhwb3J0cyBmb3VuZCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBleHBvcnRzLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7CgoKbW9kdWxlLmV4cG9ydHMgPSBzb2x2ZUludGVyc2VjdGlvbgoKdmFyIHJhdE11bCA9IF9fd2VicGFja19yZXF1aXJlX18oLyohIGJpZy1yYXQvbXVsICovICIuL25vZGVfbW9kdWxlcy9iaWctcmF0L211bC5qcyIpCnZhciByYXREaXYgPSBfX3dlYnBhY2tfcmVxdWlyZV9fKC8qISBiaWctcmF0L2RpdiAqLyAiLi9ub2RlX21vZHVsZXMvYmlnLXJhdC9kaXYuanMiKQp2YXIgcmF0U3ViID0gX193ZWJwYWNrX3JlcXVpcmVfXygvKiEgYmlnLXJhdC9zdWIgKi8gIi4vbm9kZV9tb2R1bGVzL2JpZy1yYXQvc3ViLmpzIikKdmFyIHJhdFNpZ24gPSBfX3dlYnBhY2tfcmVxdWlyZV9fKC8qISBiaWctcmF0L3NpZ24gKi8gIi4vbm9kZV9tb2R1bGVzL2JpZy1yYXQvc2lnbi5qcyIpCnZhciBydlN1YiA9IF9fd2VicGFja19yZXF1aXJlX18oLyohIHJhdC12ZWMvc3ViICovICIuL25vZ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F0sIC1iWzBdKQogIHZhciB5MCA9IHR3b1N1bShhWzFdLCAtYlsxXSkKICB2YXIgeDEgPSB0d29TdW0oY1swXSwgLWJbMF0pCiAgdmFyIHkxID0gdHdvU3VtKGNbMV0sIC1iWzFdKQoKICB2YXIgZCA9IHJvYnVzdFN1bSgKICAgIHJvYnVzdFByb2R1Y3QoeDAsIHgxKSwKICAgIHJvYnVzdFByb2R1Y3QoeTAsIHkxKSkKCiAgcmV0dXJuIGRbZC5sZW5ndGgtMV0gPj0gMAp9CgpmdW5jdGlvbiBjb21wYXJlQW5nbGUoYSwgYiwgYywgZCkgewogIHZhciBiY2QgPSBvcmllbnQoYiwgYywgZCkKICBpZihiY2QgPT09IDApIHsKICAgIC8vSGFuZGxlIGRlZ2VuZXJhdGUgY2FzZXMKICAgIHZhciBzYWJjID0gc2duKG9yaWVudChhLCBiLCBjKSkKICAgIHZhciBzYWJkID0gc2duKG9yaWVudChhLCBiLCBkKSkKICAgIGlmKHNhYmMgPT09IHNhYmQpIHsKICAgICAgaWYoc2FiYyA9PT0gMCkgewogICAgICAgIHZhciBpYyA9IHRlc3RJbnRlcmlvcihhLCBiLCBjKQogICAgICAgIHZhciBpZCA9IHRlc3RJbnRlcmlvcihhLCBiLCBkKQogICAgICAgIGlmKGljID09PSBpZCkgewogICAgICAgICAgcmV0dXJuIDAKICAgICAgICB9IGVsc2UgaWYoaWMpIHsKICAgICAgICAgIHJldHVybiAxCiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHJldHVybiAtMQogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gMAogICAgfSBlbHNlIGlmKHNhYmQgPT09IDApIHsKICAgICAgaWYoc2FiYyA+IDApIHsKICAgICAgICByZXR1cm4gLTEKICAgICAgfSBlbHNlIGlmKHRlc3RJbnRlcmlvcihhLCBiLCBkKSkgewogICAgICAgIHJldHVybiAtMQogICAgICB9IGVsc2UgewogICAgICAgIHJldHVybiAxCiAgICAgIH0KICAgIH0gZWxzZSBpZihzYWJjID09PSAwKSB7CiAgICAgIGlmKHNhYmQgPiAwKSB7CiAgICAgICAgcmV0dXJuIDEKICAgICAgfSBlbHNlIGlmKHRlc3RJbnRlcmlvcihhLCBiLCBjKSkgewogICAgICAgIHJldHVybiAxCiAgICAgIH0gZWxzZSB7CiAgICAgICAgcmV0dXJuIC0xCiAgICAgIH0KICAgIH0KICAgIHJldHVybiBzZ24oc2FiZCAtIHNhYmMpCiAgfQogIHZhciBhYmMgPSBvcmllbnQoYSwgYiwgYykKICBpZihhYmMgPiAwKSB7CiAgICBpZihiY2QgPiAwICYmIG9yaWVudChhLCBiLCBkKSA+IDApIHsKICAgICAgcmV0dXJuIDEKICAgIH0KICAgIHJldHVybiAtMQogIH0gZWxzZSBpZihhYmMgPCAwKSB7CiAgICBpZihiY2QgPiAwIHx8IG9yaWVudChhLCBiLCBkKSA+IDApIHsKICAgICAgcmV0dXJuIDEKICAgIH0KICAgIHJldHVybiAtMQogIH0gZWxzZSB7CiAgICB2YXIgYWJkID0gb3JpZW50KGEsIGIsIGQpCiAgICBpZihhYmQgPiAwKSB7CiAgICAgIHJldHVybiAxCiAgICB9IGVsc2UgewogICAgICBpZih0ZXN0SW50ZXJpb3IoYSwgYiwgYykpIHsKICAgICAgICByZXR1cm4gMQogICAgICB9IGVsc2UgewogICAgICAgIHJldHVybiAtMQogICAgICB9CiAgICB9CiAgfQp9CgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9jd2lzZS1jb21waWxlci9jb21waWxlci5qcyI6Ci8qISoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2N3aXNlLWNvbXBpbGVyL2NvbXBpbGVyLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohIG5vIHN0YXRpYyBleHBvcnRzIGZvdW5kICovCi8qKiovIChmdW5jdG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ICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGNvZGUgPSBjb2RlLnJlcGxhY2UocmUsIFthcnJTdHIsICJbIiwgcHRyU3RyLCAiXSJdLmpvaW4oIiIpKQogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgaWYoZHR5cGVzW2Fyck51bV0gPT09ICJnZW5lcmljIikgewogICAgICAgICAgICBwcmUucHVzaChbInZhciAiLCBsb2NhbFN0ciwgIj0iLCBhcnJTdHIsICIuZ2V0KCIsIHB0clN0ciwgIikiXS5qb2luKCIiKSkgLy8gVE9ETzogQ291bGQgd2Ugb3B0aW1pemUgYnkgY2hlY2tpbmcgZm9yIGNhcmcucnZhbHVlPwogICAgICAgICAgICBjb2RlID0gY29kZS5yZXBsYWNlKHJlLCBsb2NhbFN0cikKICAgICAgICAgICAgaWYoY2FyZy5sdmFsdWUpIHsKICAgICAgICAgICAgICBwb3N0LnB1c2goW2FyclN0ciwgIi5zZXQoIiwgcHRyU3RyLCAiLCIsIGxvY2FsU3RyLCIpIl0uam9pbigiIikpCiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHByZS5wdXNoKFsidmFyICIsIGxvY2FsU3RyLCAiPSIsIGFyclN0ciwgIlsiLCBwdHJTdHIsICJdIl0uam9pbigiIikpIC8vIFRPRE86IENvdWxkIHdlIG9wdGltaXplIGJ5IGNoZWNraW5nIGZvciBjYXJnLnJ2YWx1ZT8KICAgICAgICAgICAgY29kZSA9IGNvZGUucmVwbGFjZShyZSwgbG9jYWxTdHIpCiAgICAgICAgICAgIGlmKGNhcmcubHZhbHVlKSB7CiAgICAgICAgICAgICAgcG9zdC5wdXNoKFthcnJTdHIsICJbIiwgcHRyU3RyLCAiXT0iLCBsb2NhbFN0cl0uam9pbigiIikpCiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgeyAvLyBBcmd1bWVudCB0byBib2R5IGlzIGEgImJsb2NrIgogICAgICAgICAgdmFyIHJlU3RyQXJyID0gW2NhcmcubmFtZV0sIHB0clN0ckFyciA9IFtwdHJTdHJdCiAgICAgICAgICBmb3IodmFyIGo9MDsgajxNYXRoLmFicyhwcm9jLmFycmF5QmxvY2tJbmRpY2VzW2Fyck51bV0pOyBqKyspIHsKICAgICAgICAgICAgcmVTdHJBcnIucHVzaCgiXFxzKlxcWyhbXlxcXV0rKVxcXSIpCiAgICAgICAgICAgIHB0clN0ckFyci5wdXNoKCIkIiArIChqKzEpICsgIip0IiArIGFyck51bSArICJiIiArIGopIC8vIE1hdGNoZWQgaW5kZXggdGltZXMgc3RyaWRlCiAgICAgICAgICB9CiAgICAgICAgICByZSA9IG5ldyBSZWdFeHAocmVTdHJBcnIuam9pbigiIiksICJnIikKICAgICAgICAgIHB0clN0ciA9IHB0clN0ckFyci5qb2luKCIrIikKICAgICAgICAgIGlmKGR0eXBlc1thcnJOdW1dID09PSAiZ2VuZXJpYyIpIHsKICAgICAgICAgICAgLyppZihjYXJnLmx2YWx1ZSkgewogICAgICAgICAgICAgIHByZS5wdXNoKFsidmFyICIsIGxvY2FsU3RyLCAiPSIsIGFyclN0ciwgIi5nZXQoIiwgcHRyU3RyLCAiKSJdLmpvaW4oIiIpKSAvLyBJcyB0aGlzIG5lY2Vzc2FyeSBpZiB0aGUgYXJndW1lbnQgaXMgT05MWSB1c2VkIGFzIGFuIGx2YWx1ZT8gKGtlZXAgaW4gbWluZCB0aGF0IHdlIGNhbiBoYXZlIGEgKz0gc29tZXRoaW5nLCBzbyB3ZSB3b3VsZCBhY3R1YWxseSBuZWVkIHRvIGNoZWNrIGNhcmcucnZhbHVlKQogICAgICAgICAgICAgIGNvZGUgPSBjb2RlLnJlcGxhY2UocmUsIGxvY2FsU3RyKQogICAgICAgICAgICAgIHBvc3QucHVzaChbYXJyU3RyLCAiLnNldCgiLCBwdHJTdHIsICIsIiwgbG9jYWxTdHIsIikiXS5qb2luKCIiKSkKICAgICAgICAgIC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ICAiQ0FDSEVEW3R5cGVdPXByb2M9Y29tcGlsZShbIiwgdHlwZXNpZy5qb2luKCIsIiksICJdKX0iLAogICAgICAgICAgICAgInJldHVybiBwcm9jKCIsIHByb2NfYXJncy5qb2luKCIsIiksICIpfSJdLmpvaW4oIiIpKQoKICBpZihwcm9jLmRlYnVnKSB7CiAgICBjb25zb2xlLmxvZygiLS0tLS1HZW5lcmF0ZWQgdGh1bms6XG4iICsgY29kZS5qb2luKCJcbiIpICsgIlxuLS0tLS0tLS0tLSIpCiAgfQogIAogIC8vQ29tcGlsZSB0aHVuawogIHZhciB0aHVuayA9IG5ldyBGdW5jdGlvbigiY29tcGlsZSIsIGNvZGUuam9pbigiXG4iKSkKICByZXR1cm4gdGh1bmsoY29tcGlsZS5iaW5kKHVuZGVmaW5lZCwgcHJvYykpCn0KCm1vZHVsZS5leHBvcnRzID0gY3JlYXRlVGh1bmsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kL2luZGV4LmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9kL2luZGV4LmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgbm8gc3RhdGljIGV4cG9ydHMgZm91bmQgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgZXhwb3J0cywgX193ZWJwYWNrX3JlcXVpcmVfXykgewoKInVzZSBzdHJpY3QiOwoKCnZhciBhc3NpZ24gICAgICAgID0gX193ZWJwYWNrX3JlcXVpcmVfXygvKiEgZXM1LWV4dC9vYmplY3QvYXNzaWduICovICIuL25vZGVfbW9kdWxlcy9lczUtZXh0L29iamVjdC9hc3NpZ24vaW5kZXguanMiKQogICwgbm9ybWFsaXplT3B0cyA9IF9fd2VicGFja19yZXF1aXJlX18oLyohIGVzNS1leHQvb2JqZWN0L25vcm1hbGl6ZS1vcHRpb25zICovICIuL25vZGVf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qKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtYXJyYXkvc3JjL2FycmF5LmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBzbGljZSwgbWFwICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGV4cG9ydCAoYmluZGluZykgKi8gX193ZWJwYWNrX3JlcXVpcmVfXy5kKF9fd2VicGFja19leHBvcnRzX18sICJzbGljZSIsIGZ1bmN0aW9uKCkgeyByZXR1cm4gc2xpY2U7IH0pOwovKiBoYXJtb255IGV4cG9ydCAoYmluZGluZykgKi8gX193ZWJwYWNrX3JlcXVpcmVfXy5kKF9fd2VicGFja19leHBvcnRzX18sICJtYXAiLCBmdW5jdGlvbigpIHsgcmV0dXJuIG1hcDsgfSk7CnZhciBhcnJheSA9IEFycmF5LnByb3RvdHlwZTsKCnZhciBzbGljZSA9IGFycmF5LnNsaWNlOwp2YXIgbWFwID0gYXJyYXkubWFwOwoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWFycmF5L3NyYy9hc2NlbmRpbmcuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2QzLWFycmF5L3NyYy9hc2NlbmRpbmcuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leH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KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGltcG9ydCAqLyB2YXIgX2FzY2VuZGluZ19fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMF9fID0gX193ZWJwYWNrX3JlcXVpcmVfXygvKiEgLi9hc2NlbmRpbmcgKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWFycmF5L3NyYy9hc2NlbmRpbmcuanMiKTsKCgovKiBoYXJtb255IGRlZmF1bHQgZXhwb3J0ICovIF9fd2VicGFja19leHBvcnRzX19bImRlZmF1bHQiXSA9IChmdW5jdGlvbihjb21wYXJlKSB7CiAgaWYgKGNvbXBhcmUubGVuZ3RoID09PSAxKSBjb21wYXJlID0gYXNjZW5kaW5nQ29tcGFyYXRvcihjb21wYXJlKTsKICByZXR1cm4gewogICAgbGVmdDogZnVuY3Rpb24oYSwgeCwgbG8sIGhpKSB7CiAgICAgIGlmIChsbyA9PSBudWxsKSBsbyA9IDA7CiAgICAgIGlmIChoaSA9PSBudWxsKSBoaSA9IGEubGVuZ3RoOwogICAgICB3aGlsZSAobG8gPCBoaSkgewogICAgICAgIHZhciBtaWQgPSBsbyArIGhpID4+PiAxOwogICAgICAgIGlmIChjb21wYXJlKGFbbWlkXSwgeCkgPCAwKSBsbyA9IG1pZCArIDE7CiAgICAgICAgZWxzZSBoaSA9IG1pZDsKICAgICAgfQogICAgICByZXR1cm4gbG87CiAgICB9LAogICAgcmlnaHQ6IGZ1bmN0aW9uKGEsIHgsIGxvLCBoaSkgewogICAgICBpZiAobG8gPT0gbnVsbCkgbG8gPSAwOwogICAgICBpZiAoaGkgPT0gbnVsbCkgaGkgPSBhLmxlbmd0aDsKICAgICAgd2hpbGUgKGxvIDwgaGkpIHsKICAgICAgICB2YXIgbWlkID0gbG8gKyBoaSA+Pj4gMTsKICAgICAgICBpZiAoY29tcGFyZShhW21pZF0sIHgpID4gMCkgaGkgPSBtaWQ7CiAgICAgICAgZWxzZSBsbyA9IG1pZCArIDE7CiAgICAgIH0KICAgICAgcmV0dXJuIGxvOwogICAgfQogIH07Cn0pOwoKZnVuY3Rpb24gYXNjZW5kaW5nQ29tcGFyYXRvcihmKSB7CiAgcmV0dXJuIGZ1bmN0aW9uKGQsIHgpIHsKICAgIHJldHVybiBPYmplY3QoX2FzY2VuZGluZ19fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMF9fWyJkZWZhdWx0Il0pKGYoZCksIHgpOwogIH07Cn0KCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1hcnJheS9zcmMvY29uc3RhbnQuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtYXJyYXkvc3JjL2NvbnN0YW50LmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGRlZmF1bHQgZXhwb3J0ICovIF9fd2VicGFja19leHBvcnRzX19bImRlZmF1bHQiXSA9IChmdW5jdGlvbih4KSB7CiAgcmV0dXJuIGZ1bmN0aW9uKCkgewogICAgcmV0dXJuIHg7CiAgfTsKf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F5L3NyYy9kZXZpYXRpb24uanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGltcG9ydCAqLyB2YXIgX3ZhcmlhbmNlX19XRUJQQUNLX0lNUE9SVEVEX01PRFVMRV8wX18gPSBfX3dlYnBhY2tfcmVxdWlyZV9fKC8qISAuL3ZhcmlhbmNlICovICIuL25vZGVfbW9kdWxlcy9kMy1hcnJheS9zcmMvdmFyaWFuY2UuanMiKTsKCgovKiBoYXJtb255IGRlZmF1bHQgZXhwb3J0ICovIF9fd2VicGFja19leHBvcnRzX19bImRlZmF1bHQiXSA9IChmdW5jdGlvbihhcnJheSwgZikgewogIHZhciB2ID0gT2JqZWN0KF92YXJpYW5jZV9fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMF9fWyJkZWZhdWx0Il0pKGFycmF5LCBmKTsKICByZXR1cm4gdiA/IE1hdGguc3FydCh2KSA6IHY7Cn0pOwoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWFycmF5L3NyYy9leHRlbnQuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2QzLWFycmF5L3NyYy9leHRlbnQuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2Vic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ICAgICAgd2hpbGUgKCsraSA8IG4pIHsgLy8gQ29tcGFyZSB0aGUgcmVtYWluaW5nIHZhbHVlcy4KICAgICAgICAgIGlmICgodmFsdWUgPSB2YWx1ZW9mKHZhbHVlc1tpXSwgaSwgdmFsdWVzKSkgIT0gbnVsbCkgewogICAgICAgICAgICBpZiAobWluID4gdmFsdWUpIG1pbiA9IHZhbHVlOwogICAgICAgICAgICBpZiAobWF4IDwgdmFsdWUpIG1heCA9IHZhbHVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfQogIH0KCiAgcmV0dXJuIFttaW4sIG1heF07Cn0pOwoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWFycmF5L3NyYy9oaXN0b2dyYW0uanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2QzLWFycmF5L3NyYy9oaXN0b2dyYW0uanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGltcG9ydCAqLyB2YXIgX2FycmF5X19XRUJQQUNLX0lNUE9SVEVEX01PRFVMRV8wX18gPSBfX3dlYnBhY2tfcmVxdWlyZV9fKC8qISAuL2FycmF5ICovICIuL25vZGVfbW9kdWxlcy9kMy1hcnJheS9zcmMvYXJyYXkuanMiKTsKLyogaGFybW9ueSBpbXBvcnQgKi8gdmFyIF9iaXNlY3RfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzFfX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ZDMtYXJyYXkvc3JjL2lkZW50aXR5LmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2QzLWFycmF5L3NyYy9pZGVudGl0eS5qcyAqKiohCiAgXCoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm92aWRlZDogZGVmYXVsdCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBfX3dlYnBhY2tfZXhwb3J0c19fLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7Cl9fd2VicGFja19yZXF1aXJlX18ucihfX3dlYnBhY2tfZXhwb3J0c19fKTsKLyogaGFybW9ueSBkZWZhdWx0IGV4cG9ydCAqLyBfX3dlYnBhY2tfZXhwb3J0c19fWyJkZWZhdWx0Il0gPSAoZnVuY3Rpb24oeCkgewogIHJldHVybiB4Owp9KTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1hcnJheS9zcmMvaW5kZXguanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtYXJyYXkvc3JjL2luZGV4LmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBiaXNlY3QsIGJpc2VjdFJpZ2h0LCBiaXNlY3RMZWZ0LCBhc2NlbmRpbmcsIGJpc2VjdG9yLCBjcm9zcywgZGVzY2VuZGluZywgZGV2aWF0aW9uLCBleHRlbnQsIGhpc3RvZ3JhbSwgdGhyZXNob2xkRnJlZWRtYW5EaWFjb25pcywgdGhyZXNob2xkU2NvdHQsIHRocmVzaG9sZFN0dXJnZXMsIG1heCwgbWVhbiwgbWVkaWFuLCBtZ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b3J0ICovIHZhciBfemlwX19XRUJQQUNLX0lNUE9SVEVEX01PRFVMRV8yNl9fID0gX193ZWJwYWNrX3JlcXVpcmVfXygvKiEgLi96aXAgKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWFycmF5L3NyYy96aXAuanMiKTsKLyogaGFybW9ueSByZWV4cG9ydCAoc2FmZSkgKi8gX193ZWJwYWNrX3JlcXVpcmVfXy5kKF9fd2VicGFja19leHBvcnRzX18sICJ6aXAiLCBmdW5jdGlvbigpIHsgcmV0dXJuIF96aXBfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzI2X19bImRlZmF1bHQiXTsgfSk7CgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWFycmF5L3NyYy9tYXguanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2QzLWFycmF5L3NyYy9tYXguanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGRlZmF1bHQgZXhwb3J0ICovIF9fd2VicGFja19leHBvcnRzX19bImRlZmF1bHQiXSA9IChmdW5jdGlvbih2YWx1ZXMsIHZhbHVlb2YpIHsKICB2YXIgbiA9IHZhbHVlcy5sZW5ndGgsCiAgICAgIGkgPSAtMSwKICAgICAgdmFsdWUsCiAgICAgIG1heDsKCiAgaWYgKHZhbHVlb2YgPT0gbnVsbCkgewogICAgd2hpbGUgKCsraSA8IG4pIHsgLy8gRmluZCB0aGUgZmlyc3QgY29tcGFyYWJsZSB2YWx1ZS4KICAgICAgaWYgKCh2YWx1ZSA9IHZhbHVlc1tpXSkgIT0gbnVsbCAmJiB2YWx1ZSA+PSB2YWx1ZSkgewogICAgICAgIG1heCA9IHZhbHVlOwogICAgICAgIHdoaWxlICgrK2kgPCBuKSB7IC8vIENvbXBhcmUgdGhlIHJlbWFpbmluZyB2YWx1ZXMuCiAgICAgICAgICBpZiAoKHZhbHVlID0gdmFsdWVzW2ldKSAhPSBudWxsICYmIHZhbHVlID4gbWF4KSB7CiAgICAgICAgICAgIG1heCA9IHZhbHVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfQogIH0KCiAgZWxzZSB7CiAgICB3aGlsZSAoKytpIDwgbikgeyAvLyBGaW5kIHRoZSBmaXJzdCBjb21wYXJhYmxlIHZhbHVlLgogICAgICBpZiAoKHZhbHVlID0gdmFsdWVvZih2YWx1ZXNbaV0sIGksIHZhbHVlcykpICE9IG51bGwgJiYgdmFsdWUgPj0gdmFsdWUpIHsKICAgICAgICBtYXggPSB2YWx1ZTsKICAgICAgICB3aGlsZSAoKytpIDwgbikgeyAvLyBDb21wYXJlIHRoZSByZW1haW5pbmcgdmFsdWVzLgogICAgICAgICAgaWYgKCh2YWx1ZSA9IHZhbHVlb2YodmFsdWVzW2ldLCBpLCB2YWx1ZXMpKSAhPSBudWxsICYmIHZhbHVlID4gbWF4KSB7CiAgICAgICAgICAgIG1heCA9IHZhbHVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfQogIH0KCiAgcmV0dXJuIG1heDsKfSk7CgoKLyoqKi8gfSksCgovKioqLyAiLi9ub2RlX21vZHVsZXMvZDMtYXJyYXkvc3JjL21lYW4uanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9kMy1hcnJheS9zcmMvbWVhbi5qcyAqKiohCiAgXCoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGltcG9ydCAqLyB2YXIgX251bWJlcl9fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMF9fID0gX193ZWJwYWNrX3JlcXVpcmVfXygvKiEgLi9udW1iZXIgKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWFycmF5L3NyYy9udW1iZXIuanMiKTsKCgovKiBoYXJtb255IGRlZmF1bHQgZXhwb3J0ICovIF9fd2VicGFja19leHBvcnRzX19bImRlZmF1bHQiXSA9IChmdW5jdGlvbih2YWx1ZXMsIHZhbHVlb2YpIHsKICB2YXIgbiA9IHZhbHVlcy5sZW5ndGgsCiAgICAgIG0gPSBuLAogICAgICBpID0gLTEsCiAgICAgIHZhbHVlLAogICAgICBzdW0gPSAwOwoKICBpZiAodmFsdWVvZiA9PSBudWxsKSB7CiAgICB3aGlsZSAoKytpIDwgbikgewogICAgICBpZiAoIWlzTmFOKHZhbHVlID0gT2JqZWN0KF9udW1iZXJfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzBfX1siZGVmYXVsdCJdKSh2YWx1ZXNbaV0pKSkgc3VtICs9IHZhbHVlOwogICAgICBlbHNlIC0tbTsKICAgIH0KICB9CgogIGVsc2UgewogICAgd2hpbGUgKCsraSA8IG4pIHsKICAgICAgaWYgKCFpc05hTih2YWx1ZSA9IE9iamVjdChfbnVtYmVyX19XRUJQQUNLX0lNUE9SVEVEX01PRFVMRV8wX19bImRlZmF1bHQiXSkodmFsdWVvZih2YWx1Z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ci8qISoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9kMy1hcnJheS9zcmMvbWVyZ2UuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohIGV4cG9ydHMgcHJvdmlkZWQ6IGRlZmF1bHQgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgX193ZWJwYWNrX2V4cG9ydHNfXywgX193ZWJwYWNrX3JlcXVpcmVfXykgewoKInVzZSBzdHJpY3QiOwpfX3dlYnBhY2tfcmVxdWlyZV9fLnIoX193ZWJwYWNrX2V4cG9ydHNfXyk7Ci8qIGhhcm1vbnkgZGVmYXVsdCBleHBvcnQgKi8gX193ZWJwYWNrX2V4cG9ydHNfX1siZGVmYXVsdCJdID0gKGZ1bmN0aW9uKGFycmF5cykgewogIHZhciBuID0gYXJyYXlzLmxlbmd0aCwKICAgICAgbSwKICAgICAgaSA9IC0xLAogICAgICBqID0gMCwKICAgICAgbWVyZ2VkLAogICAgICBhcnJheTsKCiAgd2hpbGUgKCsraSA8IG4pIGogKz0gYXJyYXlzW2ldLmxlbmd0aDsKICBtZXJnZWQgPSBuZXcgQXJyYXkoaik7CgogIHdoaWxlICgtLW4gPj0gMCkgewogICAgYXJyYXkgPSBhcnJheXNbbl07CiAgICBtID0gYXJyYXkubGVuZ3RoOwogICAgd2hpbGUgKC0tbSA+PSAwKSB7CiAgICAgIG1lcmdlZFstLWpdID0gYXJyYXlbbV07CiAgICB9CiAgfQoKICByZXR1cm4gbWVyZ2VkOwp9KTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1hcnJheS9zcmMvbWluLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9kMy1hcnJheS9zcmMvbWluLmpzICoqKiE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udWxsICYmIHZhbHVlID49IHZhbHVlKSB7CiAgICAgICAgbWluID0gdmFsdWU7CiAgICAgICAgd2hpbGUgKCsraSA8IG4pIHsgLy8gQ29tcGFyZSB0aGUgcmVtYWluaW5nIHZhbHVlcy4KICAgICAgICAgIGlmICgodmFsdWUgPSB2YWx1ZW9mKHZhbHVlc1tpXSwgaSwgdmFsdWVzKSkgIT0gbnVsbCAmJiBtaW4gPiB2YWx1ZSkgewogICAgICAgICAgICBtaW4gPSB2YWx1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9CgogIHJldHVybiBtaW47Cn0pOwoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWFycmF5L3NyYy9udW1iZXIuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2QzLWFycmF5L3NyYy9udW1iZXIuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGRlZmF1bHQgZXhwb3J0ICovIF9fd2VicGFja19leHBvcnRzX19bImRlZmF1bHQiXSA9IChmdW5jdGlvbih4KSB7CiAgcmV0dXJuIHggPT09IG51bGwgPyBOYU4gOiAreDsKfSk7CgoKLyoqKi8gfSksCgovKioqLyAiLi9ub2RlX21vZHVsZXMvZDMtYXJyYXkvc3JjL3BhaXJzLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwK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ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGltcG9ydCAqLyB2YXIgX2FzY2VuZGluZ19fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMF9fID0gX193ZWJwYWNrX3JlcXVpcmVfXygvKiEgLi9hc2NlbmRpbmcgKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWFycmF5L3NyYy9hc2NlbmRpbmcuanMiKTsKCgovKiBoYXJtb255IGRlZmF1bHQgZXhwb3J0ICovIF9fd2VicGFja19leHBvcnRzX19bImRlZmF1bHQiXSA9IChmdW5jdGlvbih2YWx1ZXMsIGNvbXBhcmUpIHsKICBpZiAoIShuID0gdmFsdWVzLmxlbmd0aCkpIHJldHVybjsKICB2YXIgbiwKICAgICAgaSA9IDAsCiAgICAgIGogPSAwLAogICAgICB4aSwKICAgICAgeGogPSB2YWx1ZXNbal07CgogIGlmIChjb21wYXJlID09IG51bGwpIGNvbXBhcmUgPSBfYXNjZW5kaW5nX19XRUJQQUNLX0lNUE9SVEVEX01PRFVMRV8wX19bImRlZmF1bHQiXTsKCiAgd2hpbGUgKCsraSA8IG4pIHsKICAgIGlmIChjb21wYXJlKHhpID0gdmFsdWVzW2ldLCB4aikgPCAwIHx8IGNvbXBhcmUoeGosIHhqKSAhPT0gMCkgewogICAgICB4aiA9IHhpLCBqID0gaTsKICAgIH0KICB9CgogIGlmIChjb21wYXJlKHhqLCB4aikgPT09IDApIHJldHVybiBqOwp9KTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1hcnJheS9zcmMvc2h1ZmZsZS5qcyI6Ci8qISoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2QzLWFycmF5L3NyYy9zaHVmZmxlLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohIGV4cG9ydHMgcHJvdmlkZWQ6IGRlZmF1bHQgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgX193ZWJwYWNrX2V4cG9ydHNfXywgX193ZWJwYWNrX3JlcXVpcmVfXykgewoKInVzZSBzdHJpY3QiOwpfX3dlYnBhY2tfcmVxdWlyZV9fLnIoX193ZWJwYWNrX2V4cG9ydHNfXyk7Ci8qIGhhcm1vbnkgZGVmYXVsdCBleHBvcnQgKi8gX193ZWJwYWNrX2V4cG9ydHNfX1siZGVmYXVsdCJdID0gKGZ1bmN0aW9uKGFycmF5LCBpMCwgaTEpIHsKICB2YXIgbSA9IChpMSA9PSBudWxsID8gYXJyYXkubGVuZ3RoIDogaTEpIC0gKGkwID0gaTAgPT0gbnVsbCA/IDAgOiAraTApLAogICAgICB0LAogICAgICBpOwoKICB3aGlsZSAobSkgewogICAgaSA9IE1hdGgucmFuZG9tKCkgKiBtLS0gfCAwOwogICAgdCA9IGFycmF5W20gKyBpMF07CiAgICBhcnJheVttICsgaTBdID0gYXJyYXlbaSArIGkwXTsKICAgIGFycmF5W2kgKyBpMF0gPSB0OwogIH0KCiAgcmV0dXJuIGFycmF5Owp9KTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1hcnJheS9zcmMvc3VtLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9kMy1hcnJheS9zcmMvc3VtLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm92aWRlZDogZGVmYXVsdCAqLwovKioqLyAoZnVuY3R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IGltcG9ydCAqLyB2YXIgX2RldmlhdGlvbl9fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMF9fID0gX193ZWJwYWNrX3JlcXVpcmVfXygvKiEgLi4vZGV2aWF0aW9uICovICIuL25vZGVfbW9kdWxlcy9kMy1hcnJheS9zcmMvZGV2aWF0aW9uLmpzIik7CgoKLyogaGFybW9ueSBkZWZhdWx0IGV4cG9ydCAqLyBfX3dlYnBhY2tfZXhwb3J0c19fWyJkZWZhdWx0Il0gPSAoZnVuY3Rpb24odmFsdWVzLCBtaW4sIG1heCkgewogIHJldHVybiBNYXRoLmNlaWwoKG1heCAtIG1pbikgLyAoMy41ICogT2JqZWN0KF9kZXZpYXRpb25fX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzBfX1siZGVmYXVsdCJdKSh2YWx1ZXMpICogTWF0aC5wb3codmFsdWVzLmxlbmd0aCwgLTEgLyAzKSkpOwp9KTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1hcnJheS9zcmMvdGhyZXNob2xkL3N0dXJnZXMuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtYXJyYXkvc3JjL3RocmVzaG9sZC9zdHVyZ2VzLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGRlZmF1bHQgZXhwb3J0ICovIF9fd2VicGFja19leHBvcnRzX19bImRl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Bvc2UuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2QzLWFycmF5L3NyYy90cmFuc3Bvc2UuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGltcG9ydCAqLyB2YXIgX21pbl9fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMF9fID0gX193ZWJwYWNrX3JlcXVpcmVfXygvKiEgLi9taW4gKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWFycmF5L3NyYy9taW4uanMiKTsKCgovKiBoYXJtb255IGRlZmF1bHQgZXhwb3J0ICovIF9fd2VicGFja19leHBvcnRzX19bImRlZmF1bHQiXSA9IChmdW5jdGlvbihtYXRyaXgpIHsKICBpZiAoIShuID0gbWF0cml4Lmxlbmd0aCkpIHJldHVybiBbXTsKICBmb3IgKHZhciBpID0gLTEsIG0gPSBPYmplY3QoX21pbl9fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMF9fWyJkZWZhdWx0Il0pKG1hdHJpeCwgbGVuZ3RoKSwgdHJhbnNwb3NlID0gbmV3IEFycmF5KG0pOyArK2kgPCBtOykgewogICAgZm9yICh2YXIgaiA9IC0xLCBuLCByb3cgPSB0cmFuc3Bvc2VbaV0gPSBuZXcgQXJyYXkobik7ICsraiA8IG47KSB7CiAgICAgIHJvd1tqXSA9IG1hdHJpeFtqXVtpXTsKICAgIH0KICB9CiAgcmV0dXJuIHRyYW5zcG9zZTsKfS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Wx1ZSA9IE9iamVjdChfbnVtYmVyX19XRUJQQUNLX0lNUE9SVEVEX01PRFVMRV8wX19bImRlZmF1bHQiXSkodmFsdWVzW2ldKSkpIHsKICAgICAgICBkZWx0YSA9IHZhbHVlIC0gbWVhbjsKICAgICAgICBtZWFuICs9IGRlbHRhIC8gKyttOwogICAgICAgIHN1bSArPSBkZWx0YSAqICh2YWx1ZSAtIG1lYW4pOwogICAgICB9CiAgICB9CiAgfQoKICBlbHNlIHsKICAgIHdoaWxlICgrK2kgPCBuKSB7CiAgICAgIGlmICghaXNOYU4odmFsdWUgPSBPYmplY3QoX251bWJlcl9fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMF9fWyJkZWZhdWx0Il0pKHZhbHVlb2YodmFsdWVzW2ldLCBpLCB2YWx1ZXMpKSkpIHsKICAgICAgICBkZWx0YSA9IHZhbHVlIC0gbWVhbjsKICAgICAgICBtZWFuICs9IGRlbHRhIC8gKyttOwogICAgICAgIHN1bSArPSBkZWx0YSAqICh2YWx1ZSAtIG1lYW4pOwogICAgICB9CiAgICB9CiAgfQoKICBpZiAobSA+IDEpIHJldHVybiBzdW0gLyAobSAtIDEpOwp9KTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1hcnJheS9zcmMvemlwLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9kMy1hcnJheS9zcmMvemlwLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm92aWRlZDogZGVmYXVsdCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBfX3dlYnBhY2tfZXhwb3J0c19fLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7Cl9fd2VicGFja19yZXF1aXJlX18ucihfX3dlYnBhY2tfZXhwb3J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pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWF4aXMvc3JjL2F4aXMuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2QzLWF4aXMvc3JjL2F4aXMuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBheGlzVG9wLCBheGlzUmlnaHQsIGF4aXNCb3R0b20sIGF4aXNMZWZ0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGV4cG9ydCAoYmluZGluZykgKi8gX193ZWJwYWNrX3JlcXVpcmVfXy5kKF9fd2VicGFja19leHBvcnRzX18sICJheGlzVG9wIiwgZnVuY3Rpb24oKSB7IHJldHVybiBheGlzVG9wOyB9KTsKLyogaGFybW9ueSBleHBvcnQgKGJpbmRpbmcpICovIF9fd2VicGFja19yZXF1aXJlX18uZChfX3dlYnBhY2tfZXhwb3J0c19fLCAiYXhpc1JpZ2h0IiwgZnVuY3Rpb24oKSB7IHJldHVybiBheGlzUmlnaHQ7IH0pOwovKiBoYXJtb255IGV4cG9ydCAoYmluZGluZykgKi8gX193ZWJwYWNrX3JlcXVpcmVfXy5kKF9fd2VicGFja19leHBvcnRzX18sICJheGlzQm90dG9tIiwgZnVuY3Rpb24oKSB7IHJldHVybiBheGlzQm90dG9tOyB9KTsKLyogaGFybW9ueSBleHBvcnQgKGJpbmRpbmcpICovIF9fd2VicGFja19yZXF1aXJlX18uZChfX3dlYnBhY2tfZXhwb3J0c19fLCAiYXhpc0xlZnQiLCBmdW5jdGlvbigpIHsgcmV0dXJuIGF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FuZ2UgPSBzY2FsZS5yYW5nZSgpLAogICAgICAgIHJhbmdlMCA9ICtyYW5nZVswXSArIDAuNSwKICAgICAgICByYW5nZTEgPSArcmFuZ2VbcmFuZ2UubGVuZ3RoIC0gMV0gKyAwLjUsCiAgICAgICAgcG9zaXRpb24gPSAoc2NhbGUuYmFuZHdpZHRoID8gY2VudGVyIDogbnVtYmVyKShzY2FsZS5jb3B5KCkpLAogICAgICAgIHNlbGVjdGlvbiA9IGNvbnRleHQuc2VsZWN0aW9uID8gY29udGV4dC5zZWxlY3Rpb24oKSA6IGNvbnRleHQsCiAgICAgICAgcGF0aCA9IHNlbGVjdGlvbi5zZWxlY3RBbGwoIi5kb21haW4iKS5kYXRhKFtudWxsXSksCiAgICAgICAgdGljayA9IHNlbGVjdGlvbi5zZWxlY3RBbGwoIi50aWNrIikuZGF0YSh2YWx1ZXMsIHNjYWxlKS5vcmRlcigpLAogICAgICAgIHRpY2tFeGl0ID0gdGljay5leGl0KCksCiAgICAgICAgdGlja0VudGVyID0gdGljay5lbnRlcigpLmFwcGVuZCgiZyIpLmF0dHIoImNsYXNzIiwgInRpY2siKSwKICAgICAgICBsaW5lID0gdGljay5zZWxlY3QoImxpbmUiKSwKICAgICAgICB0ZXh0ID0gdGljay5zZWxlY3QoInRleHQiKTsKCiAgICBwYXRoID0gcGF0aC5tZXJnZShwYXRoLmVudGVyKCkuaW5zZXJ0KCJwYXRoIiwgIi50aWNrIikKICAgICAgICAuYXR0cigiY2xhc3MiLCAiZG9tYWluIikKICAgICAgICAuYXR0cigic3Ryb2tlIiwgImN1cnJlbnRDb2xvciIpKTsKCiAgICB0aWNrID0gdGljay5tZXJnZSh0aWNrRW50ZXIpOwoKICAgIGxpbmUgPSBsaW5lLm1lcmdlKHRpY2tFbnRlci5hcHBlbmQoImxpbmUiKQogICAgICAgIC5hdHRyKCJzdHJva2UiLCAiY3VycmVudENvbG9yIikKICAgICAgICAuYXR0cih4ICsgIjIiLCBrICogdGlja1NpemVJbm5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TsKCiAgICBwYXRoCiAgICAgICAgLmF0dHIoImQiLCBvcmllbnQgPT09IGxlZnQgfHwgb3JpZW50ID09IHJpZ2h0CiAgICAgICAgICAgID8gKHRpY2tTaXplT3V0ZXIgPyAiTSIgKyBrICogdGlja1NpemVPdXRlciArICIsIiArIHJhbmdlMCArICJIMC41ViIgKyByYW5nZTEgKyAiSCIgKyBrICogdGlja1NpemVPdXRlciA6ICJNMC41LCIgKyByYW5nZTAgKyAiViIgKyByYW5nZTEpCiAgICAgICAgICAgIDogKHRpY2tTaXplT3V0ZXIgPyAiTSIgKyByYW5nZTAgKyAiLCIgKyBrICogdGlja1NpemVPdXRlciArICJWMC41SCIgKyByYW5nZTEgKyAiViIgKyBrICogdGlja1NpemVPdXRlciA6ICJNIiArIHJhbmdlMCArICIsMC41SCIgKyByYW5nZTEpKTsKCiAgICB0aWNrCiAgICAgICAgLmF0dHIoIm9wYWNpdHkiLCAxKQogICAgICAgIC5hdHRyKCJ0cmFuc2Zvcm0iLCBmdW5jdGlvbihkKSB7IHJldHVybiB0cmFuc2Zvcm0ocG9zaXRpb24oZCkpOyB9KTsKCiAgICBsaW5lCiAgICAgICAgLmF0dHIoeCArICIyIiwgayAqIHRpY2tTaXplSW5uZXIpOwoKICAgIHRleHQKICAgICAgICAuYXR0cih4LCBrICogc3BhY2luZykKICAgICAgICAudGV4dChmb3JtYXQpOwoKICAgIHNlbGVjdGlvbi5maWx0ZXIoZW50ZXJpbmcpCiAgICAgICAgLmF0dHIoImZpbGwiLCAibm9uZSIpCiAgICAgICAgLmF0dHIoImZvbnQtc2l6ZSIsIDEwKQogICAgICAgIC5hdHRyKCJmb250LWZhbWlseSIsICJzYW5zLXNlcmlmIikKICAgICAgICAuYXR0cigidGV4dC1hbmNob3IiLCBvcmllbnQgPT09IHJpZ2h0ID8gInN0YXJ0IiA6IG9yaWVudCA9PT0gbGVmdCA/ICJlbmQiIDogIm1pZGRsZSIpOwoKICAgIHNlbGVjdGlvbgogICAgICAgIC5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9pZGVudGl0eS5qcyAqKiohCiAgXCoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGRlZmF1bHQgZXhwb3J0ICovIF9fd2VicGFja19leHBvcnRzX19bImRlZmF1bHQiXSA9IChmdW5jdGlvbih4KSB7CiAgcmV0dXJuIHg7Cn0pOwoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWF4aXMvc3JjL2luZGV4LmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtYXhpcy9zcmMvaW5kZXguanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm92aWRlZDogYXhpc1RvcCwgYXhpc1JpZ2h0LCBheGlzQm90dG9tLCBheGlzTGVmdCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBfX3dlYnBhY2tfZXhwb3J0c19fLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7Cl9fd2VicGFja19yZXF1aXJlX18ucihfX3dlYnBhY2tfZXhwb3J0c19fKTsKLyogaGFybW9ueSBpbXBvcnQgKi8gdmFyIF9heGlzX19XRUJQQUNLX0lNUE9SVEVEX01PRFVMRV8wX18gPSBfX3dlYnBhY2tfcmVxdWlyZV9fKC8qISAuL2F4aXMgKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWF4aXMvc3JjL2F4aXMuanMi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X01PRFVMRV8yX19bImludGVycG9sYXRlIl0pKHNlbGVjdGlvbjAsIHNlbGVjdGlvbjEpOwoKICAgICAgICAgICAgZnVuY3Rpb24gdHdlZW4odCkgewogICAgICAgICAgICAgIHN0YXRlLnNlbGVjdGlvbiA9IHQgPT09IDEgJiYgc2VsZWN0aW9uMSA9PT0gbnVsbCA/IG51bGwgOiBpKHQpOwogICAgICAgICAgICAgIHJlZHJhdy5jYWxsKHRoYXQpOwogICAgICAgICAgICAgIGVtaXQuYnJ1c2goKTsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgcmV0dXJuIHNlbGVjdGlvbjAgIT09IG51bGwgJiYgc2VsZWN0aW9uMSAhPT0gbnVsbCA/IHR3ZWVuIDogdHdlZW4oMSk7CiAgICAgICAgICB9KTsKICAgIH0gZWxzZSB7CiAgICAgIGdyb3VwCiAgICAgICAgICAuZWFjaChmdW5jdGlvbigpIHsKICAgICAgICAgICAgdmFyIHRoYXQgPSB0aGlzLAogICAgICAgICAgICAgICAgYXJncyA9IGFyZ3VtZW50cywKICAgICAgICAgICAgICAgIHN0YXRlID0gdGhhdC5fX2JydXNoLAogICAgICAgICAgICAgICAgc2VsZWN0aW9uMSA9IGRpbS5pbnB1dCh0eXBlb2Ygc2VsZWN0aW9uID09PSAiZnVuY3Rpb24iID8gc2VsZWN0aW9uLmFwcGx5KHRoYXQsIGFyZ3MpIDogc2VsZWN0aW9uLCBzdGF0ZS5leHRlbnQpLAogICAgICAgICAgICAgICAgZW1pdCA9IGVtaXR0ZXIodGhhdCwgYXJncykuYmVmb3Jlc3RhcnQoKTsKCiAgICAgICAgICAgIE9iamVjdChkM190cmFuc2l0aW9uX19XRUJQQUNLX0lNUE9SVEVEX01PRFVMRV80X19bImludGVycnVwdCJdKSh0aGF0KTsKICAgICAgICAgICAgc3RhdGUuc2VsZWN0aW9uID0gc2VsZWN0aW9uMSA9PT0gbnVsbCA/IG51bGwgOiBzZWxlY3Rpb24xOwogICAgICAgICAgICByZWRyYX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XJsYXkuYXR0cigiY3Vyc29yIiwgY3Vyc29ycy5vdmVybGF5KTsKICAgICAgaWYgKHN0YXRlLnNlbGVjdGlvbikgc2VsZWN0aW9uID0gc3RhdGUuc2VsZWN0aW9uOyAvLyBNYXkgYmUgc2V0IGJ5IGJydXNoLm1vdmUgKG9uIHN0YXJ0KSEKICAgICAgaWYgKGVtcHR5KHNlbGVjdGlvbikpIHN0YXRlLnNlbGVjdGlvbiA9IG51bGwsIHJlZHJhdy5jYWxsKHRoYXQpOwogICAgICBlbWl0LmVuZCgpOwogICAgfQoKICAgIGZ1bmN0aW9uIGtleWRvd25lZCgpIHsKICAgICAgc3dpdGNoIChkM19zZWxlY3Rpb25fX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzNfX1siZXZlbnQiXS5rZXlDb2RlKSB7CiAgICAgICAgY2FzZSAxNjogeyAvLyBTSElGVAogICAgICAgICAgc2hpZnRpbmcgPSBzaWduWCAmJiBzaWduWTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBjYXNlIDE4OiB7IC8vIEFMVAogICAgICAgICAgaWYgKG1vZGUgPT09IE1PREVfSEFORExFKSB7CiAgICAgICAgICAgIGlmIChzaWduWCkgZTAgPSBlMSAtIGR4ICogc2lnblgsIHcwID0gdzEgKyBkeCAqIHNpZ25YOwogICAgICAgICAgICBpZiAoc2lnblkpIHMwID0gczEgLSBkeSAqIHNpZ25ZLCBuMCA9IG4xICsgZHkgKiBzaWduWTsKICAgICAgICAgICAgbW9kZSA9IE1PREVfQ0VOVEVSOwogICAgICAgICAgICBtb3ZlKCk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgY2FzZSAzMjogeyAvLyBTUEFDRTsgdGFrZXMgcHJpb3JpdHkgb3ZlciBBTFQKICAgICAgICAgIGlmIChtb2RlID09PSBNT0RFX0hBTkRMRSB8fCBtb2RlID09PSBNT0RFX0NFTlRFUikgewogICAgICAgICAgICBpZiAoc2lnblggPCAwKSBlMCA9IGUxIC0gZHg7IGVsc2UgaWYgKHNpZ25YID4gMCkgdzAgPSB3MSAtIGR4OwogICAgICAgICAgICBpZiAoc2lnblkgPCAwKSBzMCA9IHMxIC0gZHk7IGVsc2UgaWYgKHNpZ25ZID4gMCkgbjAgPSBuMSAtIGR5OwogICAgICAgICAgICBtb2RlID0gTU9ERV9TUEFDRTsKICAgICAgICAgICAgb3ZlcmxheS5hdHRyKCJjdXJzb3IiLCBjdXJzb3JzLnNlbGVjdGlvbik7CiAgICAgICAgICAgIG1vdmUoKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBkZWZhdWx0OiByZXR1cm47CiAgICAgIH0KICAgICAgT2JqZWN0KF9ub2V2ZW50X2pzX19XRUJQQUNLX0lNUE9SVEVEX01PRFVMRV83X19bImRlZmF1bHQiXSkoKTsKICAgIH0KCiAgICBmdW5jdGlvbiBrZXl1cHBlZCgpIHsKICAgICAgc3dpdGNoIChkM19zZWxlY3Rpb25fX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzNfX1siZXZlbnQiXS5rZXlDb2RlKSB7CiAgICAgICAgY2FzZSAxNjogeyAvLyBTSElGVAogICAgICAgICAgaWYgKHNoaWZ0aW5nKSB7CiAgICAgICAgICAgIGxvY2tYID0gbG9ja1kgPSBzaGlmdGluZyA9IGZhbHNlOwogICAgICAgICAgICBtb3ZlKCk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgY2FzZSAxODogeyAvLyBBTFQKICAgICAgICAgIGlmIChtb2RlID09PSBNT0RFX0NFTlRFUikgewogICAgICAgICAgICBpZiAoc2lnblggPCAwKSBlMCA9IGUxOyBlbHNlIGlmIChzaWduWCA+IDApIHcwID0gdzE7CiAgICAgICAgICAgIGlmIChzaWduWSA8IDApIHMwID0gczE7IGVsc2UgaWYgKHNpZ25ZID4gMCkgbjAgPSBuMTsKICAgICAgICAgICAgbW9kZSA9IE1PREVfSEFORExFOwogICAgICAgICAgICBtb3ZlKCk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgY2FzZSAzMjogeyAvLyBTUEFDRQogICAgICAgICAgaWYgKG1vZGUgPT09IE1PREVfU1BBQ0UpIHsKICAgICAgICAgICAgaWYgKGQzX3NlbGVjdGlvbl9fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfM19fWyJldmVudCJdLmFsdEtleSkgewogICAgICAgICAgICAgIGlmIChzaWduWCkgZTAgPSBlMSAtIGR4ICogc2lnblgsIHcwID0gdzEgKyBkeCAqIHNpZ25YOwogICAgICAgICAgICAgIGlmIChzaWduWSkgczAgPSBzMSAtIGR5ICogc2lnblksIG4wID0gbjEgKyBkeSAqIHNpZ25ZOwogICAgICAgICAgICAgIG1vZGUgPSBNT0RFX0NFTlRFUjsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBpZiAoc2lnblggPCAwKSBlMCA9IGUxOyBlbHNlIGlmIChzaWduWCA+IDApIHcwID0gdzE7CiAgICAgICAgICAgICAgaWYgKHNpZ25ZIDwgMCkgczAgPSBzMTsgZWxzZSBpZiAoc2lnblkgPiAwKSBuMCA9IG4xOwogICAgICAgICAgICAgIG1vZGUgPSBNT0RFX0hBTkRMRTsKICAgICAgICAgICAgfQogICAgICAgICAgICBvdmVybGF5LmF0dHIoImN1cnNvciIsIGN1cnNvcnNbdHlwZV0pOwogICAgICAgICAgICBtb3ZlKCk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgZGVmYXVsdDogcmV0dXJuOwogICAgICB9CiAgICAgIE9iamVjdChfbm9ldmVudF9qc19fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfN19fWyJkZWZhdWx0Il0pKCk7CiAgICB9CiAgfQoKICBmdW5jdGlvbiB0b3VjaG1vdmVkKCkgewogICAgZW1pdHRlcih0aGlzLCBhcmd1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CJdID0gKGZ1bmN0aW9uKHgpIHsKICByZXR1cm4gZnVuY3Rpb24oKSB7CiAgICByZXR1cm4geDsKICB9Owp9KTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1icnVzaC9zcmMvZXZlbnQuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtYnJ1c2gvc3JjL2V2ZW50LmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGRlZmF1bHQgZXhwb3J0ICovIF9fd2VicGFja19leHBvcnRzX19bImRlZmF1bHQiXSA9IChmdW5jdGlvbih0YXJnZXQsIHR5cGUsIHNlbGVjdGlvbikgewogIHRoaXMudGFyZ2V0ID0gdGFyZ2V0OwogIHRoaXMudHlwZSA9IHR5cGU7CiAgdGhpcy5zZWxlY3Rpb24gPSBzZWxlY3Rpb247Cn0pOwoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWJydXNoL3NyYy9pbmRleC5qcyI6Ci8qISoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9kMy1icnVzaC9zcmMvaW5kZXguanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohIGV4cG9ydHMgcHJvdmlkZWQ6IGJydXNoLCBicnVzaFgsIGJydXNoWS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x0IGV4cG9ydCAqLyBfX3dlYnBhY2tfZXhwb3J0c19fWyJkZWZhdWx0Il0gPSAoZnVuY3Rpb24oKSB7CiAgdmFyIHBhZEFuZ2xlID0gMCwKICAgICAgc29ydEdyb3VwcyA9IG51bGwsCiAgICAgIHNvcnRTdWJncm91cHMgPSBudWxsLAogICAgICBzb3J0Q2hvcmRzID0gbnVsbDsKCiAgZnVuY3Rpb24gY2hvcmQobWF0cml4KSB7CiAgICB2YXIgbiA9IG1hdHJpeC5sZW5ndGgsCiAgICAgICAgZ3JvdXBTdW1zID0gW10sCiAgICAgICAgZ3JvdXBJbmRleCA9IE9iamVjdChkM19hcnJheV9fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMF9fWyJyYW5nZSJdKShuKSwKICAgICAgICBzdWJncm91cEluZGV4ID0gW10sCiAgICAgICAgY2hvcmRzID0gW10sCiAgICAgICAgZ3JvdXBzID0gY2hvcmRzLmdyb3VwcyA9IG5ldyBBcnJheShuKSwKICAgICAgICBzdWJncm91cHMgPSBuZXcgQXJyYXkobiAqIG4pLAogICAgICAgIGssCiAgICAgICAgeCwKICAgICAgICB4MCwKICAgICAgICBkeCwKICAgICAgICBpLAogICAgICAgIGo7CgogICAgLy8gQ29tcHV0ZSB0aGUgc3VtLgogICAgayA9IDAsIGkgPSAtMTsgd2hpbGUgKCsraSA8IG4pIHsKICAgICAgeCA9IDAsIGogPSAtMTsgd2hpbGUgKCsraiA8IG4pIHsKICAgICAgICB4ICs9IG1hdHJpeFtpXVtqXTsKICAgICAgfQogICAgICBncm91cFN1bXMucHVzaCh4KTsKICAgICAgc3ViZ3JvdXBJbmRleC5wdXNoKE9iamVjdChkM19hcnJheV9fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMF9fWyJyYW5nZSJdKShuKSk7CiAgICAgIGsgKz0geDsKICAgIH0KCiAgICAvLyBTb3J0IGdyb3Vwc+KApgogICAgaWYgKHNvcnRHcm91cHMpIGdyb3VwSW5kZXguc29ydChmd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raSA8IG4pIHsKICAgICAgeDAgPSB4LCBqID0gLTE7IHdoaWxlICgrK2ogPCBuKSB7CiAgICAgICAgdmFyIGRpID0gZ3JvdXBJbmRleFtpXSwKICAgICAgICAgICAgZGogPSBzdWJncm91cEluZGV4W2RpXVtqXSwKICAgICAgICAgICAgdiA9IG1hdHJpeFtkaV1bZGpdLAogICAgICAgICAgICBhMCA9IHgsCiAgICAgICAgICAgIGExID0geCArPSB2ICogazsKICAgICAgICBzdWJncm91cHNbZGogKiBuICsgZGldID0gewogICAgICAgICAgaW5kZXg6IGRpLAogICAgICAgICAgc3ViaW5kZXg6IGRqLAogICAgICAgICAgc3RhcnRBbmdsZTogYTAsCiAgICAgICAgICBlbmRBbmdsZTogYTEsCiAgICAgICAgICB2YWx1ZTogdgogICAgICAgIH07CiAgICAgIH0KICAgICAgZ3JvdXBzW2RpXSA9IHsKICAgICAgICBpbmRleDogZGksCiAgICAgICAgc3RhcnRBbmdsZTogeDAsCiAgICAgICAgZW5kQW5nbGU6IHgsCiAgICAgICAgdmFsdWU6IGdyb3VwU3Vtc1tkaV0KICAgICAgfTsKICAgICAgeCArPSBkeDsKICAgIH0KCiAgICAvLyBHZW5lcmF0ZSBjaG9yZHMgZm9yIGVhY2ggKG5vbi1lbXB0eSkgc3ViZ3JvdXAtc3ViZ3JvdXAgbGluay4KICAgIGkgPSAtMTsgd2hpbGUgKCsraSA8IG4pIHsKICAgICAgaiA9IGkgLSAxOyB3aGlsZSAoKytqIDwgbikgewogICAgICAgIHZhciBzb3VyY2UgPSBzdWJncm91cHNbaiAqIG4gKyBpXSwKICAgICAgICAgICAgdGFyZ2V0ID0gc3ViZ3JvdXBzW2kgKiBuICsgal07CiAgICAgICAgaWYgKHNvdXJjZS52YWx1ZSB8fCB0YXJnZXQudmFsdWUpIHsKICAgICAgICAgIGNob3Jkcy5wdXNoKHNvdXJjZS52YWx1ZSA8IHRhcmdldC52YWx1ZQogICAgICAgICAgICAgID8ge3NvdXJjZTogdGFyZ2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KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9kMy1jaG9yZC9zcmMvY29uc3RhbnQuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohIGV4cG9ydHMgcHJvdmlkZWQ6IGRlZmF1bHQgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgX193ZWJwYWNrX2V4cG9ydHNfXywgX193ZWJwYWNrX3JlcXVpcmVfXykgewoKInVzZSBzdHJpY3QiOwpfX3dlYnBhY2tfcmVxdWlyZV9fLnIoX193ZWJwYWNrX2V4cG9ydHNfXyk7Ci8qIGhhcm1vbnkgZGVmYXVsdCBleHBvcnQgKi8gX193ZWJwYWNrX2V4cG9ydHNfX1siZGVmYXVsdCJdID0gKGZ1bmN0aW9uKHgpIHsKICByZXR1cm4gZnVuY3Rpb24oKSB7CiAgICByZXR1cm4geDsKICB9Owp9KTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1jaG9yZC9zcmMvaW5kZXguanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtY2hvcmQvc3JjL2luZGV4LmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBjaG9yZCwgcmliYm9uICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGltcG9ydCAqLyB2YXIgX2Nob3JkX19XRUJQQUNLX0lNUE9SVEVEX01PRFVMRV8wX18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JndW1lbnRzLmxlbmd0aCA/IChlbmRBbmdsZSA9IHR5cGVvZiBfID09PSAiZnVuY3Rpb24iID8gXyA6IE9iamVjdChfY29uc3RhbnRfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzFfX1siZGVmYXVsdCJdKSgrXyksIHJpYmJvbikgOiBlbmRBbmdsZTsKICB9OwoKICByaWJib24uc291cmNlID0gZnVuY3Rpb24oXykgewogICAgcmV0dXJuIGFyZ3VtZW50cy5sZW5ndGggPyAoc291cmNlID0gXywgcmliYm9uKSA6IHNvdXJjZTsKICB9OwoKICByaWJib24udGFyZ2V0ID0gZnVuY3Rpb24oXykgewogICAgcmV0dXJuIGFyZ3VtZW50cy5sZW5ndGggPyAodGFyZ2V0ID0gXywgcmliYm9uKSA6IHRhcmdldDsKICB9OwoKICByaWJib24uY29udGV4dCA9IGZ1bmN0aW9uKF8pIHsKICAgIHJldHVybiBhcmd1bWVudHMubGVuZ3RoID8gKChjb250ZXh0ID0gXyA9PSBudWxsID8gbnVsbCA6IF8pLCByaWJib24pIDogY29udGV4dDsKICB9OwoKICByZXR1cm4gcmliYm9uOwp9KTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1jb2xsZWN0aW9uL3NyYy9lbnRyaWVzLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9kMy1jb2xsZWN0aW9uL3NyYy9lbnRyaWVzLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm92aWRlZDogZGVmYXVsdCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBfX3dlYnBhY2tfZXhwb3J0c19fLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7Cl9fd2VicGFja19yZXF1aXJlX18ucihfX3dlYnBhY2tfZXhwb3J0c19fKTsKLyogaGFybW9ueSBkZWZhdWx0IGV4cG9ydCAqLyBfX3dlYnBhY2tfZXhwb3J0c19fWyJkZWZhdWx0Il0gPSAoZnVuY3Rpb24obWFwKSB7CiAgdmFyIGVudHJpZXMgPSBbXTsKICBmb3IgKHZhciBrZXkgaW4gbWFwKSBlbnRyaWVzLnB1c2goe2tleToga2V5LCB2YWx1ZTogbWFwW2tleV19KTsKICByZXR1cm4gZW50cmllczsKfSk7CgoKLyoqKi8gfSksCgovKioqLyAiLi9ub2RlX21vZHVsZXMvZDMtY29sbGVjdGlvbi9zcmMvaW5kZXguanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9kMy1jb2xsZWN0aW9uL3NyYy9pbmRleC5qcyAqKiohCiAgXCoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBuZXN0LCBzZXQsIG1hcCwga2V5cywgdmFsdWVzLCBlbnRyaWVzICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGltcG9ydCAqLyB2YXIgX25lc3RfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzBfXyA9IF9fd2VicGFja19yZXF1aXJlX18oLyohIC4vbmVzdCAqLyAiLi9ub2RlX21vZHVsZXMvZDMtY29sbGVjdGlvbi9zcmMvbmVzdC5qcyIpOwovKiBoYXJtb255IHJlZXhwb3J0IChzYWZlKSAqLyBfX3dlYnBhY2tfcmVxdWlyZV9fLmQoX193ZWJwYWNrX2V4cG9ydHNfXywgIm5lc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KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2QzLWNvbGxlY3Rpb24vc3JjL2tleXMuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGRlZmF1bHQgZXhwb3J0ICovIF9fd2VicGFja19leHBvcnRzX19bImRlZmF1bHQiXSA9IChmdW5jdGlvbihtYXApIHsKICB2YXIga2V5cyA9IFtdOwogIGZvciAodmFyIGtleSBpbiBtYXApIGtleXMucHVzaChrZXkpOwogIHJldHVybiBrZXlzOwp9KTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1jb2xsZWN0aW9uL3NyYy9tYXAuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtY29sbGVjdGlvbi9zcmMvbWFwLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBwcmVmaXgsIGRlZmF1bHQgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgX193ZWJwYWNrX2V4cG9ydHNfXywgX193ZWJwYWNrX3JlcXVpcmVfXykgewoKInVzZSBzdHJpY3QiOwpfX3dlYnBhY2tfcmVxdWlyZV9fLnIoX193ZWJwYWNrX2V4cG9ydHNfXyk7Ci8qIGhhcm1vbnkgZXhwb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KTsKCiAgLy8gSW5kZXggYXJyYXkgYnkgbnVtZXJpYyBpbmRleCBvciBzcGVjaWZpZWQga2V5IGZ1bmN0aW9uLgogIGVsc2UgaWYgKEFycmF5LmlzQXJyYXkob2JqZWN0KSkgewogICAgdmFyIGkgPSAtMSwKICAgICAgICBuID0gb2JqZWN0Lmxlbmd0aCwKICAgICAgICBvOwoKICAgIGlmIChmID09IG51bGwpIHdoaWxlICgrK2kgPCBuKSBtYXAuc2V0KGksIG9iamVjdFtpXSk7CiAgICBlbHNlIHdoaWxlICgrK2kgPCBuKSBtYXAuc2V0KGYobyA9IG9iamVjdFtpXSwgaSwgb2JqZWN0KSwgbyk7CiAgfQoKICAvLyBDb252ZXJ0IG9iamVjdCB0byBtYXAuCiAgZWxzZSBpZiAob2JqZWN0KSBmb3IgKHZhciBrZXkgaW4gb2JqZWN0KSBtYXAuc2V0KGtleSwgb2JqZWN0W2tleV0pOwoKICByZXR1cm4gbWFwOwp9CgovKiBoYXJtb255IGRlZmF1bHQgZXhwb3J0ICovIF9fd2VicGFja19leHBvcnRzX19bImRlZmF1bHQiXSA9IChtYXApOwoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWNvbGxlY3Rpb24vc3JjL25lc3QuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2QzLWNvbGxlY3Rpb24vc3JjL25lc3QuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRz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ci4KICBpZiAob2JqZWN0IGluc3RhbmNlb2YgU2V0KSBvYmplY3QuZWFjaChmdW5jdGlvbih2YWx1ZSkgeyBzZXQuYWRkKHZhbHVlKTsgfSk7CgogIC8vIE90aGVyd2lzZSwgYXNzdW1lIGl04oCZcyBhbiBhcnJheS4KICBlbHNlIGlmIChvYmplY3QpIHsKICAgIHZhciBpID0gLTEsIG4gPSBvYmplY3QubGVuZ3RoOwogICAgaWYgKGYgPT0gbnVsbCkgd2hpbGUgKCsraSA8IG4pIHNldC5hZGQob2JqZWN0W2ldKTsKICAgIGVsc2Ugd2hpbGUgKCsraSA8IG4pIHNldC5hZGQoZihvYmplY3RbaV0sIGksIG9iamVjdCkpOwogIH0KCiAgcmV0dXJuIHNldDsKfQoKLyogaGFybW9ueSBkZWZhdWx0IGV4cG9ydCAqLyBfX3dlYnBhY2tfZXhwb3J0c19fWyJkZWZhdWx0Il0gPSAoc2V0KTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1jb2xsZWN0aW9uL3NyYy92YWx1ZXMuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtY29sbGVjdGlvbi9zcmMvdmFsdWVzLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGRlZmF1bHQgZXhwb3J0ICovIF9fd2VicGFja19leHBvcnRzX19bImRlZmF1bHQiXSA9IChmdW5jdGlvbihtYXAp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BrLCB0aGlzLm9wYWNpdHkpOwogIH0sCiAgcmdiOiBmdW5jdGlvbigpIHsKICAgIHZhciBoID0gdGhpcy5oICUgMzYwICsgKHRoaXMuaCA8IDApICogMzYwLAogICAgICAgIHMgPSBpc05hTihoKSB8fCBpc05hTih0aGlzLnMpID8gMCA6IHRoaXMucywKICAgICAgICBsID0gdGhpcy5sLAogICAgICAgIG0yID0gbCArIChsIDwgMC41ID8gbCA6IDEgLSBsKSAqIHMsCiAgICAgICAgbTEgPSAyICogbCAtIG0yOwogICAgcmV0dXJuIG5ldyBSZ2IoCiAgICAgIGhzbDJyZ2IoaCA+PSAyNDAgPyBoIC0gMjQwIDogaCArIDEyMCwgbTEsIG0yKSwKICAgICAgaHNsMnJnYihoLCBtMSwgbTIpLAogICAgICBoc2wycmdiKGggPCAxMjAgPyBoICsgMjQwIDogaCAtIDEyMCwgbTEsIG0yKSwKICAgICAgdGhpcy5vcGFjaXR5CiAgICApOwogIH0sCiAgZGlzcGxheWFibGU6IGZ1bmN0aW9uKCkgewogICAgcmV0dXJuICgwIDw9IHRoaXMucyAmJiB0aGlzLnMgPD0gMSB8fCBpc05hTih0aGlzLnMpKQogICAgICAgICYmICgwIDw9IHRoaXMubCAmJiB0aGlzLmwgPD0gMSkKICAgICAgICAmJiAoMCA8PSB0aGlzLm9wYWNpdHkgJiYgdGhpcy5vcGFjaXR5IDw9IDEpOwogIH0sCiAgZm9ybWF0SHNsOiBmdW5jdGlvbigpIHsKICAgIHZhciBhID0gdGhpcy5vcGFjaXR5OyBhID0gaXNOYU4oYSkgPyAxIDogTWF0aC5tYXgoMCwgTWF0aC5taW4oMSwgYSkpOwogICAgcmV0dXJuIChhID09PSAxID8gImhzbCgiIDogImhzbGEoIikKICAgICAgICArICh0aGlzLmggfHwgMCkgKyAiLCAiCiAgICAgICAgKyAodGhpcy5zIHx8IDApICogMTAwICsgIiUsICIKICAgICAgICArICh0aGlzLmwgfHwgMCkgKiAxMDAgKyAiJSIKICAgICAgICArI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ICByZXR1cm4gbmV3IF9jb2xvcl9qc19fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMV9fWyJSZ2IiXSgKICAgICAgMjU1ICogKGwgKyBhICogKEEgKiBjb3NoICsgQiAqIHNpbmgpKSwKICAgICAgMjU1ICogKGwgKyBhICogKEMgKiBjb3NoICsgRCAqIHNpbmgpKSwKICAgICAgMjU1ICogKGwgKyBhICogKEUgKiBjb3NoKSksCiAgICAgIHRoaXMub3BhY2l0eQogICAgKTsKICB9Cn0pKTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1jb2xvci9zcmMvZGVmaW5lLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9kMy1jb2xvci9zcmMvZGVmaW5lLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm92aWRlZDogZGVmYXVsdCwgZXh0ZW5kICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGV4cG9ydCAoYmluZGluZykgKi8gX193ZWJwYWNrX3JlcXVpcmVfXy5kKF9fd2VicGFja19leHBvcnRzX18sICJleHRlbmQiLCBmdW5jdGlvbigpIHsgcmV0dXJuIGV4dGVuZDsgfSk7Ci8qIGhhcm1vbnkgZGVmYXVsdCBleHBvcnQgKi8gX193ZWJwYWNrX2V4cG9ydHNfX1siZGVmYXVsdCJdID0gKGZ1bmN0aW9uKGNvbnN0cnVjdG9yLCBmYWN0b3J5LCBwcm90b3R5cGUpIHsKICBjb25zdHJ1Y3Rvci5wcm90b3R5cGUgPSB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IHJpbmdbaV1bMF0gLSByaW5nW2kgLSAxXVswXSAqIHJpbmdbaV1bMV07CiAgcmV0dXJuIGFyZWE7Cn0pOwoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWNvbnRvdXIvc3JjL2FycmF5LmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtY29udG91ci9zcmMvYXJyYXkuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm92aWRlZDogc2xpY2UgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgX193ZWJwYWNrX2V4cG9ydHNfXywgX193ZWJwYWNrX3JlcXVpcmVfXykgewoKInVzZSBzdHJpY3QiOwpfX3dlYnBhY2tfcmVxdWlyZV9fLnIoX193ZWJwYWNrX2V4cG9ydHNfXyk7Ci8qIGhhcm1vbnkgZXhwb3J0IChiaW5kaW5nKSAqLyBfX3dlYnBhY2tfcmVxdWlyZV9fLmQoX193ZWJwYWNrX2V4cG9ydHNfXywgInNsaWNlIiwgZnVuY3Rpb24oKSB7IHJldHVybiBzbGljZTsgfSk7CnZhciBhcnJheSA9IEFycmF5LnByb3RvdHlwZTsKCnZhciBzbGljZSA9IGFycmF5LnNsaWNlOwoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWNvbnRvdXIvc3JjL2FzY2VuZGluZy5qcyI6Ci8qISoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9kMy1jb250b3VyL3NyYy9hc2NlbmRpbmcuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohIGV4cG9ydHMgcH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BzciA9IDA7IGogPCBtICsgcjsgKytqKSB7CiAgICAgIGlmIChqIDwgbSkgewogICAgICAgIHNyICs9IHNvdXJjZS5kYXRhW2kgKyBqICogbl07CiAgICAgIH0KICAgICAgaWYgKGogPj0gcikgewogICAgICAgIGlmIChqID49IHcpIHsKICAgICAgICAgIHNyIC09IHNvdXJjZS5kYXRhW2kgKyAoaiAtIHcpICogbl07CiAgICAgICAgfQogICAgICAgIHRhcmdldC5kYXRhW2kgKyAoaiAtIHIpICogbl0gPSBzciAvIE1hdGgubWluKGogKyAxLCBtIC0gMSArIHcgLSBqLCB3KTsKICAgICAgfQogICAgfQogIH0KfQoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWNvbnRvdXIvc3JjL2NvbnN0YW50LmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtY29udG91ci9zcmMvY29uc3RhbnQuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm92aWRlZDogZGVmYXVsdCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBfX3dlYnBhY2tfZXhwb3J0c19fLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7Cl9fd2VicGFja19yZXF1aXJlX18ucihfX3dlYnBhY2tfZXhwb3J0c19fKTsKLyogaGFybW9ueSBkZWZhdWx0IGV4cG9ydCAqLyBfX3dlYnBhY2tfZXhwb3J0c19fWyJkZWZhdWx0Il0gPSAoZnVuY3Rpb24oeCkgewogIHJldHVybiBmdW5jdGlvbigpIHsKICAgIHJldHVybiB4OwogIH07Cn0pOwoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWNvbnRvdXIvc3JjL2NvbnRhaW5zLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtY29udG91ci9zcmMvY29udGFpbnMuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm92aWRlZDogZGVmYXVsdCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBfX3dlYnBhY2tfZXhwb3J0c19fLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7Cl9fd2VicGFja19yZXF1aXJlX18ucihfX3dlYnBhY2tfZXhwb3J0c19fKTsKLyogaGFybW9ueSBkZWZhdWx0IGV4cG9ydCAqLyBfX3dlYnBhY2tfZXhwb3J0c19fWyJkZWZhdWx0Il0gPSAoZnVuY3Rpb24ocmluZywgaG9sZSkgewogIHZhciBpID0gLTEsIG4gPSBob2xlLmxlbmd0aCwgYzsKICB3aGlsZSAoKytpIDwgbikgaWYgKGMgPSByaW5nQ29udGFpbnMocmluZywgaG9sZVtpXSkpIHJldHVybiBjOwogIHJldHVybiAwOwp9KTsKCmZ1bmN0aW9uIHJpbmdDb250YWlucyhyaW5nLCBwb2ludCkgewogIHZhciB4ID0gcG9pbnRbMF0sIHkgPSBwb2ludFsxXSwgY29udGFpbnMgPSAtMTsKICBmb3IgKHZhciBpID0gMCwgbiA9IHJpbmcubGVuZ3RoLCBqID0gbiAtIDE7IGkgPCBuOyBqID0gaSsrKSB7CiAgICB2YXIgcGkgPSByaW5nW2ldLCB4aSA9IHBpWzBdLCB5aSA9IHBpWzFdLCBwaiA9IHJpbmdbal0sIHhqID0gcGpbMF0sIHlqID0gcGpbMV07CiAgICBpZiAoc2VnbWVudENvbnRhaW5zKHBpLCBwaiwgcG9pbnQpKSByZXR1cm4gMDsKICAgIGlmICgoKHlpID4geSkgIT09ICh5aiA+IHkpKSAmJiAoKHggPC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G9jay9zaGFwZWZpbGUvYmxvYi92MC42LjIvc2hwL3BvbHlnb24uanMKICBmdW5jdGlvbiBjb250b3VyKHZhbHVlcywgdmFsdWUpIHsKICAgIHZhciBwb2x5Z29ucyA9IFtdLAogICAgICAgIGhvbGVzID0gW107CgogICAgaXNvcmluZ3ModmFsdWVzLCB2YWx1ZSwgZnVuY3Rpb24ocmluZykgewogICAgICBzbW9vdGgocmluZywgdmFsdWVzLCB2YWx1ZSk7CiAgICAgIGlmIChPYmplY3QoX2FyZWFfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzNfX1siZGVmYXVsdCJdKShyaW5nKSA+IDApIHBvbHlnb25zLnB1c2goW3JpbmddKTsKICAgICAgZWxzZSBob2xlcy5wdXNoKHJpbmcpOwogICAgfSk7CgogICAgaG9sZXMuZm9yRWFjaChmdW5jdGlvbihob2xlKSB7CiAgICAgIGZvciAodmFyIGkgPSAwLCBuID0gcG9seWdvbnMubGVuZ3RoLCBwb2x5Z29uOyBpIDwgbjsgKytpKSB7CiAgICAgICAgaWYgKE9iamVjdChfY29udGFpbnNfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzVfX1siZGVmYXVsdCJdKSgocG9seWdvbiA9IHBvbHlnb25zW2ldKVswXSwgaG9sZSkgIT09IC0xKSB7CiAgICAgICAgICBwb2x5Z29uLnB1c2goaG9sZSk7CiAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICB9CiAgICB9KTsKCiAgICByZXR1cm4gewogICAgICB0eXBlOiAiTXVsdGlQb2x5Z29uIiwKICAgICAgdmFsdWU6IHZhbHVlLAogICAgICBjb29yZGluYXRlczogcG9seWdvbnMKICAgIH07CiAgfQoKICAvLyBNYXJjaGluZyBzcXVhcmVzIHdpdGggaXNvbGluZXMgc3RpdGNoZWQgaW50byByaW5ncy4KICAvLyBCYXNlZCBvbiBodHRwczovL2dpdGh1Yi5jb20vdG9wb2pzb24vdG9wb2pzb24tY2xpZW50L2Jsb2IvdjMuM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YXJ0XTsKICAgICAgICAgIGlmIChmID09PSBnKSB7CiAgICAgICAgICAgIGYucmluZy5wdXNoKGVuZCk7CiAgICAgICAgICAgIGNhbGxiYWNrKGYucmluZyk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBmcmFnbWVudEJ5U3RhcnRbZi5zdGFydF0gPSBmcmFnbWVudEJ5RW5kW2cuZW5kXSA9IHtzdGFydDogZi5zdGFydCwgZW5kOiBnLmVuZCwgcmluZzogZi5yaW5nLmNvbmNhdChnLnJpbmcpfTsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGVsZXRlIGZyYWdtZW50QnlFbmRbZi5lbmRdOwogICAgICAgICAgZi5yaW5nLnB1c2goZW5kKTsKICAgICAgICAgIGZyYWdtZW50QnlFbmRbZi5lbmQgPSBlbmRJbmRleF0gPSBmOwogICAgICAgIH0KICAgICAgfSBlbHNlIGlmIChmID0gZnJhZ21lbnRCeVN0YXJ0W2VuZEluZGV4XSkgewogICAgICAgIGlmIChnID0gZnJhZ21lbnRCeUVuZFtzdGFydEluZGV4XSkgewogICAgICAgICAgZGVsZXRlIGZyYWdtZW50QnlTdGFydFtmLnN0YXJ0XTsKICAgICAgICAgIGRlbGV0ZSBmcmFnbWVudEJ5RW5kW2cuZW5kXTsKICAgICAgICAgIGlmIChmID09PSBnKSB7CiAgICAgICAgICAgIGYucmluZy5wdXNoKGVuZCk7CiAgICAgICAgICAgIGNhbGxiYWNrKGYucmluZyk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBmcmFnbWVudEJ5U3RhcnRbZy5zdGFydF0gPSBmcmFnbWVudEJ5RW5kW2YuZW5kXSA9IHtzdGFydDogZy5zdGFydCwgZW5kOiBmLmVuZCwgcmluZzogZy5yaW5nLmNvbmNhdChmLnJpbmcpfTsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGVsZXRlIGZyYWdtZW50QnlTdGFydFtmLnN0YXJ0XTsKICAgICAgICAgIGYucmluZy51bnNoaWZ0KHN0YXJ0KTsKICAgICAgICAgIGZyYWdtZW50QnlTdGFydFtmLnN0YXJ0ID0gc3RhcnRJbmRleF0gPSBmOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBmcmFnbWVudEJ5U3RhcnRbc3RhcnRJbmRleF0gPSBmcmFnbWVudEJ5RW5kW2VuZEluZGV4XSA9IHtzdGFydDogc3RhcnRJbmRleCwgZW5kOiBlbmRJbmRleCwgcmluZzogW3N0YXJ0LCBlbmRdfTsKICAgICAgfQogICAgfQogIH0KCiAgZnVuY3Rpb24gaW5kZXgocG9pbnQpIHsKICAgIHJldHVybiBwb2ludFswXSAqIDIgKyBwb2ludFsxXSAqIChkeCArIDEpICogNDsKICB9CgogIGZ1bmN0aW9uIHNtb290aExpbmVhcihyaW5nLCB2YWx1ZXMsIHZhbHVlKSB7CiAgICByaW5nLmZvckVhY2goZnVuY3Rpb24ocG9pbnQpIHsKICAgICAgdmFyIHggPSBwb2ludFswXSwKICAgICAgICAgIHkgPSBwb2ludFsxXSwKICAgICAgICAgIHh0ID0geCB8IDAsCiAgICAgICAgICB5dCA9IHkgfCAwLAogICAgICAgICAgdjAsCiAgICAgICAgICB2MSA9IHZhbHVlc1t5dCAqIGR4ICsgeHRdOwogICAgICBpZiAoeCA+IDAgJiYgeCA8IGR4ICYmIHh0ID09PSB4KSB7CiAgICAgICAgdjAgPSB2YWx1ZXNbeXQgKiBkeCArIHh0IC0gMV07CiAgICAgICAgcG9pbnRbMF0gPSB4ICsgKHZhbHVlIC0gdjApIC8gKHYxIC0gdjApIC0gMC41OwogICAgICB9CiAgICAgIGlmICh5ID4gMCAmJiB5IDwgZHkgJiYgeXQgPT09IHkpIHsKICAgICAgICB2MCA9IHZhbHVlc1soeXQgLSAxKSAqIGR4ICsgeHRdOwogICAgICAgIHBvaW50WzFdID0geSArICh2YWx1ZSAtIHYwKSAvICh2MSAtIHYwKSAtIDAuNTsKICAgICAgfQog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TsKLyogaGFybW9ueSByZWV4cG9ydCAoc2FmZSkgKi8gX193ZWJwYWNrX3JlcXVpcmVfXy5kKF9fd2VicGFja19leHBvcnRzX18sICJjb250b3VyRGVuc2l0eSIsIGZ1bmN0aW9uKCkgeyByZXR1cm4gX2RlbnNpdHlfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzFfX1siZGVmYXVsdCJdOyB9KTsKCgoKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1jb250b3VyL3NyYy9ub29wLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9kMy1jb250b3VyL3NyYy9ub29wLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm92aWRlZDogZGVmYXVsdCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBfX3dlYnBhY2tfZXhwb3J0c19fLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7Cl9fd2VicGFja19yZXF1aXJlX18ucihfX3dlYnBhY2tfZXhwb3J0c19fKTsKLyogaGFybW9ueSBkZWZhdWx0IGV4cG9ydCAqLyBfX3dlYnBhY2tfZXhwb3J0c19fWyJkZWZhdWx0Il0gPSAoZnVuY3Rpb24oKSB7fSk7CgoKLyoqKi8gfSksCgovKioqLyAiLi9ub2RlX21vZHVsZXMvZDMtZGlzcGF0Y2gvc3JjL2Rpc3BhdGNoLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2QzLWRpc3BhdGNoL3NyYy9kaXNwYXRjaC5qcyAqKiohCiAgXCoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiE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SAyKSA8IDEgPyB0ICogdCAqICgocyArIDEpICogdCAtIHMpIDogKHQgLT0gMikgKiB0ICogKChzICsgMSkgKiB0ICsgcykgKyAyKSAvIDI7CiAgfQoKICBiYWNrSW5PdXQub3ZlcnNob290ID0gY3VzdG9tOwoKICByZXR1cm4gYmFja0luT3V0Owp9KShvdmVyc2hvb3QpOwoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWVhc2Uvc3JjL2JvdW5jZS5qcyI6Ci8qISoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9kMy1lYXNlL3NyYy9ib3VuY2UuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohIGV4cG9ydHMgcHJvdmlkZWQ6IGJvdW5jZUluLCBib3VuY2VPdXQsIGJvdW5jZUluT3V0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGV4cG9ydCAoYmluZGluZykgKi8gX193ZWJwYWNrX3JlcXVpcmVfXy5kKF9fd2VicGFja19leHBvcnRzX18sICJib3VuY2VJbiIsIGZ1bmN0aW9uKCkgeyByZXR1cm4gYm91bmNlSW47IH0pOwovKiBoYXJtb255IGV4cG9ydCAoYmluZGluZykgKi8gX193ZWJwYWNrX3JlcXVpcmVfXy5kKF9fd2VicGFja19leHBvcnRzX18sICJib3VuY2VPdXQiLCBmdW5jdGlvbigpIHsgcmV0dXJuIGJvdW5jZU91dDsgfSk7Ci8qIGhhcm1vbnkgZXhwb3J0IChiaW5kaW5nKSAqLyBfX3dlYnBhY2tfcmVxdWlyZV9fLmQoX193ZWJwY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qKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2QzLWVhc2Uvc3JjL2xpbmVhci5qcyAqKiohCiAgXCoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm92aWRlZDogbGluZWFyICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGV4cG9ydCAoYmluZGluZykgKi8gX193ZWJwYWNrX3JlcXVpcmVfXy5kKF9fd2VicGFja19leHBvcnRzX18sICJsaW5lYXIiLCBmdW5jdGlvbigpIHsgcmV0dXJuIGxpbmVhcjsgfSk7CmZ1bmN0aW9uIGxpbmVhcih0KSB7CiAgcmV0dXJuICt0Owp9CgoKLyoqKi8gfSksCgovKioqLyAiLi9ub2RlX21vZHVsZXMvZDMtZWFzZS9zcmMvcG9seS5qcyI6Ci8qISoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtZWFzZS9zcmMvcG9seS5qcyAqKiohCiAgXCoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohIGV4cG9ydHMgcHJvdmlkZWQ6IHBvbHlJbiwgcG9seU91dCwgcG9seUluT3V0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGV4cG9ydCAoYmluZGluZykgKi8gX193ZWJwYWNrX3JlcXVpcmVfXy5kKF9fd2VicGFja19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WRPdXQodCkgewogIHJldHVybiB0ICogKDIgLSB0KTsKfQoKZnVuY3Rpb24gcXVhZEluT3V0KHQpIHsKICByZXR1cm4gKCh0ICo9IDIpIDw9IDEgPyB0ICogdCA6IC0tdCAqICgyIC0gdCkgKyAxKSAvIDI7Cn0KCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1lYXNlL3NyYy9zaW4uanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtZWFzZS9zcmMvc2luLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBzaW5Jbiwgc2luT3V0LCBzaW5Jbk91dCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBfX3dlYnBhY2tfZXhwb3J0c19fLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7Cl9fd2VicGFja19yZXF1aXJlX18ucihfX3dlYnBhY2tfZXhwb3J0c19fKTsKLyogaGFybW9ueSBleHBvcnQgKGJpbmRpbmcpICovIF9fd2VicGFja19yZXF1aXJlX18uZChfX3dlYnBhY2tfZXhwb3J0c19fLCAic2luSW4iLCBmdW5jdGlvbigpIHsgcmV0dXJuIHNpbkluOyB9KTsKLyogaGFybW9ueSBleHBvcnQgKGJpbmRpbmcpICovIF9fd2VicGFja19yZXF1aXJlX18uZChfX3dlYnBhY2tfZXhwb3J0c19fLCAic2luT3V0IiwgZnVuY3Rpb24oKSB7IHJldHVybiBzaW5PdXQ7IH0pOwovKiBoYXJtb255IGV4cG9ydCAoYmluZGluZykgKi8gX193ZWJwYWNrX3JlcXVpcmVfXy5kKF9fd2VicGFja19leHBvcnRzX18sICJzaW5Jbk91dCIsIGZ1bmN0aW9uKCkgeyByZXR1cm4gc2luSW5PdXQ7IH0pOwp2YXIgcGk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CiAgICAgIHJhZGlpLAogICAgICBzdHJlbmd0aCA9IDEsCiAgICAgIGl0ZXJhdGlvbnMgPSAxOwoKICBpZiAodHlwZW9mIHJhZGl1cyAhPT0gImZ1bmN0aW9uIikgcmFkaXVzID0gT2JqZWN0KF9jb25zdGFudF9fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMF9fWyJkZWZhdWx0Il0pKHJhZGl1cyA9PSBudWxsID8gMSA6ICtyYWRpdXMpOwoKICBmdW5jdGlvbiBmb3JjZSgpIHsKICAgIHZhciBpLCBuID0gbm9kZXMubGVuZ3RoLAogICAgICAgIHRyZWUsCiAgICAgICAgbm9kZSwKICAgICAgICB4aSwKICAgICAgICB5aSwKICAgICAgICByaSwKICAgICAgICByaTI7CgogICAgZm9yICh2YXIgayA9IDA7IGsgPCBpdGVyYXRpb25zOyArK2spIHsKICAgICAgdHJlZSA9IE9iamVjdChkM19xdWFkdHJlZV9fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMl9fWyJxdWFkdHJlZSJdKShub2RlcywgeCwgeSkudmlzaXRBZnRlcihwcmVwYXJlKTsKICAgICAgZm9yIChpID0gMDsgaSA8IG47ICsraSkgewogICAgICAgIG5vZGUgPSBub2Rlc1tpXTsKICAgICAgICByaSA9IHJhZGlpW25vZGUuaW5kZXhdLCByaTIgPSByaSAqIHJpOwogICAgICAgIHhpID0gbm9kZS54ICsgbm9kZS52eDsKICAgICAgICB5aSA9IG5vZGUueSArIG5vZGUudnk7CiAgICAgICAgdHJlZS52aXNpdChhcHBseSk7CiAgICAgIH0KICAgIH0KCiAgICBmdW5jdGlvbiBhcHBseShxdWFkLCB4MCwgeTAsIHgxLCB5MSkgewogICAgICB2YXIgZGF0YSA9IHF1YWQuZGF0YSwgcmogPSBxdWFkLnIsIHIgPSByaSArIHJqOwogICAgICBpZiAoZGF0YSkgewogICAgICAgIGlmIChkYXRhLmluZGV4ID4gbm9kZS5pbmRleCkgewogICAgICAgICAgdmFyIHggPSB4aSAtIGRhdGEueCAtIGRhdGEudngsCiAgICAgICAgICAgICAgeSA9IHlpIC0gZGF0YS55IC0gZGF0YS52eSwKICAgICAgICAgICAgICBsID0geCAqIHggKyB5ICogeTsKICAgICAgICAgIGlmIChsIDwgciAqIHIpIHsKICAgICAgICAgICAgaWYgKHggPT09IDApIHggPSBPYmplY3QoX2ppZ2dsZV9fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMV9fWyJkZWZhdWx0Il0pKCksIGwgKz0geCAqIHg7CiAgICAgICAgICAgIGlmICh5ID09PSAwKSB5ID0gT2JqZWN0KF9qaWdnbGVfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzFfX1siZGVmYXVsdCJdKSgpLCBsICs9IHkgKiB5OwogICAgICAgICAgICBsID0gKHIgLSAobCA9IE1hdGguc3FydChsKSkpIC8gbCAqIHN0cmVuZ3RoOwogICAgICAgICAgICBub2RlLnZ4ICs9ICh4ICo9IGwpICogKHIgPSAocmogKj0gcmopIC8gKHJpMiArIHJqKSk7CiAgICAgICAgICAgIG5vZGUudnkgKz0gKHkgKj0gbCkgKiByOwogICAgICAgICAgICBkYXRhLnZ4IC09IHggKiAociA9IDEgLSByKTsKICAgICAgICAgICAgZGF0YS52eSAtPSB5ICogcjsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIHJldHVybiB4MCA+IHhpICsgciB8fCB4MSA8IHhpIC0gciB8fCB5MCA+IHlpICsgciB8fCB5MSA8IHlpIC0gcjsKICAgIH0KICB9CgogIGZ1bmN0aW9uIHByZXBhcmUocXVhZCkgewogICAgaWYgKHF1YWQuZGF0YSkgcmV0dXJuIHF1YWQuciA9IHJhZGlpW3F1YWQuZGF0YS5pbmRleF07CiAgICBmb3IgKHZhciBpID0gcXVhZC5yID0gMDsgaSA8IDQ7ICsraSkgewogICAgICBpZiAocXVhZFtpXSAmJiBxdWFkW2ldLnIgPiBxdWFkLnIpIHsKICAgICAgICBxdWF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qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtZm9yY2Uvc3JjL2NvbnN0YW50LmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGRlZmF1bHQgZXhwb3J0ICovIF9fd2VicGFja19leHBvcnRzX19bImRlZmF1bHQiXSA9IChmdW5jdGlvbih4KSB7CiAgcmV0dXJuIGZ1bmN0aW9uKCkgewogICAgcmV0dXJuIHg7CiAgfTsKfSk7CgoKLyoqKi8gfSksCgovKioqLyAiLi9ub2RlX21vZHVsZXMvZDMtZm9yY2Uvc3JjL2luZGV4LmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2QzLWZvcmNlL3NyYy9pbmRleC5qcyAqKiohCiAgXCoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm92aWRlZDogZm9yY2VDZW50ZXIsIGZvcmNlQ29sbGlkZSwgZm9yY2VMaW5rLCBmb3JjZU1hbnlCb2R5LCBmb3JjZVJhZGlhbCwgZm9yY2VTaW11bGF0aW9uLCBmb3JjZVgsIGZvcmNlWSAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBfX3dlYnBhY2tfZXhwb3J0c19fLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7Cl9fd2VicGFja19yZ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KCgoKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1mb3JjZS9zcmMvamlnZ2xlLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9kMy1mb3JjZS9zcmMvamlnZ2xlLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm92aWRlZDogZGVmYXVsdCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBfX3dlYnBhY2tfZXhwb3J0c19fLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7Cl9fd2VicGFja19yZXF1aXJlX18ucihfX3dlYnBhY2tfZXhwb3J0c19fKTsKLyogaGFybW9ueSBkZWZhdWx0IGV4cG9ydCAqLyBfX3dlYnBhY2tfZXhwb3J0c19fWyJkZWZhdWx0Il0gPSAoZnVuY3Rpb24oKSB7CiAgcmV0dXJuIChNYXRoLnJhbmRvbSgpIC0gMC41KSAqIDFlLTY7Cn0pOwoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWZvcmNlL3NyYy9saW5rLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtZm9yY2Uvc3JjL2xpbmsuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm92aWRlZDogZGVmYXVsdCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBfX3dlYnBhY2tfZXhwb3J0c19fLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7Cl9fd2VicGFja19yZXF1aXJlX18ucihfX3dlYnBhY2tfZXhw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ogc3RyZW5ndGhzW2ldOwogICAgICAgIHggKj0gbCwgeSAqPSBsOwogICAgICAgIHRhcmdldC52eCAtPSB4ICogKGIgPSBiaWFzW2ldKTsKICAgICAgICB0YXJnZXQudnkgLT0geSAqIGI7CiAgICAgICAgc291cmNlLnZ4ICs9IHggKiAoYiA9IDEgLSBiKTsKICAgICAgICBzb3VyY2UudnkgKz0geSAqIGI7CiAgICAgIH0KICAgIH0KICB9CgogIGZ1bmN0aW9uIGluaXRpYWxpemUoKSB7CiAgICBpZiAoIW5vZGVzKSByZXR1cm47CgogICAgdmFyIGksCiAgICAgICAgbiA9IG5vZGVzLmxlbmd0aCwKICAgICAgICBtID0gbGlua3MubGVuZ3RoLAogICAgICAgIG5vZGVCeUlkID0gT2JqZWN0KGQzX2NvbGxlY3Rpb25fX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzJfX1sibWFwIl0pKG5vZGVzLCBpZCksCiAgICAgICAgbGluazsKCiAgICBmb3IgKGkgPSAwLCBjb3VudCA9IG5ldyBBcnJheShuKTsgaSA8IG07ICsraSkgewogICAgICBsaW5rID0gbGlua3NbaV0sIGxpbmsuaW5kZXggPSBpOwogICAgICBpZiAodHlwZW9mIGxpbmsuc291cmNlICE9PSAib2JqZWN0IikgbGluay5zb3VyY2UgPSBmaW5kKG5vZGVCeUlkLCBsaW5rLnNvdXJjZSk7CiAgICAgIGlmICh0eXBlb2YgbGluay50YXJnZXQgIT09ICJvYmplY3QiKSBsaW5rLnRhcmdldCA9IGZpbmQobm9kZUJ5SWQsIGxpbmsudGFyZ2V0KTsKICAgICAgY291bnRbbGluay5zb3VyY2UuaW5kZXhdID0gKGNvdW50W2xpbmsuc291cmNlLmluZGV4XSB8fCAwKSArIDE7CiAgICAgIGNvdW50W2xpbmsudGFyZ2V0LmluZGV4XSA9IChjb3VudFtsaW5rLnRhcmdldC5pbmRleF0gfHwgMCkgKyAxOwogICAgfQoKICAgIGZvciAoaSA9IDAsIGJpYXMgPSBuZXcgQXJ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KICAgIGZpbmQ6IGZ1bmN0aW9uKHgsIHksIHJhZGl1cykgewogICAgICB2YXIgaSA9IDAsCiAgICAgICAgICBuID0gbm9kZXMubGVuZ3RoLAogICAgICAgICAgZHgsCiAgICAgICAgICBkeSwKICAgICAgICAgIGQyLAogICAgICAgICAgbm9kZSwKICAgICAgICAgIGNsb3Nlc3Q7CgogICAgICBpZiAocmFkaXVzID09IG51bGwpIHJhZGl1cyA9IEluZmluaXR5OwogICAgICBlbHNlIHJhZGl1cyAqPSByYWRpdXM7CgogICAgICBmb3IgKGkgPSAwOyBpIDwgbjsgKytpKSB7CiAgICAgICAgbm9kZSA9IG5vZGVzW2ldOwogICAgICAgIGR4ID0geCAtIG5vZGUueDsKICAgICAgICBkeSA9IHkgLSBub2RlLnk7CiAgICAgICAgZDIgPSBkeCAqIGR4ICsgZHkgKiBkeTsKICAgICAgICBpZiAoZDIgPCByYWRpdXMpIGNsb3Nlc3QgPSBub2RlLCByYWRpdXMgPSBkMjsKICAgICAgfQoKICAgICAgcmV0dXJuIGNsb3Nlc3Q7CiAgICB9LAoKICAgIG9uOiBmdW5jdGlvbihuYW1lLCBfKSB7CiAgICAgIHJldHVybiBhcmd1bWVudHMubGVuZ3RoID4gMSA/IChldmVudC5vbihuYW1lLCBfKSwgc2ltdWxhdGlvbikgOiBldmVudC5vbihuYW1lKTsKICAgIH0KICB9Owp9KTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1mb3JjZS9zcmMveC5qcyI6Ci8qISoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2QzLWZvcmNlL3NyYy94LmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohIGV4cG9ydHMgcHJvdmlkZWQ6IGRlZmF1bHQgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgX193ZWJwYWNrX2V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VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMF9fID0gX193ZWJwYWNrX3JlcXVpcmVfXygvKiEgLi9mb3JtYXREZWNpbWFsLmpzICovICIuL25vZGVfbW9kdWxlcy9kMy1mb3JtYXQvc3JjL2Zvcm1hdERlY2ltYWwuanMiKTsKCgovKiBoYXJtb255IGRlZmF1bHQgZXhwb3J0ICovIF9fd2VicGFja19leHBvcnRzX19bImRlZmF1bHQiXSA9IChmdW5jdGlvbih4KSB7CiAgcmV0dXJuIHggPSBPYmplY3QoX2Zvcm1hdERlY2ltYWxfanNfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzBfX1siZGVmYXVsdCJdKShNYXRoLmFicyh4KSksIHggPyB4WzFdIDogTmFOOwp9KTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1mb3JtYXQvc3JjL2Zvcm1hdERlY2ltYWwuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtZm9ybWF0L3NyYy9mb3JtYXREZWNpbWFsLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovLyBDb21wdXRlcyB0aGUgZGVjaW1hbCBjb2VmZmljaWVudCBhbmQgZXhwb25lbnQgb2YgdGhlIHNwZWNpZmllZCBudW1iZXIgeCB3aXRoCi8vIHNpZ25pZmljYW50IGRpZ2l0cyBwLCB3aGVyZSB4IGlzIHBvc2l0aXZlIGFuZC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hdE51bWVyYWxzLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm92aWRlZDogZGVmYXVsdCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBfX3dlYnBhY2tfZXhwb3J0c19fLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7Cl9fd2VicGFja19yZXF1aXJlX18ucihfX3dlYnBhY2tfZXhwb3J0c19fKTsKLyogaGFybW9ueSBkZWZhdWx0IGV4cG9ydCAqLyBfX3dlYnBhY2tfZXhwb3J0c19fWyJkZWZhdWx0Il0gPSAoZnVuY3Rpb24obnVtZXJhbHMpIHsKICByZXR1cm4gZnVuY3Rpb24odmFsdWUpIHsKICAgIHJldHVybiB2YWx1ZS5yZXBsYWNlKC9bMC05XS9nLCBmdW5jdGlvbihpKSB7CiAgICAgIHJldHVybiBudW1lcmFsc1sraV07CiAgICB9KTsKICB9Owp9KTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1mb3JtYXQvc3JjL2Zvcm1hdFByZWZpeEF1dG8uanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtZm9ybWF0L3NyYy9mb3JtYXRQcmVmaXhBdXRvLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBwcmVmaXhFeHBvbmVudCwgZGVmYXVsdCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBfX3dlYnBhY2tfZXhwb3J0c19fLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7Cl9fd2VicGFja19yZXF1aXJlX18ucihfX3dl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19bImRlZmF1bHQiXSA9IChmdW5jdGlvbih4LCBwKSB7CiAgdmFyIGQgPSBPYmplY3QoX2Zvcm1hdERlY2ltYWxfanNfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzBfX1siZGVmYXVsdCJdKSh4LCBwKTsKICBpZiAoIWQpIHJldHVybiB4ICsgIiI7CiAgdmFyIGNvZWZmaWNpZW50ID0gZFswXSwKICAgICAgZXhwb25lbnQgPSBkWzFdOwogIHJldHVybiBleHBvbmVudCA8IDAgPyAiMC4iICsgbmV3IEFycmF5KC1leHBvbmVudCkuam9pbigiMCIpICsgY29lZmZpY2llbnQKICAgICAgOiBjb2VmZmljaWVudC5sZW5ndGggPiBleHBvbmVudCArIDEgPyBjb2VmZmljaWVudC5zbGljZSgwLCBleHBvbmVudCArIDEpICsgIi4iICsgY29lZmZpY2llbnQuc2xpY2UoZXhwb25lbnQgKyAxKQogICAgICA6IGNvZWZmaWNpZW50ICsgbmV3IEFycmF5KGV4cG9uZW50IC0gY29lZmZpY2llbnQubGVuZ3RoICsgMikuam9pbigiMCIpOwp9KTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1mb3JtYXQvc3JjL2Zvcm1hdFNwZWNpZmllci5qcyI6Ci8qISoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2QzLWZvcm1hdC9zcmMvZm9ybWF0U3BlY2lmaWVyLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohIGV4cG9ydHMgcHJvdmlkZWQ6IGRlZmF1bHQsIEZvcm1hdFNwZWNpZmllciAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBfX3dlYnBhY2tfZXhwb3J0c19fLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7Cl9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sKICByZXR1cm4gdGhpcy5maWxsCiAgICAgICsgdGhpcy5hbGlnbgogICAgICArIHRoaXMuc2lnbgogICAgICArIHRoaXMuc3ltYm9sCiAgICAgICsgKHRoaXMuemVybyA/ICIwIiA6ICIiKQogICAgICArICh0aGlzLndpZHRoID09PSB1bmRlZmluZWQgPyAiIiA6IE1hdGgubWF4KDEsIHRoaXMud2lkdGggfCAwKSkKICAgICAgKyAodGhpcy5jb21tYSA/ICIsIiA6ICIiKQogICAgICArICh0aGlzLnByZWNpc2lvbiA9PT0gdW5kZWZpbmVkID8gIiIgOiAiLiIgKyBNYXRoLm1heCgwLCB0aGlzLnByZWNpc2lvbiB8IDApKQogICAgICArICh0aGlzLnRyaW0gPyAifiIgOiAiIikKICAgICAgKyB0aGlzLnR5cGU7Cn07CgoKLyoqKi8gfSksCgovKioqLyAiLi9ub2RlX21vZHVsZXMvZDMtZm9ybWF0L3NyYy9mb3JtYXRUcmltLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2QzLWZvcm1hdC9zcmMvZm9ybWF0VHJpbS5qcyAqKiohCiAgXCoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm92aWRlZDogZGVmYXVsdCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBfX3dlYnBhY2tfZXhwb3J0c19fLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7Cl9fd2VicGFja19yZXF1aXJlX18ucihfX3dlYnBhY2tfZXhwb3J0c19fKTsKLy8gVHJpbXMgaW5zaWduaWZpY2FudCB6ZXJvcywgZS5nLiwgcmVwbGFjZXMgMS4yMDAwayB3aXRoIDEuMmsuCi8qIGhhcm1vbnkgZGVmYXVsdCBleHBvcnQgKi8gX193ZWJwYWNrX2V4cG9ydHNfX1si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x0Il0pKHggKiAxMDAsIHApOyB9LAogICJyIjogX2Zvcm1hdFJvdW5kZWRfanNfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzFfX1siZGVmYXVsdCJdLAogICJzIjogX2Zvcm1hdFByZWZpeEF1dG9fanNfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzBfX1siZGVmYXVsdCJdLAogICJYIjogZnVuY3Rpb24oeCkgeyByZXR1cm4gTWF0aC5yb3VuZCh4KS50b1N0cmluZygxNikudG9VcHBlckNhc2UoKTsgfSwKICAieCI6IGZ1bmN0aW9uKHgpIHsgcmV0dXJuIE1hdGgucm91bmQoeCkudG9TdHJpbmcoMTYpOyB9Cn0pOwoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWZvcm1hdC9zcmMvaWRlbnRpdHkuanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiohKlwKICAhKioqIC4vbm9kZV9tb2R1bGVzL2QzLWZvcm1hdC9zcmMvaWRlbnRpdHkuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGRlZmF1bHQgZXhwb3J0ICovIF9fd2VicGFja19leHBvcnRzX19bImRlZmF1bHQiXSA9IChmdW5jdGlvbih4KSB7CiAgcmV0dXJuIHg7Cn0pOwoKCi8qKiovIH0pLAoKLyoqKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWZvcm1hdC9zcmMvaW5kZXguanMiOgovKiEqKioqKioqKioqKioqKio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Lm1heCgtOCwgTWF0aC5taW4oOCwgTWF0aC5mbG9vcihPYmplY3QoX2V4cG9uZW50X2pzX19XRUJQQUNLX0lNUE9SVEVEX01PRFVMRV8wX19bImRlZmF1bHQiXSkodmFsdWUpIC8gMykpKSAqIDMsCiAgICAgICAgayA9IE1hdGgucG93KDEwLCAtZSksCiAgICAgICAgcHJlZml4ID0gcHJlZml4ZXNbOCArIGUgLyAzXTsKICAgIHJldHVybiBmdW5jdGlvbih2YWx1ZSkgewogICAgICByZXR1cm4gZihrICogdmFsdWUpICsgcHJlZml4OwogICAgfTsKICB9CgogIHJldHVybiB7CiAgICBmb3JtYXQ6IG5ld0Zvcm1hdCwKICAgIGZvcm1hdFByZWZpeDogZm9ybWF0UHJlZml4CiAgfTsKfSk7CgoKLyoqKi8gfSksCgovKioqLyAiLi9ub2RlX21vZHVsZXMvZDMtZm9ybWF0L3NyYy9wcmVjaXNpb25GaXhlZC5qcyI6Ci8qISoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtZm9ybWF0L3NyYy9wcmVjaXNpb25GaXhlZC5qcyAqKiohCiAgXCoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohIGV4cG9ydHMgcHJvdmlkZWQ6IGRlZmF1bHQgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgX193ZWJwYWNrX2V4cG9ydHNfXywgX193ZWJwYWNrX3JlcXVpcmVfXykgewoKInVzZSBzdHJpY3QiOwpfX3dlYnBhY2tfcmVxdWlyZV9fLnIoX193ZWJwYWNrX2V4cG9ydHNfXyk7Ci8qIGhhcm1vbnkgaW1wb3J0ICovIHZhciBfZXhwb25lbnRfanNfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzBfXyA9IF9fd2VicGFja19yZXF1aXJlX18oLyohIC4vZXhwb25lbnQuanMgKi8gIi4vbm9kZV9tb2R1bGVzL2QzLWZvcm1hdC9zcmMvZXhwb25lbnQuanMiKTsKCgovKiBoYXJtb255IGRlZmF1bHQgZXhwb3J0ICovIF9fd2VicGFja19leHBvcnRzX19bImRlZmF1bHQiXSA9IChmdW5jdGlvbihzdGVwKSB7CiAgcmV0dXJuIE1hdGgubWF4KDAsIC1PYmplY3QoX2V4cG9uZW50X2pzX19XRUJQQUNLX0lNUE9SVEVEX01PRFVMRV8wX19bImRlZmF1bHQiXSkoTWF0aC5hYnMoc3RlcCkpKTsKfSk7CgoKLyoqKi8gfSksCgovKioqLyAiLi9ub2RlX21vZHVsZXMvZDMtZm9ybWF0L3NyYy9wcmVjaXNpb25QcmVmaXguanMiOgovKiEqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9kMy1mb3JtYXQvc3JjL3ByZWNpc2lvblByZWZpeC5qcyAqKiohCiAgXCoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qISBleHBvcnRzIHByb3ZpZGVkOiBkZWZhdWx0ICovCi8qKiovIChmdW5jdGlvbihtb2R1bGUsIF9fd2VicGFja19leHBvcnRzX18sIF9fd2VicGFja19yZXF1aXJlX18pIHsKCiJ1c2Ugc3RyaWN0IjsKX193ZWJwYWNrX3JlcXVpcmVfXy5yKF9fd2VicGFja19leHBvcnRzX18pOwovKiBoYXJtb255IGltcG9ydCAqLyB2YXIgX2V4cG9uZW50X2pzX19XRUJQQUNLX0lNUE9SVEVEX01PRFVMRV8wX18gPSBfX3dlYnBhY2tfcmVxdWlyZV9fKC8qISAuL2V4cG9uZW50LmpzICovICIuL25vZGVfbW9kdWxlcy9kMy1mb3JtYXQvc3JjL2V4cG9uZW50LmpzIik7CgoKLyogaGFybW9ueSBkZWZhdWx0IGV4cG9ydCAqLyBfX3dlYnBhY2tfZXhwb3J0c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ZShsYW1iZGEgKyAobGFtYmRhIDwgMCA/IF9tYXRoX2pzX19XRUJQQUNLX0lNUE9SVEVEX01PRFVMRV8yX19bInBpIl0gOiAtX21hdGhfanNfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzJfX1sicGkiXSksIHBoaSkgOiAwOwogICAgICAgIGlmICghcG9pbnQwICYmICh2MDAgPSB2MCA9IHYpKSBzdHJlYW0ubGluZVN0YXJ0KCk7CiAgICAgICAgLy8gSGFuZGxlIGRlZ2VuZXJhY2llcy4KICAgICAgICAvLyBUT0RPIGlnbm9yZSBpZiBub3QgY2xpcHBpbmcgcG9seWdvbnMuCiAgICAgICAgaWYgKHYgIT09IHYwKSB7CiAgICAgICAgICBwb2ludDIgPSBpbnRlcnNlY3QocG9pbnQwLCBwb2ludDEpOwogICAgICAgICAgaWYgKCFwb2ludDIgfHwgT2JqZWN0KF9wb2ludEVxdWFsX2pzX19XRUJQQUNLX0lNUE9SVEVEX01PRFVMRV8zX19bImRlZmF1bHQiXSkocG9pbnQwLCBwb2ludDIpIHx8IE9iamVjdChfcG9pbnRFcXVhbF9qc19fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfM19fWyJkZWZhdWx0Il0pKHBvaW50MSwgcG9pbnQyKSkgewogICAgICAgICAgICBwb2ludDFbMF0gKz0gX21hdGhfanNfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzJfX1siZXBzaWxvbiJdOwogICAgICAgICAgICBwb2ludDFbMV0gKz0gX21hdGhfanNfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzJfX1siZXBzaWxvbiJdOwogICAgICAgICAgICB2ID0gdmlzaWJsZShwb2ludDFbMF0sIHBvaW50MVsxXSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmICh2ICE9PSB2MCkgewogICAgICAgICAgY2xlYW4gPSAwOwogICAgICAgICAgaWYgKHYpIHsKICAgICAgICAgICAgLy8gb3V0c2lkZSBnb2luZyBpbgogICAgICAgICAgICBzdHJlYW0ubGluZVN0YXJ0KCk7CiAgICAgICAgICAgIHBvaW50MiA9IGludGVyc2VjdChwb2ludDEsIHBvaW50MCk7CiAgICAgICAgICAgIHN0cmVhbS5wb2ludChwb2ludDJbMF0sIHBvaW50MlsxXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAvLyBpbnNpZGUgZ29pbmcgb3V0CiAgICAgICAgICAgIHBvaW50MiA9IGludGVyc2VjdChwb2ludDAsIHBvaW50MSk7CiAgICAgICAgICAgIHN0cmVhbS5wb2ludChwb2ludDJbMF0sIHBvaW50MlsxXSk7CiAgICAgICAgICAgIHN0cmVhbS5saW5lRW5kKCk7CiAgICAgICAgICB9CiAgICAgICAgICBwb2ludDAgPSBwb2ludDI7CiAgICAgICAgfSBlbHNlIGlmIChub3RIZW1pc3BoZXJlICYmIHBvaW50MCAmJiBzbWFsbFJhZGl1cyBeIHYpIHsKICAgICAgICAgIHZhciB0OwogICAgICAgICAgLy8gSWYgdGhlIGNvZGVzIGZvciB0d28gcG9pbnRzIGFyZSBkaWZmZXJlbnQsIG9yIGFyZSBib3RoIHplcm8sCiAgICAgICAgICAvLyBhbmQgdGhlcmUgdGhpcyBzZWdtZW50IGludGVyc2VjdHMgd2l0aCB0aGUgc21hbGwgY2lyY2xlLgogICAgICAgICAgaWYgKCEoYyAmIGMwKSAmJiAodCA9IGludGVyc2VjdChwb2ludDEsIHBvaW50MCwgdHJ1ZSkpKSB7CiAgICAgICAgICAgIGNsZWFuID0gMDsKICAgICAgICAgICAgaWYgKHNtYWxsUmFkaXVzKSB7CiAgICAgICAgICAgICAgc3RyZWFtLmxpbmVTdGFydCgpOwogICAgICAgICAgICAgIHN0cmVhbS5wb2ludCh0WzBdWzBdLCB0WzBdWzFdKTsKICAgICAgICAgICAgICBzdHJlYW0ucG9pbnQodFsxXVswXSwgdFsxXVsxXSk7CiAgICAgICAgICAgICAgc3RyZWFtLmxpbmVFbmQoKTsKICAgICAgICAgICAgfSBlb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Il0gLSByYWRpdXMsCiAgICAgICAgY29kZSA9IDA7CiAgICBpZiAobGFtYmRhIDwgLXIpIGNvZGUgfD0gMTsgLy8gbGVmdAogICAgZWxzZSBpZiAobGFtYmRhID4gcikgY29kZSB8PSAyOyAvLyByaWdodAogICAgaWYgKHBoaSA8IC1yKSBjb2RlIHw9IDQ7IC8vIGJlbG93CiAgICBlbHNlIGlmIChwaGkgPiByKSBjb2RlIHw9IDg7IC8vIGFib3ZlCiAgICByZXR1cm4gY29kZTsKICB9CgogIHJldHVybiBPYmplY3QoX2luZGV4X2pzX19XRUJQQUNLX0lNUE9SVEVEX01PRFVMRV80X19bImRlZmF1bHQiXSkodmlzaWJsZSwgY2xpcExpbmUsIGludGVycG9sYXRlLCBzbWFsbFJhZGl1cyA/IFswLCAtcmFkaXVzXSA6IFstX21hdGhfanNfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzJfX1sicGkiXSwgcmFkaXVzIC0gX21hdGhfanNfX1dFQlBBQ0tfSU1QT1JURURfTU9EVUxFXzJfX1sicGkiXV0pOwp9KTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1nZW8vc3JjL2NsaXAvZXh0ZW50LmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9kMy1nZW8vc3JjL2NsaXAvZXh0ZW50LmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm92aWRlZDogZGVmYXVsdCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBfX3dlYnBhY2tfZXhwb3J0c19fLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7Cl9fd2VicGFja19yZXF1aXJlX18ucihfX3dlYnBhY2tfZXhwb3J0c19fKTsKLyogaGFybW9ueSB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ICAgICAgIH0KICAgICAgICBpZiAocG9seWdvblN0YXJ0ZWQpIHNpbmsucG9seWdvbkVuZCgpLCBwb2x5Z29uU3RhcnRlZCA9IGZhbHNlOwogICAgICAgIHNlZ21lbnRzID0gcG9seWdvbiA9IG51bGw7CiAgICAgIH0sCiAgICAgIHNwaGVyZTogZnVuY3Rpb24oKSB7CiAgICAgICAgc2luay5wb2x5Z29uU3RhcnQoKTsKICAgICAgICBzaW5rLmxpbmVTdGFydCgpOwogICAgICAgIGludGVycG9sYXRlKG51bGwsIG51bGwsIDEsIHNpbmspOwogICAgICAgIHNpbmsubGluZUVuZCgpOwogICAgICAgIHNpbmsucG9seWdvbkVuZCgpOwogICAgICB9CiAgICB9OwoKICAgIGZ1bmN0aW9uIHBvaW50KGxhbWJkYSwgcGhpKSB7CiAgICAgIGlmIChwb2ludFZpc2libGUobGFtYmRhLCBwaGkpKSBzaW5rLnBvaW50KGxhbWJkYSwgcGhpKTsKICAgIH0KCiAgICBmdW5jdGlvbiBwb2ludExpbmUobGFtYmRhLCBwaGkpIHsKICAgICAgbGluZS5wb2ludChsYW1iZGEsIHBoaSk7CiAgICB9CgogICAgZnVuY3Rpb24gbGluZVN0YXJ0KCkgewogICAgICBjbGlwLnBvaW50ID0gcG9pbnRMaW5lOwogICAgICBsaW5lLmxpbmVTdGFydCgpOwogICAgfQoKICAgIGZ1bmN0aW9uIGxpbmVFbmQoKSB7CiAgICAgIGNsaXAucG9pbnQgPSBwb2ludDsKICAgICAgbGluZS5saW5lRW5kKCk7CiAgICB9CgogICAgZnVuY3Rpb24gcG9pbnRSaW5nKGxhbWJkYSwgcGhpKSB7CiAgICAgIHJpbmcucHVzaChbbGFtYmRhLCBwaGldKTsKICAgICAgcmluZ1NpbmsucG9pbnQobGFtYmRhLCBwaGkpOwogICAgfQoKICAgIGZ1bmN0aW9uIHJpbmdTdGFydCgpIHsKICAgICAgcmluZ1NpbmsubGluZVN0YXJ0KCk7CiAgICAgIHJpbmcgPSBbXTsKICAgIH0KCiAgICBmdW5jdGlvbiByaW5nRW5kKCkgewogICAgICBwb2ludFJpbmcocmluZ1swXVswXSwgcmluZ1swXVsxXSk7CiAgICAgIHJpbmdTaW5rLmxpbmVFbmQoKTsKCiAgICAgIHZhciBjbGVhbiA9IHJpbmdTaW5rLmNsZWFuKCksCiAgICAgICAgICByaW5nU2VnbWVudHMgPSByaW5nQnVmZmVyLnJlc3VsdCgpLAogICAgICAgICAgaSwgbiA9IHJpbmdTZWdtZW50cy5sZW5ndGgsIG0sCiAgICAgICAgICBzZWdtZW50LAogICAgICAgICAgcG9pbnQ7CgogICAgICByaW5nLnBvcCgpOwogICAgICBwb2x5Z29uLnB1c2gocmluZyk7CiAgICAgIHJpbmcgPSBudWxsOwoKICAgICAgaWYgKCFuKSByZXR1cm47CgogICAgICAvLyBObyBpbnRlcnNlY3Rpb25zLgogICAgICBpZiAoY2xlYW4gJiAxKSB7CiAgICAgICAgc2VnbWVudCA9IHJpbmdTZWdtZW50c1swXTsKICAgICAgICBpZiAoKG0gPSBzZWdtZW50Lmxlbmd0aCAtIDEpID4gMCkgewogICAgICAgICAgaWYgKCFwb2x5Z29uU3RhcnRlZCkgc2luay5wb2x5Z29uU3RhcnQoKSwgcG9seWdvblN0YXJ0ZWQgPSB0cnVlOwogICAgICAgICAgc2luay5saW5lU3RhcnQoKTsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBtOyArK2kpIHNpbmsucG9pbnQoKHBvaW50ID0gc2VnbWVudFtpXSlbMF0sIHBvaW50WzFdKTsKICAgICAgICAgIHNpbmsubGluZUVuZCgpOwogICAgICAgIH0KICAgICAgICByZXR1cm47CiAgICAgIH0KCiAgICAgIC8vIFJlam9pbiBjb25uZWN0ZWQgc2VnbWVudHMuCiAgICAgIC8vIFRPRE8gcmV1c2UgcmluZ0J1ZmZlci5yZWpvaW4oKT8KICAgICAgaWYgKG4gPiAxICYmIGNsZWFuICYgMikgcmluZ1NlZ21lbnRzLnB1c2gocmluZ1NlZ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zIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtZ2VvL3NyYy9jbGlwL2xpbmUuanMgKioqIQogIFwqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm92aWRlZDogZGVmYXVsdCAqLwovKioqLyAoZnVuY3Rpb24obW9kdWxlLCBfX3dlYnBhY2tfZXhwb3J0c19fLCBfX3dlYnBhY2tfcmVxdWlyZV9fKSB7CgoidXNlIHN0cmljdCI7Cl9fd2VicGFja19yZXF1aXJlX18ucihfX3dlYnBhY2tfZXhwb3J0c19fKTsKLyogaGFybW9ueSBkZWZhdWx0IGV4cG9ydCAqLyBfX3dlYnBhY2tfZXhwb3J0c19fWyJkZWZhdWx0Il0gPSAoZnVuY3Rpb24oYSwgYiwgeDAsIHkwLCB4MSwgeTEpIHsKICB2YXIgYXggPSBhWzBdLAogICAgICBheSA9IGFbMV0sCiAgICAgIGJ4ID0gYlswXSwKICAgICAgYnkgPSBiWzFdLAogICAgICB0MCA9IDAsCiAgICAgIHQxID0gMSwKICAgICAgZHggPSBieCAtIGF4LAogICAgICBkeSA9IGJ5IC0gYXksCiAgICAgIHI7CgogIHIgPSB4MCAtIGF4OwogIGlmICghZHggJiYgciA+IDApIHJldHVybjsKICByIC89IGR4OwogIGlmIChkeCA8IDApIHsKICAgIGlmIChyIDwgdDApIHJldHVybjsKICAgIGlmIChyIDwgdDEpIHQxID0gcjsKICB9IGVsc2UgaWYgKGR4ID4gMCkgewogICAgaWYgKHIgPiB0MSkgcmV0dXJuOwogICAgaWYgKHIgPiB0MCkgdDAgPSByOwogIH0KCiAgciA9IHgxIC0gYXg7CiAgaWYgKCFkeCAmJiByIDwgMCkgcmV0dXJuOwogIHIgLz0gZHg7CiAgaWYgKGR4IDwgMCkgewogICAgaWYgKHIgPiB0MSkgcmV0dXJuOwogICAgaWYgKHIgPiB0MCkgdDAgPSByOwogIH0gZWxzZSBpZiAoZHggPiAwKSB7CiAgICBpZiAociA8IHQwKSByZXR1cm47CiAgICBpZiAociA8IHQxKSB0MSA9IHI7CiAgfQoKICByID0geTAgLSBheTsKICBpZiAoIWR5ICYmIHIgPiAwKSByZXR1cm47CiAgciAvPSBkeTsKICBpZiAoZHkgPCAwKSB7CiAgICBpZiAociA8IHQwKSByZXR1cm47CiAgICBpZiAociA8IHQxKSB0MSA9IHI7CiAgfSBlbHNlIGlmIChkeSA+IDApIHsKICAgIGlmIChyID4gdDEpIHJldHVybjsKICAgIGlmIChyID4gdDApIHQwID0gcjsKICB9CgogIHIgPSB5MSAtIGF5OwogIGlmICghZHkgJiYgciA8IDApIHJldHVybjsKICByIC89IGR5OwogIGlmIChkeSA8IDApIHsKICAgIGlmIChyID4gdDEpIHJldHVybjsKICAgIGlmIChyID4gdDApIHQwID0gcjsKICB9IGVsc2UgaWYgKGR5ID4gMCkgewogICAgaWYgKHIgPCB0MCkgcmV0dXJuOwogICAgaWYgKHIgPCB0MSkgdDEgPSByOwogIH0KCiAgaWYgKHQwID4gMCkgYVswXSA9IGF4ICsgdDAgKiBkeCwgYVsxXSA9IGF5ICsgdDAgKiBkeTsKICBpZiAodDEgPCAxKSBiWzBdID0gYXggKyB0MSAqIGR4LCBiWzFdID0gYXkgKyB0MSAqIGR5OwogIHJldHVybiB0cnVlOwp9KTsKCgovKioqLyB9KSwKCi8qKiovICIuL25vZGVfbW9kdWxlcy9kMy1nZW8vc3JjL2NsaXAvcmVjdGFuZ2xlLmpzIjoKLyohKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqISpcCiAgISoqKiAuL25vZGVfbW9kdWxlcy9kMy1nZW8vc3JjL2NsaXAvcmVjdGFuZ2xlLmpzICoqKiEKICBcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEgZXhwb3J0cyBwcm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jYiA/IGNhIC0gY2IKICAgICAgICA6IGNhID09PSAwID8gYlsxXSAtIGFbMV0KICAgICAgICA6IGNhID09PSAxID8gYVswXSAtIGJbMF0KICAgICAgICA6IGNhID09PSAyID8gYVsxXSAtIGJbMV0KICAgICAgICA6IGJbMF0gLSBhWzBdOwogIH0KCiAgcmV0dXJuIGZ1bmN0aW9uKHN0cmVhbSkgewogICAgdmFyIGFjdGl2ZVN0cmVhbSA9IHN0cmVhbSwKICAgICAgICBidWZmZXJTdHJlYW0gPSBPYmplY3QoX2J1ZmZlcl9qc19fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMV9fWyJkZWZhdWx0Il0pKCksCiAgICAgICAgc2VnbWVudHMsCiAgICAgICAgcG9seWdvbiwKICAgICAgICByaW5nLAogICAgICAgIHhfXywgeV9fLCB2X18sIC8vIGZpcnN0IHBvaW50CiAgICAgICAgeF8sIHlfLCB2XywgLy8gcHJldmlvdXMgcG9pbnQKICAgICAgICBmaXJzdCwKICAgICAgICBjbGVhbjsKCiAgICB2YXIgY2xpcFN0cmVhbSA9IHsKICAgICAgcG9pbnQ6IHBvaW50LAogICAgICBsaW5lU3RhcnQ6IGxpbmVTdGFydCwKICAgICAgbGluZUVuZDogbGluZUVuZCwKICAgICAgcG9seWdvblN0YXJ0OiBwb2x5Z29uU3RhcnQsCiAgICAgIHBvbHlnb25FbmQ6IHBvbHlnb25FbmQKICAgIH07CgogICAgZnVuY3Rpb24gcG9pbnQoeCwgeSkgewogICAgICBpZiAodmlzaWJsZSh4LCB5KSkgYWN0aXZlU3RyZWFtLnBvaW50KHgsIHkpOwogICAgfQoKICAgIGZ1bmN0aW9uIHBvbHlnb25JbnNpZGUoKSB7CiAgICAgIHZhciB3aW5kaW5nID0gMDsKCiAgICAgIGZvciAodmFyIGkgPSAwLCBuID0gcG9seWdvbi5sZW5ndGg7IGkgPCBuOyArK2kpIHsKICAgICAgICBmb3IgKHZhciByaW5nID0gcG9seWdvbltpXSwgaiA9IDEsIG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sKICAgICAgaWYgKHNlZ21lbnRzKSB7CiAgICAgICAgbGluZVBvaW50KHhfXywgeV9fKTsKICAgICAgICBpZiAodl9fICYmIHZfKSBidWZmZXJTdHJlYW0ucmVqb2luKCk7CiAgICAgICAgc2VnbWVudHMucHVzaChidWZmZXJTdHJlYW0ucmVzdWx0KCkpOwogICAgICB9CiAgICAgIGNsaXBTdHJlYW0ucG9pbnQgPSBwb2ludDsKICAgICAgaWYgKHZfKSBhY3RpdmVTdHJlYW0ubGluZUVuZCgpOwogICAgfQoKICAgIGZ1bmN0aW9uIGxpbmVQb2ludCh4LCB5KSB7CiAgICAgIHZhciB2ID0gdmlzaWJsZSh4LCB5KTsKICAgICAgaWYgKHBvbHlnb24pIHJpbmcucHVzaChbeCwgeV0pOwogICAgICBpZiAoZmlyc3QpIHsKICAgICAgICB4X18gPSB4LCB5X18gPSB5LCB2X18gPSB2OwogICAgICAgIGZpcnN0ID0gZmFsc2U7CiAgICAgICAgaWYgKHYpIHsKICAgICAgICAgIGFjdGl2ZVN0cmVhbS5saW5lU3RhcnQoKTsKICAgICAgICAgIGFjdGl2ZVN0cmVhbS5wb2ludCh4LCB5KTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgaWYgKHYgJiYgdl8pIGFjdGl2ZVN0cmVhbS5wb2ludCh4LCB5KTsKICAgICAgICBlbHNlIHsKICAgICAgICAgIHZhciBhID0gW3hfID0gTWF0aC5tYXgoY2xpcE1pbiwgTWF0aC5taW4oY2xpcE1heCwgeF8pKSwgeV8gPSBNYXRoLm1heChjbGlwTWluLCBNYXRoLm1pbihjbGlwTWF4LCB5XykpXSwKICAgICAgICAgICAgICBiID0gW3ggPSBNYXRoLm1heChjbGlwTWluLCBNYXRoLm1pbihjbGlwTWF4LCB4KSksIHkgPSBNYXRoLm1heChjbGlwTWluLCBNYXRoLm1pbihjbGlwTWF4LCB5KSldOwogICAgICAgICAgaWYgKE9iamVjdChfbGluZV9qc19fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMl9fWyJkZWZhdWx0Il0pKGEsIGIsIHgwLCB5MCwgeDEsIHkxKSkgewogICAgICAgICAgICBpZiAoIXZfKSB7CiAgICAgICAgICAgICAgYWN0aXZlU3RyZWFtLmxpbmVTdGFydCgpOwogICAgICAgICAgICAgIGFjdGl2ZVN0cmVhbS5wb2ludChhWzBdLCBhWzFdKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBhY3RpdmVTdHJlYW0ucG9pbnQoYlswXSwgYlsxXSk7CiAgICAgICAgICAgIGlmICghdikgYWN0aXZlU3RyZWFtLmxpbmVFbmQoKTsKICAgICAgICAgICAgY2xlYW4gPSBmYWxzZTsKICAgICAgICAgIH0gZWxzZSBpZiAodikgewogICAgICAgICAgICBhY3RpdmVTdHJlYW0ubGluZVN0YXJ0KCk7CiAgICAgICAgICAgIGFjdGl2ZVN0cmVhbS5wb2ludCh4LCB5KTsKICAgICAgICAgICAgY2xlYW4gPSBmYWxzZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgeF8gPSB4LCB5XyA9IHksIHZfID0gdjsKICAgIH0KCiAgICByZXR1cm4gY2xpcFN0cmVhbTsKICB9Owp9CgoKLyoqKi8gfSksCgovKioqLyAiLi9ub2RlX21vZHVsZXMvZDMtZ2VvL3NyYy9jbGlwL3Jlam9pbi5qcyI6Ci8qISoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiEqXAogICEqKiogLi9ub2RlX21vZHVsZXMvZDMtZ2VvL3NyYy9jbGlwL3Jlam9pbi5qcyAqKiohCiAgXCoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohIGV4cG9ydHMgcHJvdmlkZWQ6IGRlZmF1bHQgKi8KLyoqKi8gKGZ1bmN0aW9uKG1vZHVsZSwgX193ZWJwYWNrX2V4cG9ydHNfXywgX193ZWJwYWNrX3JlcXVpcmVfXykgewoKInVzZSBzdHJ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DEsIG51bGwsIHgsIHRydWUpKTsKICB9KTsKCiAgaWYgKCFzdWJqZWN0L |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment