luogu#P16337. 「ALFR Round 10」Bit Problem

「ALFR Round 10」Bit Problem

Problem Description

Given two non-negative integers nn and mm, you need to determine the value of the non-negative integer nn after applying the following operation exactly kk times:

  • nnandmax(nm,0)n \gets n \operatorname{and} \max(n - m, 0).

Input Format

There are TT test cases.

The first line contains a positive integer TT, the number of test cases.

For each test case:

  • A single line contains three non-negative integers n,m,kn, m, k.

Output Format

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

7
1 2 2
3 5 1
2 3 3
6 7 1
1 6 1
4 9 1
9 1 1
0
0
0
0
0
0
8

Hint

For 100%100\% of the data:

  • 1T2×1051 \le T \le 2 \times 10^5;
  • 0n,m,k2300 \le n, m, k \le 2^{30};
  • k1k \ge 1.
Subtask n,m,k<n,m,k < Special Property
1 232^3 None
2 292^9 ^
3 2172^{17} T100T \le 100
4 2302^{30} None