human
Perform given queries on Queue according to the given rules | Function to perform all the queries operations on the given queue.
Stores the count query of type 1.
Event E1 : increase countE1.
Event E2 : add the X in set.
Event E3 : Find position of X.
Initial position is ( position - countE1 ).
If X is already removed or popped out.
Finding the position of X in queue.
Traverse set to decrease position of X for all the number removed in front.
Print the position of X.
Driver Code"
How can the above be solved in Python?
 Can you provide a code to perform given queries on Queue according to the given rules and the other steps required?
assistant
#Here is code to perform given queries on Queue according to the given rules and the other steps required.
 def solve ( n , m , queries ) :
	countE1 = 0
	removed = set ( )
	for i in range ( 0 , m ) :
		if ( queries [ i ] [ 0 ] == 1 ) :
			countE1 += 1
		elif ( queries [ i ] [ 0 ] == 2 ) :
			removed . add ( queries [ i ] [ 1 ] )
		else :
			position = queries [ i ] [ 1 ] - countE1
			if ( queries [ i ] [ 1 ] in removed or position <= 0 ) :
				print ( " - 1" )
			else :
				for it in removed :
					if ( it > queries [ i ] [ 1 ] ) :
						break
					position -= 1
				print ( position )
if __name__ == " _ _ main _ _ " :
	N = 5
	Q = 3
	queries = [ [ 0 for _ in range ( 2 ) ] for _ in range ( Q ) ]
	queries [ 0 ] [ 0 ] = 1
	queries [ 0 ] [ 1 ] = 0
	queries [ 1 ] [ 0 ] = 3
	queries [ 1 ] [ 1 ] = 3
	queries [ 2 ] [ 0 ] = 2
	queries [ 2 ] [ 1 ] = 2
	solve ( N , Q , queries )