403558: GYM101193 I Credit history

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. Credit historytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Banking software is the most reliable software in the world. At least so claim its developers. But even it can fail, and a failure has happened at the "Horns and Hoofs” bank branch. All credit payments data is lost, and the bank is left with only debtors names database. It is a very objectionable situation. All debtors claim that their small debts were almost fully paid. And yet the SEO Plyushkin is having doubts, so he has decided that all debt amounts need to be recalculated. The debt amount is the difference between the credit amount and the already paid amount, which are represented as n-digit integer numbers (potentially with leading zeroes). The debt is calculated in the following way: the customer relations expert Durilkin picks a digit and the debtor Nakupilkin puts it in place of a digit in the not yet restored credit or payment amount number. This procedure is repeated until both numbers are restored. Durilkin wants to maximize the debt amount and Nakupilkin wants to minimize it.

You have a chance to act as both Durilkin and Nakupilkin, and you need to do it optimally. Of course, your opponent will play optimally.

Input

The first input line contains two numbers t and n. t denotes the person which you are about to play for (1 for Durilkin, 2 for Nakupilkin). n denotes the number of digits in the credit and payment fields.

1 ≤ n ≤ 9
Output

Durilkin picks a digit. If you act as him, you need to output it, otherwise you need to read it.

Then Nakupilkin picks the digit position and the field for the digit insertion. Nakupilkin names two numbers: r and c. If r is equal to one, he wants to edit the credit amount; if r is equal to two, then he wants to edit the payment amount. c denotes the digit index; the digit enumeration starts at the most significant digit. If you act as Nakupilkin, you need to output r c, otherwise you need to read these numbers.

1 ≤ r ≤ 2
1 ≤ c ≤ n

Don’t forget to put a newline character and to flush the output stream after you print. For example, use fflush(stdout) in C++, System.out.flush() in Java, and flush(output) in Pascal.

加入题单

上一题 下一题 算法标签: