{"raw_statement":[{"iden":"problem statement","content":"Takahashi has decided to give **one** gift to Aoki and **one** gift to Snuke.  \nThere are $N$ candidates of gifts for Aoki, and their values are $A_1, A_2, \\ldots,A_N$.  \nThere are $M$ candidates of gifts for Snuke, and their values are $B_1, B_2, \\ldots,B_M$.\nTakahashi wants to choose gifts so that the difference in values of the two gifts is at most $D$.\nDetermine if he can choose such a pair of gifts. If he can, print the maximum sum of values of the chosen gifts."},{"iden":"constraints","content":"*   $1\\leq N,M\\leq 2\\times 10^5$\n*   $1\\leq A_i,B_i\\leq 10^{18}$\n*   $0\\leq D \\leq 10^{18}$\n*   All values in the input are integers."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$ $M$ $D$\n$A_1$ $A_2$ $\\ldots$ $A_N$\n$B_1$ $B_2$ $\\ldots$ $B_M$"},{"iden":"sample input 1","content":"2 3 2\n3 10\n2 5 15"},{"iden":"sample output 1","content":"8\n\nThe difference of values of the two gifts should be at most $2$.  \nIf he gives a gift with value $3$ to Aoki and another with value $5$ to Snuke, the condition is satisfied, achieving the maximum possible sum of values.  \nThus, $3+5=8$ should be printed."},{"iden":"sample input 2","content":"3 3 0\n1 3 3\n6 2 7"},{"iden":"sample output 2","content":"\\-1\n\nHe cannot choose gifts to satisfy the condition. Note that the candidates of gifts for a person may contain multiple gifts with the same value."},{"iden":"sample input 3","content":"1 1 1000000000000000000\n1000000000000000000\n1000000000000000000"},{"iden":"sample output 3","content":"2000000000000000000\n\nNote that the answer may not fit into a $32$\\-bit integer type."},{"iden":"sample input 4","content":"8 6 1\n2 5 6 5 2 1 7 9\n7 2 5 5 2 4"},{"iden":"sample output 4","content":"14"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}