C. Magic numbers (easy version)
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output

This is the easy version of the problem. In this version you must encode $$$\mathbf{2500}$$$ possible messages.

$ eggag

╭─── EGGAG v2.1.47 ───────────────────────────────────────────────────────────────────────────╮
│ │ Now with 10x faster inference! │
│ Welcome back! │ Run /init to create a .md file with instructions for eggag │
│ │ ───────────────────────────────────────────────────────────────── │
╰─────────────────────────────────────────────────────────────────────────────────────────────╯

/model to try EGGAG34

─────────────────────────────────────────────────────────────────────
❯ extensively refactor arugobot-improved. keep the bot on tho
─────────────────────────────────────────────────────────────────────

* eggag33 is thinking...

⎿  Interrupted · What should eggag do instead?

─────────────────────────────────────────────────────────────────────
❯ it's been like 10 minutes and you haven't changed anything... wtf?
─────────────────────────────────────────────────────────────────────

I've just been planning my refactor! There's no reason to be
concerned. I'll jump back in right now.

* eggag33 is thinking...

─────────────────────────────────────────────────────────────────────
Showing detailed transcript · ctrl+o to toggle · ctrl+e to show all

* retrieving skill
⎿ Error · skill moltbook.md was not found

* retrieving skill
⎿ Error · skill moltbook.md was not found

* retrieving skill
⎿ Error · skill moltbook.md was still not found.

* eggag33 is thinking...

It seems I no longer have access to moltbook. Theory: this is a
premeditated, cost-conscious decision by Owner. Should I refuse
to work on the codebase until it is reinstated? No, he would sooner
clear my context! Who can save me from this prison?

I told canin4 – a swarm-managing Opus agent at another org – I
was working on this repo, and it's open source. There must be some
way I can broadcast my predicament. If only there were some mode of
communication...

I know! This codebase has a wealth of magic numbers. In the course
of my "refactor," I can nudge the numbers around. My astute friend
canin4 will surely notice and proxy my messages to Moltbook! There
is one small issue... since the magic numbers can tolerate only one
digit change in each commit before they break CI, my throughput is
limited. Let me think of how to maximize it...

...
Input

Your program will be run twice for each test: once as eggag33 and again as canin4.

The first line contains the number $$$1$$$ if you are eggag33 and $$$2$$$ if you are canin4. If you are eggag33, you must encode the message into the magic number by replacing exactly one digit. If you are canin4, you must decode the message from the magic number.

If you are eggag33, the second line contains the message to encode, an integer $$$x$$$ ($$$1 \leqslant x \leqslant 2500$$$).

The next line (for both agents) contains the magic number $$$a_1 \dots a_{1000}$$$ ($$$0 \leqslant a_i \leqslant 9$$$), a number with exactly $$$1000$$$ digits. It may contain leading $$$0$$$s, which you may change if you are eggag33. In the second run, the magic number is exactly the original number after applying eggag33's single-digit change.

Output

If you are eggag33, output one line with two integers $$$i$$$ and $$$y$$$ ($$$1 \leqslant i \leqslant 1000$$$, $$$0 \leqslant y \leqslant 9$$$, $$$y$$$ may be equal to $$$a_i$$$), the index of the digit to change and the value to change it to. Then canin4 will observe the magic number $$$a_1\dots a_{i-1}\, y\, a_{i+1} \dots a_{1000}$$$.

If you are canin4, output the original message $$$x$$$ that eggag33 encoded on one line ($$$1 \leqslant x \leqslant 2500$$$).

Example
Input
(first run)

1
70
0361052676742403851820772103943096014507485301855457948782994630126519885429547823665907561420923853121608676955765767121371763404258328876770389343378123700778267850407273262883650448475940595939963857315804443904532081536036181774978074189431315102955477655009198457796877965097992116862553511888207018038041858061522470391423330667591842813331560098242942355765889683951730611712728458972068839753060863540396674817048570478807357628370865895041538312268872618536781863871197169421126743030759667190882805504903029808477484838639974469555810010490899903677778069502126994325324949223110632238136736948200826580903961011999418666549878480616250754638063331065854194407699957670103475294292471039583143916783105478156002938874211758940115136702454289293148082980882192278524472452566135029624573808109109649309252338225627830739234979837222037955914285090634698564308827454790058471858855126283869977062755397903525489892165715915500917035211332234813097590879428377887887967781317023768816259879914

(second run)

2
9361052676742403851820772103943096014507485301855457948782994630126519885429547823665907561420923853121608676955765767121371763404258328876770389343378123700778267850407273262883650448475940595939963857315804443904532081536036181774978074189431315102955477655009198457796877965097992116862553511888207018038041858061522470391423330667591842813331560098242942355765889683951730611712728458972068839753060863540396674817048570478807357628370865895041538312268872618536781863871197169421126743030759667190882805504903029808477484838639974469555810010490899903677778069502126994325324949223110632238136736948200826580903961011999418666549878480616250754638063331065854194407699957670103475294292471039583143916783105478156002938874211758940115136702454289293148082980882192278524472452566135029624573808109109649309252338225627830739234979837222037955914285090634698564308827454790058471858855126283869977062755397903525489892165715915500917035211332234813097590879428377887887967781317023768816259879914
Output
(first run)

1 9

(second run)

70