// Arup Guha
// 3/13/2019
// Solution to 2019 UCF HS Contest Problem: David and the Deli

import java.util.*;
import java.io.*;

public class deli {
	
	// For all possible costs.
	final public static int MAXBITS = 30;
	
	// Where we'll store our data.
	public static int n;
	public static bit[] mybits;
	public static TreeSet[] mytss;
	public static int[] pows;
	
	public static void main(String[] args) throws Exception {
	
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		int numCases = Integer.parseInt(stdin.readLine().trim());
		
		// Process each case.
		for (int loop=1; loop<=numCases; loop++) {
		
			// Get basic info.
			StringTokenizer tok = new StringTokenizer(stdin.readLine());
			n = Integer.parseInt(tok.nextToken());
			int numQ = Integer.parseInt(tok.nextToken());
			
			// Set up my BITs and TreeSets.
			mybits = new bit[MAXBITS+1];
			mytss = new TreeSet[MAXBITS+1];
			for (int i=0; i<=MAXBITS; i++) {
				mybits[i] = new bit(n);
				mytss[i] = new TreeSet<Integer>();
			}
			pows = new int[n+1];
			
			// Set up initial toppings - we have a bit and treeset for each cost. The treeset stores the indexes
			// with that cost and the bit stores 1 for each index with its associated cost.
			tok = new StringTokenizer(stdin.readLine());
			for (int i=1; i<=n; i++) {
				long val = Long.parseLong(tok.nextToken());
				int pow = getPow(val);
				pows[i] = pow;
				mybits[pow].add(i, 1);
				mytss[pow].add(i);
			}
			
			// Case header.
			System.out.println("Scenario #"+loop+":");
			StringBuilder sb = new StringBuilder();
			
			// Process queries.
			for (int i=0; i<numQ; i++) {
				
				// Get query type.
				tok = new StringTokenizer(stdin.readLine());
				int qtype = Integer.parseInt(tok.nextToken());
				
				// Handle answering question.
				if (qtype == 1) {
					long max = Long.parseLong(tok.nextToken());
					sb.append("David can get "+query(max, 1)+" toppings\n");
				}
				
				// Or an update.
				else {
					
					// Get relevant items.
					int idx = Integer.parseInt(tok.nextToken());
					int newval = getPow(Long.parseLong(tok.nextToken()));
					int oldval = pows[idx];
					
					// Change bits.
					mybits[oldval].add(idx,-1);
					mybits[newval].add(idx,1);
					
					// Change tree sets.
					mytss[oldval].remove(idx);
					mytss[newval].add(idx);
					
					// Update pows list.
					pows[idx] = newval;
				}
			}
			
			// Output everything for this case.
			System.out.println(sb);
		}
	}
	
	// Returns n where 2^n is the value of the highest one bit.
	public static int getPow(long v) {
		for (int i=62; i>=0; i--)
			if ((v & (1L<<i)) != 0)
				return i;
		return -1; // Should never trigger since our costs are always positive.
	}
	
	// max is how much money I have left, start is the index I am starting on, 1 based.
	public static int query(long max, int start) {
		
		// This is easy.
		if (max == 0 || start > n) return 0;
		
		// If we are down to 1, just check if any future cost is 1.
		if (max == 1) {
			Integer lastI = mytss[0].size() > 0 ? (Integer)mytss[0].last() : null;
			if (lastI == null) return 0;
			return lastI >= start ? 1 : 0;
		}
		
		// Take care of big cases here - note that a bit query isn't needed since ALL BITS are <= MAXBITS.
		if (max > (1L << MAXBITS)) {
			int searchTo = binsearch(start, n, MAXBITS, max-(1L<<MAXBITS));
			long left = max - query(start, searchTo, MAXBITS);
			return searchTo-start+1 + query(left, searchTo+1);
		}
		
		// Find where the first occurrence of the largest item we could possibly get is.
		int bigI = Math.min(getPow(max), MAXBITS);
		
		// Find the next index with bigI.
		Integer nextIndex = (Integer)mytss[bigI].higher(start-1);
		int firstBig = n+1;
		if (nextIndex != null) firstBig = nextIndex;
		
		// Find the sum of all the smaller elements upto the first occurence of big.
		long upto = query(start, firstBig-1, bigI-1); 
		
		// We can take everything.
		if (firstBig == n+1 && upto <= max) return numbits(start, n, bigI);
		
		// We will take everything upto the first occurrence of big.
		if (upto <= max-(1L<<bigI)) {
			return numbits(start,firstBig,bigI) + query(max-upto-(1L<<bigI), firstBig+1);
		}
		
		// Here we take everything up to big, EXCEPT for big...
		else if (upto <= max) {
			return numbits(start,firstBig-1,bigI-1) + query(max-upto, firstBig+1);
		}
		
		// Here, we know we'll only take items upto firstBig of smaller value and might get cutoff.
		else {
			
			// We can go upto nextI.
			int nextI = binsearch(start, firstBig-1, bigI-1, max);
			
			// When we do, this is what we have left.
			long left = max - query(start, nextI, bigI-1);
			
			// So, we took everything upto nextI, skip nextI+1, and try our best from there.
			return numbits(start,nextI,bigI-1) + query(left, nextI+2);
		}
	}
	
	// Returns the sum of elements from index start to index end using all bits upto maxset.
	public static long query(int start, int end, int maxset) {
		
		if (start > end) return 0;
		
		long res = 0L;
		for (int i=0; i<=maxset; i++)
			res += ((1L<<i)*mybits[i].sum(start,end));
		
		return res;
	}
	
	// Returns the max index  i >= start and i <= end such that sum[start..i] <= value.
	public static int binsearch(int start, int end, int maxset, long value) {
		
		int low = start, high = end;
		
		// Usual binary search.
		while (low < high) {
			
			// Try the middle.
			int mid = (low+high+1)/2;
			long tmp = query(start, mid, maxset);
			
			// We can go at least this far.
			if (tmp <= value)
				low = mid;
			
			// We can't make it this far.
			else
				high = mid-1;
		}
		
		// This is the best we can do.
		return low;
	}
	
	// Returns the number of bits on from index start to end that have value no more than maxset.
	public static int numbits(int start, int end, int maxset) {
		int res = 0;
		for (int i=0; i<=maxset; i++)
			res += mybits[i].sum(start, end);
		return res;
	}
}

class bit {

	public int[] cumfreq;
	
	// Do indexes 1 to n.
	public bit(int n) {
		int size = 1;
		while (size < n) size <<= 1;
		n = size;
		cumfreq = new int[n+1];
	}

	// Uses 1 based indexing.
	public void add(int index, int value) {
		while (index < cumfreq.length) {
			cumfreq[index] += value;
			index += Integer.lowestOneBit(index);
		}
	}

	// Returns the sum of everything upto index.
	public int sum(int index) {
		int ans = 0;
		while (index > 0) {
			ans += cumfreq[index];
			index -= (Integer.lowestOneBit(index));
		}
		return ans;
	}
	
	// Returns the sum of everything from low to high inclusive.
	public int sum(int low, int high) {
		return sum(high) - sum(low-1);
	}
	
}