#P9277. [AGM 2023 资格赛] 反转

[AGM 2023 资格赛] 反转

Problem Description

Given a sequence aa of length NN, where every number is less than 2K2^K. You need to perform exactly PP operations. In each operation, you flip one binary bit of one number. In the end, you need to make

ijaiaj(i<j)\sum_i\sum_j a_i\oplus a_j(i<j)

as large as possible, where \oplus is the bitwise XOR operation.

Input Format

The first line contains integers NN, KK, PP. It is guaranteed that 1N1051 \le N \le 10^5, 1K301 \le K \le 30, 1PN×K1 \le P \le N \times K.

The next line contains NN integers, the sequence aa. For all 1iN1 \le i \le N, it is guaranteed that 0ai<2K0 \le a_i < 2^K.

Output Format

Output PP lines. Each line contains two integers ii and jj, satisfying 1iN1 \le i \le N, 0j<K0 \le j < K, meaning that you flip the jj-th bit of the number aia_i. That is, aiai2ja_i \leftarrow a_i \oplus 2^j.

You may flip the same bit multiple times. If there are multiple solutions that maximize the total sum, output any one of them.

2 5 1
0 31
1 0
4 2 2
0 0 2 2
4 0
3 0
5 6 4
63 15 0 10 5

5 5
4 5
4 4
5 4

Hint

Translated by ChatGPT 5