Implement different operations on an unordered set s .

**Input:**

The first line of input contains an integer **T** denoting the no of test cases . Then T test cases follow. The first line of input contains an integer **Q** denoting the no of queries . Then in the next line are **Q** space separated queries .

A query can be of four types

1. a x (inserts an element x to the unordered set s)

2. b x (erases an element x from the unordered set s)

3. c x (prints 1 if the element x is present in the set else print -1)

4. d (prints the size of the unordered set s)

**Output:**

The output for each test case will be space separated integers denoting the results of each query .

**Constraints:**

1<=T<=100

1<=Q<=100

**Example(To be used only for only expected output):**

**Input**

2

5

a 1 a 2 a 3 b 2 d

4

a 1 a 5 d c 2

**
Output**

2

2 -1

For the first test case

There are five queries. Queries are performed in this order

1. a 1 {inserts 1 to set now set has {1} }

2. a 2 {inserts 2 to set now set has {1,2} }

3. a 3 {inserts 3 to set now set has {1,2,3} }

4. b 2 {removes 2 from the set }

5. d {prints the size of the unordered set ie 2}

There are four queries. Queries are performed in this order

1. a 1 {inserts 1 to set now set has {1} }

2. a 5 {inserts 5 to set now set has {1,5} }

3. d {prints the size of the set ie 2}

4. c 2 {since 2 is not present in the set prints -1}

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

sabka_din_aayega | 317 |

maggiiiii | 248 |

thanuvinu94 | 211 |

Savage_19 | 206 |

Anugrah_kumar | 172 |

Bishnu Dev Panda | 803 |

sabka_din_aayega | 628 |

Anugrah_kumar | 562 |

okayboss | 561 |

maggiiiii | 531 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4925 |

Quandray | 4547 |

Login to report an issue on this page.