Basic Typescript Types
Python 3, 261 bytes

lambda x,o=&quot;&amp;&quot;,y=&quot;&quot;:(&quot;any&quot;in x+y)*(o&lt;&quot;|&quot;)*-~-(&quot;never&quot;in x+y)*&quot;any&quot;or(lambda r:r==31and&quot;any&quot;or&quot;|&quot;.join(&quot;ubsnnnotuudormleliblfene iagr nn   e    d&quot;[i::5]for i in range(5)if r&amp;2**i)or&quot;never&quot;)(eval(o.join(str(min(31,2**&quot;dormlyv&quot;.find(k[2])%64))for k in[x,y or x])))

Try it online!
-1 byet thanks to ovs