Which really big number is bigger? This question is tricky (and in particular harder than Which big number is bigger?), for those who like more challenging puzzles.

Input

Integers a1, a2, a3, a4, a5,  b1, b2, b3, b4, b5 each in the range 1 to 10.

Output

True if a1^(a2^(a3^(a4^a5))) &gt; b1^(b2^(b3^(b4^b5))) and False otherwise.


^ is exponentiation in this question.

Rules

This is code-golf. Your code must terminate correctly within 10 seconds for any valid input on TIO.  If your language is not on TIO, the code should finish under 10 seconds on your machine.

You can output anything Truthy for True and anything Falsey for False.

Test cases

Recall that by the rules of exponentiaon,  a1^(a2^(a3^(a4^a5))) == a1^a2^a3^a4^a5.

10^10^10^10^10 &gt; 10^10^10^10^9
1^2^3^4^5 &lt; 5^4^3^2^1
2^2^2^2^3 &gt; 10^4^3^2^2
6^7^8^9^10 is not bigger than 6^7^8^9^10
10^6^4^2^2 &lt; 10^6^2^4^2
2^2^2^2^10 &gt; 2^2^2^10^2
10^9^8^7^6 &lt; 6^7^8^9^10 
3^1^10^10^10 &gt; 2^1^10^10^10 
9^10^10^10^10 &lt; 10^9^10^10^10


New test cases from Kevin Cruijssen

[10,10,10,10,10, 10,10,10,10,9] #true
[2,2,2,2,3,      10,4,3,2,2]    #true
[2,2,2,2,10,     2,2,2,10,2]    #true
[10,10,10,10,10, 9,10,10,10,10] #true
[3,2,2,1,1,      2,5,1,1,1]     #true
[2,2,3,10,1,     2,7,3,9,1]     #true
[7,9,10,10,10,   6,9,10,10,10]  #true
[3,2,2,2,2,      2,2,2,2,2]     #true
[8,3,1,2,1,      2,2,3,1,1]     #true
[2,4,2,1,1,      3,3,2,1,1]     #true
[5,4,3,2,1,      1,2,3,4,5]     #true

[1,2,3,4,5,      5,4,3,2,1]     #false
[6,7,8,9,10,     6,7,8,9,10]    #false
[10,6,4,2,2,     10,6,2,4,2]    #false
[10,9,8,7,6,     6,7,8,9,10]    #false
[1,10,10,10,10,  1,10,10,10,9]  #false
[2,4,1,1,1,      2,2,2,1,1]     #false
[2,2,2,1,1,      2,4,1,1,1]     #false
[2,5,1,1,1,      3,2,2,1,1]     #false
[4,2,1,1,1,      2,4,1,1,1]     #false
[2,4,1,1,1,      4,2,1,1,1]     #false
[2,3,10,1,1,     8,3,9,1,1]     #false
[8,3,9,1,1,      2,3,10,1,1]    #false
[2,4,1,1,1,      3,3,1,1,1]     #false
[2,2,1,9,9,      2,2,1,10,10]   #false
[2,2,1,10,10,    2,2,1,9,9]     #false
[1,1,1,1,1,      1,2,1,1,1]     #false
Ruby, 150 bytes

See revisions for previous byte counts.

-&gt;a,b,c,d,e,f,g,h,i,j{l=-&gt;s,t=c{Math.log(s,t)};y,z=l[l[g,b]]-d**e+l[h]*i**=j,l[l[a,f]*b**c,g];a&gt;1?f&lt;2?1:b&lt;2||g&lt;2?z&gt;h:c&lt;2||d&lt;2?l[z,h]&gt;i:y==0?a&gt;f:y&lt;0:p}


-10 bytes thanks to @ValueInk

+16 bytes thanks to @RosLuP for bugs.

Try it online.

Compare different base powers-towers (of 'height' five)?

Ungolfed code:

-&gt; a, b, c, d, e, f, g, h, i, j {
    l =-&gt; s, t = c {Math.log(s, t)}
    i **= j
    y = l[l[g, b]] - d ** e + l[h] * i
    z = l[l[a, f] * b ** c, g]
    if a == 1
        return p
    elsif f == 1
        return 1
    elsif b == 1 || g == 1
        return z &gt; h
    elsif d == 1 || c == 1
        return l[z, h] &gt; i
    elsif y == 0
        return a &gt; f
    else
        return y &lt; 0
    end
}


Code breakdown:

l =-&gt; s, t = c {Math.log(s, t)}


This is the base t logarithm, which will be used to reduce the size of the numbers we are comparing. It defaults to base c when only one argument is given.

i **= j
y = l[l[g, b]] - d ** e + l[h] * i
z = l[l[a, f] * b ** c, g]


This updates i = i ** j since i never gets used on it's own, and y is the result of logging b^c^d^e == g^h^i(^j) twice and moving everything to one side. We then let z = l[a, f] * b ** c as the log base g of the log base f of a ** b ** c.

if a == 1
    return p
elsif f == 1
    return 1


1^b^c^d^e = 1 is never greater than f^g^h^i^j, and likewise, a^b^c^d^e is always greater than 1^g^h^i^j = 1 if a != 1. Note that return p returns nil, which is falsey, and return 1 returns 1, which is truthy.

elsif b == 1
    return z &gt; h


If b == 1 or g == 1, then this reduces to comparing a ** b ** c to f ** g ** h, which is done with two logs to both sides.

elsif d == 1 || c == 1
    return l[z, h] &gt; i


This compares a ** b ** c with f ** g ** h ** i by rearranging it as log[log[b ** c * log[a, f], g], h] compared to i. (Recall that i **= j in the beginning and z = log[b ** c * log[a, f], g].)

elsif y == 0
    return a &gt; f
else
    return y &lt; 0
end


This compares the 4 highest powers after logging both sides twice. If they are equal, it compares the base.