P16337 「ALFR Round 10」Bit Problem

Description

Given two non-negative integers $n$ and $m$, you need to determine the value of the non-negative integer $n$ after applying the following operation exactly $k$ times: - $n \gets n \operatorname{and} \max(n - m, 0)$.

Input Format

There are $T$ test cases. The first line contains a positive integer $T$, the number of test cases. For each test case: - A single line contains three non-negative integers $n, m, k$.

Output Format

For each test case, output a single line containing one non-negative integer — the answer.

Explanation/Hint

For $100\%$ of the data: * $1 \le T \le 2 \times 10^5$; * $0 \le n, m, k \le 2^{30}$; * $k \ge 1$. | Subtask | $n,m,k