ASeDatAb

아직 제출이 없습니다시간 제한10초메모리 제한1024 MB

문제

A research consortium has been looking for the best possible database for three years, but they are still having problems. The database stores values as records that hold 88-bit binary strings. Unfortunately, their implementation of the function to set the value of a record is flawed.

Each record of the database is an 88⁠-bit binary string. The bits of the binary string are indexed from 00 to 77 from left to right. When an instruction to set a specific record to a new value VV is received, instead of setting the value to VV the database does the following:

  1. Choose an integer rr between 00 and 77, inclusive, and let WW be like VV but rotated by rr to the right. That is, the ((i+r)mod8)((i + r) \bmod 8)⁠-th bit of WW is the ii⁠-th bit of VV.
  2. Replace the current value XX of the record with XX XOR WW. That is, the new value of the record has a 11 as its ii⁠-th bit if and only if the ii⁠-th bits of XX and WW are different.
  3. Finally, return the number of bits that are 11 in the new value to the user.

Luckily, it turns out that no matter what the initial value is or what rotation values the database chooses, it is always possible to reset the value of a record to have all bits be 00 with no more than 300300 uses of this operation. Implement a program to interact with the database that does this.

제한

  • 1T1001 \le \mathbf{T} \le 100.
  • 1N_i8-1 \le \mathbf{N\_i} \le 8 for all ii.