// Arup Guha
// 10/21/2026
// Example to show use of StringTokenizer, ArrayList

import java.util.*;

public class ReadTeam {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		Team dolphins = new Team();
		
		// Reads in the whole line, put into StringTokenizer.
		StringTokenizer tok = new StringTokenizer(stdin.nextLine());
		
		// Extract tokens convert to integers.
		// For doubles do Double.parseDouble().
		int numPlayers = Integer.parseInt(tok.nextToken());
		int numOffense = Integer.parseInt(tok.nextToken());
		int numDefense = Integer.parseInt(tok.nextToken());
		
		for (int i=0; i<numPlayers; i++) {
		
			// These tokens are comma delimited!
			tok = new StringTokenizer(stdin.nextLine(), ",");
		
			// Get each piece out.
			String name = tok.nextToken();
			String position = tok.nextToken();
			int jerseyNum = Integer.parseInt(tok.nextToken());
			
			// Create the player object.
			Player tmp = new Player(name, position, jerseyNum);
			
			// Adding another player, probably won't help us win a game :(
			dolphins.addPlayer(tmp);
		}
		
		// Print out team.
		System.out.println(dolphins);
		
		// Do removals.
		int numRemove = Integer.parseInt(stdin.nextLine());
		for (int i=0; i<numRemove; i++) {
			String guy = stdin.nextLine();
			if (dolphins.remove(dolphins.getPlayer(guy)))
				System.out.println(guy+" has been removed from the team.");
			else
				System.out.println(guy+" wasn't on the team to begin with.");
		}
		
		// See updates.
		System.out.println(dolphins);
	}

}