Under construction

Still being built. Things may change

Third Group Exam

Interview

Time limit1sMemory limit512 MB

Summary
Given per-block theory grades x_i and practice grades y_i, pick at least a theory blocks and at least b practice blocks to maximize the total grade, and print the choice.
Level

Medium5 of 10

Topics
Greedy, Sorting
Solved
No attempts yet

Statement

One teacher came up with a new format for an exam. The exam consists of nn blocks, one for each topic. A student receives a grade cic_i for the ii-th block, for every ii from 11 to nn, and all grades are independent. Each grade is an integer from 00 to 100100, inclusive.

For each block, a student chooses one way to earn the grade: answer a theoretical question or solve a practical problem. The exam is passed successfully if at least aa blocks were graded by answering a theoretical question and at least bb blocks were graded by solving a practical problem. If the exam is passed, the final grade CC is the sum of the grades for all blocks: C=∑i=1nciC = \sum_{i=1}^n c_i.

Ilya is about to take the exam. For block ii, answering the theoretical question gives him a grade of xix_i, and solving the practical problem gives him a grade of yiy_i. Help him decide which blocks (at least aa of them) he should answer by theory and which blocks (at least bb of them) he should solve by practice, so that his total exam score is as large as possible.

Input

The first line contains three integers nn, aa and bb, the total number of topics, the minimum number of blocks to pass by theory, and the minimum number of blocks to pass by practice (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5; 0≤a,b≤n0 \le a, b \le n). It is guaranteed that a+b≤na + b \le n.

The second line contains nn integers xix_i, the grades for answering the theoretical questions (0≤xi≤1000 \le x_i \le 100).

The third line contains nn integers yiy_i, the grades for solving the practical problems (0≤yi≤1000 \le y_i \le 100).

Output

The first line must contain a single integer CC, the maximum total grade Ilya can get.

The second line must contain nn space-separated characters, where the ii-th character is T if Ilya should answer the theoretical question for block ii, and P if he should solve the practical problem. At least aa characters must be T, and at least bb characters must be P.

Examples3

  1. Example 1

    Input
    4 1 1
    10 30 50 70
    80 60 40 20
    
    Expected output
    260
    P P T T
    
  2. Example 2

    Input
    4 1 1
    30 40 60 90
    10 25 50 85
    
    Expected output
    215
    T T T P
    
  3. Example 3

    Input
    4 2 1
    0 17 70 13
    2 21 55 99
    
    Expected output
    190
    T P T P