def valid(person, task):
    for taskCheck in person:
        if task[0] in range(taskCheck[0], taskCheck[1]) or task[1] in 
range(taskCheck[0], taskCheck[1]):
            return False
    return True


def fun():
    jamie = []
    cameron = []
    ans = ''
    taskCount = int(input())

    for i in range(taskCount):
        lst = (list(map(int, input().split(" "))))
        if valid(cameron, lst):
            cameron.append(lst)
            ans += 'C'
        elif valid(jamie, lst):
            ans += 'J'
            jamie.append(lst)
        else:
            ans = "IMPOSSIBLE"
            break
    return ans


n = int(input())
anslst = []
for i in range(n):
    anslst.append(fun())
j = 1
for i in anslst:
    print("Case #" + str(j) + ": ", end="")
    print(i)
    j += 1







-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/8203662a-9504-4c20-97a9-e1abbcbd4879%40googlegroups.com.

Reply via email to