defget_ans(self):# 计算该数几次操作后变为1 ans = -1# 因为是变为1,所以要减去一次 while self: ans += 1 self >>= 1 return ans
defmain(): T = int(input()) N = 10005 num = [0] * N for t inrange(T): n, k = map(int, input().split()) s = input().split() for i inrange(n): num[i] = get_ans(int(s[i])) f = True res = [] cnt = 0 i = 0 while i < n: if num[i] == 0: i += 1 else: j = i while j < n and (j == 0or num[j] > num[j - 1]): num[j] -= 1 j += 1 if j - i < k: # 注意在while结束的j是多了1的,就不用在加上1了 f = False print(-1) break cnt += 1 res.append(i + 1) res.append(j) if f: print(cnt) for i inrange(0, cnt << 1, 2): print('%d %d' % (res[i], res[i + 1]))