decimal number has a base k same. The singular digits of a base k number are called k-its. How about we characterize the k-itwise XOR of two k-its an and b as (a+b)modk.    The k-itwise XOR of two base k numbers is equivalent to the new number framed by taking the k-itwise XOR of their relating k-its. The k-itwise XOR of two decimal

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Correct answer will be upvoted else downvoted.

 

Each decimal number has a base k same. The singular digits of a base k number are called k-its. How about we characterize the k-itwise XOR of two k-its an and b as (a+b)modk. 

 

The k-itwise XOR of two base k numbers is equivalent to the new number framed by taking the k-itwise XOR of their relating k-its. The k-itwise XOR of two decimal numbers an and b is signified by a⊕kb and is equivalent to the decimal portrayal of the k-itwise XOR of the base k portrayals of an and b. All further numbers utilized in the assertion underneath are in decimal except if indicated. When k=2 (it is in every case valid in this form), the k-itwise XOR is as old as bitwise XOR. 

 

You have hacked the criminal data set of Rockport Police Department (RPD), otherwise called the Rap Sheet. However, to get to it, you require a secret word. You don't have any acquaintance with it, yet you are very certain that it lies somewhere in the range of 0 and n−1 comprehensive. In this way, you have chosen to get it. Fortunately, you can attempt all things considered n times without being impeded by the system. Yet, the system is versatile. Each time you make an erroneous supposition, it changes the secret phrase. In particular, if the secret key before the speculation was x, and you surmise an alternate number y, then, at that point, the system changes the secret phrase to a number z to such an extent that x⊕kz=y. Supposition the secret phrase and break into the system. 

 

Input 

 

The principal line of input contains a solitary integer t (1≤t≤10000) meaning the number of experiments. t experiments follow. 

 

The primary line of each experiment contains two integers n (1≤n≤2⋅105) and k (k=2). 

 

It is ensured that the amount of n over all experiments doesn't surpass 2⋅105. 

 

Association 

 

For each experiment, first read two integers n and k. Then, at that point, you might ask up to n questions. 

 

For each question, print a solitary integer y (0≤y≤2⋅107). Leave the current secret phrase alone x. From that point onward, read an integer r. 

 

In the event that x=y, you will peruse r=1 and the experiment is tackled. You should then keep addressing the excess experiments. 

 

Else, you will peruse r=0. As of now the secret phrase is changed to a number z with the end goal that x⊕kz=y. 

 

Subsequent to printing a question, remember to output the finish of line and flush the output. If not, you will get as far as possible surpassed decision.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY