The Productive Juan Project - Phase 2

0

0 votes
Medium-Hard
Problem

Every Juan needs to be productive even more. The government asks you to intensify the Productive Juan Project and commence with its second phase.

Goal is simple. Your program must provide the series of tasks that a Juan must perform in a day to be productive.

Now, off you go and work it out in an instant!

INPUT

Input starts with the number of test cases N. Succeeding lines are the N test cases. A test case starts with the number of tasks T to process. Following lines are the set of tasks, labeled by the letters of the alphabet, along with their respective start time and end time. Time follows the 24-hour/military time format.

OUTPUT

For each test case, your program must display the order of tasks that a Juan can do in a day. Assume that

  1. A Juan can do one task at a time;
  2. Shorter tasks are preferred over the longer ones; and
  3. Earlier start times are preferred for conflicting tasks. For cases not defined by the specification, display ‘unable to process’

CONSTRAINTS

0<N10

0<T<20

SAMPLE INPUT

4
3
A 0800 0900
B 0830 1000
C 0900 1200
5
A 1200 2000
B 1600 1800
C 0500 1200
D 0800 1200
E 1030 1230
10
A 0800 0900
B 0900 1000
C 1000 1100
D 1100 1200
E 1130 1230
F 1200 1300
G 1300 1400
H 1400 1500
I 1500 1600
J 1600 1700
2
A 800 900
B 0900

SAMPLE OUTPUT

AC
EB
ABCDFGHIJ
unable to process
Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?