// Arup Guha
// 1/25/2019
// Alternate solution to proposed 2019 Mercer Problem: Discord Dilemma
// Note: I intentionally output each item one by one, so that this runs
//       pretty slowly; I don't want to require someone using a StringBuilder
//       and outputting once.

import java.util.*;
import java.io.*;

public class discord_arup {
	
	// Constants for operations.
	final public static char LOGON = 'A';
	final public static char LOGOFF = 'B';
	final public static char ADDROLE = 'C';
	final public static char DELROLE = 'D';
	
	public static void main(String[] args) throws Exception {
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		int nC = Integer.parseInt(stdin.readLine());
		
		// Go through each case.
		for (int loop = 0; loop<nC; loop++) {
			
			StringTokenizer tok = new StringTokenizer(stdin.readLine());
			int n = Integer.parseInt(tok.nextToken());
			int numQ = Integer.parseInt(tok.nextToken());
			
			// Get my roles - automatically add n+1.
			int nRoles = Integer.parseInt(tok.nextToken());
			TreeSet<Integer> mine = new TreeSet<Integer>();
			mine.add(n+1);
			tok = new StringTokenizer(stdin.readLine());
			for (int i=0; i<nRoles; i++)
				mine.add(Integer.parseInt(tok.nextToken()));
			
			// BIT to keep track of how many people at each level.
			bit mybit = new bit(n+1);
			
			// Go through each query.
			for (int i=0; i<numQ; i++) {
				
				// Get this line.
				tok = new StringTokenizer(stdin.readLine());
				
				char type = tok.nextToken().charAt(0);
				
				// Handle a log on.
				if (type == LOGON) {
					int level = Integer.parseInt(tok.nextToken());
					int numPeople = Integer.parseInt(tok.nextToken());
					mybit.add(level, numPeople);
				}
				
				// Log off, just subtract.
				else if (type == LOGOFF) {
					int level = Integer.parseInt(tok.nextToken());
					int numPeople = Integer.parseInt(tok.nextToken());
					mybit.add(level, -numPeople);					
				}
				
				// Add to my set.
				else if (type == ADDROLE) {
					int level = Integer.parseInt(tok.nextToken());
					mine.add(level);
				}
				
				// Get rid of my role, only if it's there.
				else {
					int level = Integer.parseInt(tok.nextToken());
					if (mine.contains(level)) mine.remove(level);
				}
				
				// My current rank is the sum of people before me, plus 1.
				System.out.println(mybit.sum(mine.first()-1)+1);
			}
		}
	}
}

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, long 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;
	}
}
