PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000454. Phán quyết công bằng (Gravamen)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Phán quyết công bằng (Gravamen)

Gravamen

Source: Kattis – https://open.kattis.com/problems/gravamen

Version: Phuoc Hung OJ Extended

Problem Statement

A judge must rule on LL lawsuits involving RR individuals and SS corporations, numbered separately starting from 1. Lawsuit ii involves individual AiA_i and corporation BiB_i. A pair may be involved in more than one lawsuit.

For every lawsuit, exactly one of its two parties must win. Minimize the largest number of wins of any single individual or corporation. Output any optimal set of rulings.

Input

The first line contains R,S,LR,S,L. Each of the next LL lines contains Ai,BiA_i,B_i.

Output

Print exactly LL lines in input order. Line ii must contain INDV followed by AiA_i, or CORP followed by BiB_i, identifying the winner. Any optimal assignment is accepted. Do not print the optimum value separately.

Subtasks

Common conditions apply to all subtasks. Scoring groups are added by Phuoc Hung OJ.

1≤R,S≤20001\le R,S\le2000; max⁡(R,S)≤L\max(R,S)\le L; 1≤Ai≤R1\le A_i\le R; 1≤Bi≤S1\le B_i\le S.

Each individual and corporation participates in at least one lawsuit. Repeated pairs are allowed. All input values are integers.

Subtask 1 (20 points)

  • 1≤L≤121\le L\le12.

Subtask 2 (30 points)

  • 1≤L≤2001\le L\le200.

Subtask 3 (50 points)

  • 1≤L≤20001\le L\le2000.

Examples

Example 1

Input

5 3 8
1 1
2 1
3 1
4 2
5 2
3 3
4 3
5 3

Output

INDV 1
INDV 2
CORP 1
INDV 4
CORP 2
INDV 3
CORP 3
INDV 5

Explanation

Each of the eight parties wins exactly once. The optimum cannot be zero, so the assignment is optimal.

Example 2

Input

1 1 4
1 1
1 1
1 1
1 1

Output

INDV 1
INDV 1
CORP 1
CORP 1

Explanation

Four lawsuits shared by two parties require at least two wins for one party. The sample gives each party two wins.