Problem:
Score : 200 points

Problem Statement

You are given two positive integers A and B. Compare the magnitudes of these numbers.

Constraints

1 ≤ A, B ≤ 10^{100}

Neither A nor B begins with a 0.

Input

Input is given from Standard Input in the following format:

A
B

Output

Print GREATER if A>B, LESS if A<B and EQUAL if A=B.

Sample Input 1

36
24

Sample Output 1

GREATER

Since 36>24, print GREATER.

Sample Input 2

850
3777

Sample Output 2

LESS

Sample Input 3

9720246
22516266

Sample Output 3

LESS

Sample Input 4

123456789012345678901234567890
234567890123456789012345678901

Sample Output 4

LESS

Solution in Scala (2.11.7) (judge verdict: Wrong Answer)

import scala.io.StdIn
import scala.annotation.tailrec

object Main extends App {
  val a = StdIn.readLine
  val b = StdIn.readLine

  val ans = {
    if(a.length > b.length) "GREATER"
    else if(a.length < b.length) "LESS"
    else {
      val ita = a.reverseIterator
      val itb = b.reverseIterator

      @tailrec
      def rec(cha:Char, chb:Char):String = {
        if(cha > chb) "GREATER"
        else if(cha < chb) "LESS"
        else if(!ita.hasNext) "EQUAL"
        else rec(ita.next, itb.next)
      }

      rec(ita.next, itb.next)
    }
  }

  println(ans)
}