Olympiad in Programming and Sports
Contest: 2016-2017 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)
Difficulty rating: 2000
Tags: dp, flows, graphs, greedy

There are n students at Berland State University. Every student has two skills, each measured as a number: ai — the programming skill and bi — the sports skill.

It is announced that an Olympiad in programming and sports will be held soon. That's why Berland State University should choose two teams: one to take part in the programming track and one to take part in the sports track.

There should be exactly p students in the programming team and exactly s students in the sports team. A student can't be a member of both teams.

The university management considers that the strength of the university on the Olympiad is equal to the sum of two values: the programming team strength and the sports team strength. The strength of a team is the sum of skills of its members in the corresponding area, so the strength of the programming team is the sum of all ai and the strength of the sports team is the sum of all bi over corresponding team members.

Help Berland State University to compose two teams to maximize the total strength of the university on the Olympiad.

Input format:
The first line contains three positive integer numbers n, p and s (2 ≤ n ≤ 3000, p + s ≤ n) — the number of students, the size of the programming team and the size of the sports team.

The second line contains n positive integers a1, a2, ..., an (1 ≤ ai ≤ 3000), where ai is the programming skill of the i-th student.

The third line contains n positive integers b1, b2, ..., bn (1 ≤ bi ≤ 3000), where bi is the sports skill of the i-th student.

Output format:
In the first line, print the the maximum strength of the university on the Olympiad. In the second line, print p numbers — the members of the programming team. In the third line, print s numbers — the members of the sports team.

The students are numbered from 1 to n as they are given in the input. All numbers printed in the second and in the third lines should be distinct and can be printed in arbitrary order.

If there are multiple solutions, print any of them.

Constraints:
Time limit: 2.0 s
Memory limit: 512.0 MB

Example input:
5 2 2
1 3 4 5 2
5 3 2 1 4

Example output:
18
3 4
1 5

Example input:
4 2 2
10 8 8 3
10 7 9 4

Example output:
31
1 2
3 4

Editorial:
This problem can be solved with help of algorithm of finding maximum flow with minimal cost in the graph. So how to build graph from the given data?
The vertices in graph will be:
• the source and the drain of the net of the flow;
• two vertices for the programming team and for the sport team;
• n vertices for every student.
Now we need only to add the edges for the flow. At first let's add two edges from the source — the edge to vertex for the programming team with capacity p and cost 0 and the edge to vertex for the sport team with capacity s and cost 0.
Then let's add n edges from the vertex for the programming team to all vertices for the students — the edge to i-th student must has capacity 1 and cost  - ai, and add n edges from the vertex for the sport team to all vertices for the students — the edge to i-th student must has capacity 1 and cost  - bi.
After that we need only to add edges from every vertices for the students to drain with capacities 1 and costs 0.
The answer for the problem is absolute value of the minimum cost of the maximum flow. After we found this cost we need only to accurate restore the distribution of the students.