#K75977. Who Will Finish Painting First?

    ID: 34539 Type: Default 1000ms 256MiB

Who Will Finish Painting First?

Who Will Finish Painting First?

Two painters, Emma and John, are racing to finish painting their allocated portions. Each painter has N portions to paint, and the time required for each portion is provided. The painter with the smaller total painting time finishes first. If both painters take the same amount of time, the result is a tie.

For each test case, you are given:

  • An integer N representing the number of portions.
  • A list of N integers representing the time for Emma to paint each portion.
  • A list of N integers representing the time for John to paint each portion.

Your task is to determine which painter finishes first. Formally, let \(E = \sum_{i=1}^{N} e_i\) and \(J = \sum_{i=1}^{N} j_i\). The winner is:

  • EMMA if \(E < J\)
  • JOHN if \(J < E\)
  • TIE if \(E = J\)

inputFormat

The first line contains an integer T, the number of test cases.

For each test case, there are three lines:

  1. An integer N representing the number of portions.
  2. A line with N space-separated integers, representing the time required by Emma for each portion.
  3. A line with N space-separated integers, representing the time required by John for each portion.

Constraints:

  • \(1 \leq T \leq 100\)
  • \(1 \leq N \leq 10^5\)
  • Each painting time is an integer between 1 and \(10^9\).

outputFormat

For each test case, output a single line containing one of the following: EMMA, JOHN, or TIE, based on the painter who finishes first.

## sample
3
4
1 2 3 4
2 2 2 2
5
1 1 1 1 1
1 1 1 1 2
3
2 2 2
3 1 2
JOHN

EMMA TIE

</p>