Which number is bigger? Define f(a,b) := a if b=1; a^f(a,b-1) if b&gt;1 (Tetration, where ^ means power) for positive integers a and b, given four positive integers a,b,c,d, compare f(a,b) and f(c,d).

Your program should output three constant values to mean "greater", "less" and "equal".

Samples:

a b c d f(a,b) output f(c,d)
3 2 2 3 27     &gt;      16
4 2 2 4 256    &lt;      65536
4 1 2 2 4      =      4


Lowest time complexity to max{a,b,c,d} win, with tie-breaker code length(the shorter the better) and then answer time(the earlier the better).

Complexity assumption


Your code should handle a,b,c,d up to 100, and your algorithm should handle all legal input
You can assume integer calculations (that your language directly support) in O((a+b+c+d)^k) cost O(1) time if can be done in O(1) for 2k bit numbers if k bit computing can be done in O(1)
For example, both plus(+) and multiply(*) can be done in O(1) for 2k bit numbers if k bit computing for both can be done in O(1), so both satisy the requirement. It's fine if multiply can't be done without plus, or even if both can't be done without each other.
Float calculations in O(log(a+b+c+d)) bit precision in ±2^O((a+b+c+d)^k), takes O(1), with same requirements like integer calculations.
Java (JDK 10), 295 bytes



int f(Long a,long b,long c,long d){return a&gt;c?-f(c,d,a,b):a&lt;c?b&gt;d?d==1?(a==2&amp;((b==2&amp;c==4)|(b==3&amp;c==16)))|(a==3&amp;b==2&amp;c==27)?0:1:b-d&gt;1?1:f(t(a,b),1,c,d):-1:a&lt;2?0:a.signum(b-d);}long t(long a,long b){long t=1;for(;b--&gt;0;)t=p(a,t);return t;}long p(long a,long b){long p=1;for(;b--&gt;0;)p*=a;return p;}


Try it online!

Codes:


1 if a^^b &gt; c^^d
-1 if a^^b &lt; c^^d
0 is a^^b == c^^d