Implement a Stack using two queues q1 and q2.
Example 1:
Input:
push(2)
push(3)
pop()
push(4)
pop()
Output: 3 4
Explanation:
push(2) the stack will be {2}
push(3) the stack will be {2 3}
pop()   poped element will be 3 the 
        stack will be {2}
push(4) the stack will be {2 4}
pop()   poped element will be 4  
Example 2:
Input:
push(2)
pop()
pop()
push(3)
Output: 2 -1
Your Task:
Since this is a function problem, you don't need to take inputs. You are required to complete the two methods push() which takes an integer 'x' as input denoting the element to be pushed into the stack and pop() which returns the integer poped out from the stack(-1 if the stack is empty).
Expected Time Complexity: O(1) for push() and O(N) for pop() (or vice-versa).
Expected Auxiliary Space: O(1) for both push() and pop().
Constraints:
1 <= Number of queries <= 100
1 <= values of the stack <= 100

Difficulty: EASY
Tags: Data structures
Skill types: Data structures
Expected Time Complexity: O(1) for push() and O(N) for pop() (or vice-versa).
Expected Auxiliary Space: O(1) for both push() and pop().

Starter code:
#User function Template for python3
'''
    :param x: value to be inserted
    :return: None

    queue_1 = [] # first queue
    queue_2 = [] # second queue
   '''
   
#Function to push an element into stack using two queues.
def push(x):
    
    # global declaration
    global queue_1
    global queue_2
    
    # code here


#Function to pop an element from stack using two queues.     
def pop():
    
    # global declaration
    global queue_1
    global queue_2
    
    # code here

Solutions:
def push(x):
	global queue_1
	global queue_2
	queue_1.append(x)
	while queue_2:
		val = queue_2.pop(0)
		queue_1.append(val)
	(queue_1, queue_2) = (queue_2, queue_1)

def pop():
	global queue_1
	global queue_2
	if not queue_2:
		return -1
	return queue_2.pop(0)


def push(x):
	global queue_1
	global queue_2
	queue_1.append(x)

def pop():
	global queue_1
	global queue_2
	if len(queue_1) >= 1:
		while len(queue_1) > 1:
			a = queue_1.pop(0)
			queue_2.append(a)
		ans = queue_1.pop(0)
		b = queue_1
		queue_1 = queue_2
		queue_2 = b
		return ans
	else:
		return -1


def push(x):
	global queue_1
	global queue_2
	while len(queue_1) != 0:
		queue_2.append(queue_1.pop(0))
	queue_1.append(x)
	while len(queue_2) != 0:
		queue_1.append(queue_2.pop(0))

def pop():
	global queue_1
	global queue_2
	if len(queue_1) == 0:
		return -1
	else:
		return queue_1.pop(0)


def push(x):
	global queue_1
	global queue_2
	queue_1.append(x)

def pop():
	global queue_1
	global queue_2
	if queue_1 == []:
		return -1
	while len(queue_1) > 1:
		val = queue_1.pop(0)
		queue_2.append(val)
	ans = queue_1.pop(0)
	while len(queue_2) > 0:
		val = queue_2.pop(0)
		queue_1.append(val)
	return ans


def push(x):
	global queue_1
	global queue_2
	queue_1.append(x)

def pop():
	global queue_1
	global queue_2
	if not queue_1:
		return -1
	while len(queue_1) > 1:
		queue_2.append(queue_1.pop(0))
	popped_element = queue_1.pop(0)
	(queue_1, queue_2) = (queue_2, queue_1)
	return popped_element


def push(x):
	global queue_1
	global queue_2
	queue_1.append(x)

def pop():
	global queue_1
	global queue_2
	return queue_1.pop() if queue_1 else -1


def push(x):
	global queue_1
	global queue_2
	queue_1.append(x)

def pop():
	global queue_1
	queue_2 = []
	if len(queue_1) > 0:
		for i in range(len(queue_1) - 1):
			queue_2.append(queue_1.pop(0))
		temp = queue_1.pop()
		queue_1 = queue_2
		del queue_2
		return temp
	else:
		return -1


def push(x):
	global queue_1
	global queue_2
	queue_1.insert(0, x)

def pop():
	global queue_1
	global queue_2
	if len(queue_1) == 0:
		return -1
	while len(queue_1) != 1:
		queue_2.insert(0, queue_1.pop())
	res = queue_1.pop()
	while len(queue_2) != 0:
		queue_1.insert(0, queue_2.pop())
	return res


def isEmpty(queue):
	if len(queue) == 0:
		return True
	else:
		return False

def push(x):
	global queue_1
	global queue_2
	queue_2.append(x)
	while not isEmpty(queue_1):
		queue_2.append(queue_1.pop(0))
	while not isEmpty(queue_2):
		queue_1.append(queue_2.pop(0))

def pop():
	global queue_1
	global queue_2
	if isEmpty(queue_1):
		return -1
	temp = queue_1.pop(0)
	return temp


def push(x):
	global queue_1
	global queue_2
	queue_1.append(x)

def pop():
	global queue_1
	global queue_2
	if not queue_1:
		return -1
	return queue_1.pop()


def push(x):
	global queue_1
	global queue_2
	queue_1.append(x)

def pop():
	global queue_1
	global queue_2
	size = len(queue_1)
	if size == 0:
		return -1
	for _ in range(size - 1):
		queue_2.append(queue_1.pop(0))
	popedValue = queue_1.pop(0)
	(queue_1, queue_2) = (queue_2, queue_1)
	return popedValue


def push(x):
	global queue_1
	global queue_2
	queue_1.append(x)

def pop():
	global queue_1
	global queue_2
	res = -1
	if len(queue_2) != 0:
		ele = queue_2[0]
		del queue_2[0]
	elif len(queue_1) != 0:
		while len(queue_1) != 1:
			queue_2.append(queue_1[0])
			del queue_1[0]
		res = queue_1[0]
		del queue_1[0]
		(queue_1, queue_2) = (queue_2, queue_1)
	return res


def push(x):
	global queue_1
	global queue_2
	queue_1.append(x)
	for i in range(0, len(queue_1) - 1):
		queue_1.append(queue_1.pop())

def pop():
	global queue_1
	global queue_2
	if not queue_1:
		return -1
	return queue_1.pop()


def dequeue(q):
	r = q[0]
	del q[0]
	return r

def enqueue(q, x):
	q.append(x)

def push(x):
	global queue_1
	global queue_2
	while len(queue_1) != 0:
		k = dequeue(queue_1)
		enqueue(queue_2, k)
	enqueue(queue_1, x)
	while len(queue_2) != 0:
		k = dequeue(queue_2)
		enqueue(queue_1, k)

def pop():
	global queue_1
	global queue_2
	if queue_1:
		k = dequeue(queue_1)
		return k
	else:
		return -1