This is an interactive problem
In ancient Carthage, scholars created a secret numerical cipher to protect their most valuable trade secrets. This cipher, believed to be a function $$$f$$$, that maps each natural number to a secret value, was known only to the High Council of Merchants. The cipher was lost when Rome destroyed Carthage in 146 BC.
For centuries, archaeologists have searched for the legendary "Stone of Accounts", the key to unlocking this ancient secret.
Recently, in the ruins of ancient Carthage near modern-day Tunis, you've discovered the fabled Stone of Accounts! It's a mysterious device with two input slots and one output display. Ancient Punic inscriptions explain how it works: "Place two numbered stones in the slots. If their numbers sum to a power of two, the stone reveals the sum of their hidden values. Otherwise, it reveals nothing."
Formally, The Stone accepts two positive integers $$$n$$$ and $$$m$$$:
Centuries ago, archaeologists discovered ancient Carthaginian scrolls containing encrypted trade secrets: $$$S=[S_1,\dots,S_n].$$$ For generations, scholars have tried to decipher them, but without the Stone of Accounts, all attempts failed.
Now, with the Stone finally discovered, you have a chance to succeed where others could not.
Your mission: Recover the true message $$$M=[f(S_1),\dots,f(S_n)].$$$ But be careful! The Stone is ancient and fragile. You can use it at most 10,000 times before it breaks forever.
Your program will interact via standard input/output with the black box.
Starting from $$$i=1$$$, two modes of operations are supported:
3 1 3 4 R 0 R 2 N R 4 N R 8 N
? 1 2 ? 1 1 ! 1 ? 3 1 ! 3 ? 4 4 ! 4