| SDU Open 2023 |
|---|
| Finished |
There is a group of $$$n$$$ undergraduate students at SDU who are interested in participating in the upcoming ICPC competitions. For each student, their strength level is known, denoted by a single integer $$$a_i$$$.
There are also $$$m$$$ similar graduate students at the university who are interested in the role of coach. For each of them, their strength level is also known, denoted by a single integer $$$b_i$$$.
The SDU administration is interested in how potentially balanced a team can be assembled from their university. To do this, a team of three undergraduate students $$$i$$$, $$$j$$$, and $$$q$$$ ($$$1 \le i \lt j \lt q \le n$$$) must be formed. The strength of the team will be determined by the sum of the individual members of the team, namely — the number $$$a_i + a_j + a_q$$$.
However, the team will not develop fully without a coach. Therefore, it was decided to choose one coach from the graduate students. Let the number of the selected coach be $$$k$$$ $$$(1 \leq k \leq m)$$$. Then the following conditions must also be met:
Taking into account the above restrictions, it was decided to form a suitable team so that the difference between the strength of the coach and the strength of the team $$$b_k - (a_i + a_j + a_q)$$$ was minimal. If it is possible to form several suitable teams, any of them can be chosen.
Help assemble the dream team.
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 300$$$) — the number of undergraduate and graduate students, respectively.
The second line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$1 \leq a_i \leq 10000$$$) — the strength levels of undergraduate students.
The third line contains $$$m$$$ integers $$$b_1, \ldots, b_m$$$ ($$$1 \leq b_i \leq 10000$$$) — the strength levels of graduate students.
If it is possible to form the dream team, output four integers $$$i, j, q, k$$$ ($$$1 \leq i \lt j \lt q \leq n$$$, $$$1 \leq k \leq m$$$) — the numbers of the team members and the coach.
If it is impossible to assemble the dream team, output a single integer -1.
3 2 1 2 3 10 8
1 2 3 2
3 2 1 2 3 6 4
-1
5 5 1 2 4 8 16 6 18 23 27 30
2 3 5 3
In the first example, only three undergraduate students can be selected for the team, and the strength of this team will be $$$1+2+3=6$$$. For the role of coach, we can choose a graduate student with a strength of $$$8$$$ or a graduate student with a strength of $$$10$$$, among them it is best to choose a student with a strength of $$$8$$$ to minimize the difference between the strength of the team and the strength of the coach.
In the second example, the strength of the only possible team is $$$6$$$, and it is impossible to choose a coach who would be stronger than this team.
| Name |
|---|


