<s> class Queue : <EOL> def __init__ ( self ) : <EOL> self . data = collections . deque ( ) <EOL> def push ( self , x ) : <EOL> self . data . append ( x ) <EOL> def peek ( self ) : <EOL> return self . data [ <NUM_LIT:0> ] <EOL> def pop ( self ) : <EOL> return self . data . popleft ( ) <EOL> def size ( self ) : <EOL> return len ( self . data ) <EOL> def empty ( self ) : <EOL> return len ( self . data ) == <NUM_LIT:0> <EOL> class Stack : <EOL> def __init__ ( self ) : <EOL> self . q_ = Queue ( ) <EOL> def push ( self , x ) : <EOL> self . q_ . push ( x ) <EOL> for _ in xrange ( self . q_ . size ( ) - <NUM_LIT:1> ) : <EOL> self . q_ . push ( self . q_ . pop ( ) ) <EOL> def pop ( self ) : <EOL> self . q_ . pop ( ) <EOL> def top ( self ) : <EOL> return self . q_ . peek ( ) <EOL> def empty ( self ) : <EOL> return self . q_ . empty ( ) <EOL> class Stack2 : <EOL> def __init__ ( self ) : <EOL> self . q_ = Queue ( ) <EOL> self . top_ = None <EOL> def push ( self , x ) : <EOL> self . q_ . push ( x ) <EOL> self . top_ = x <EOL> def pop ( self ) : <EOL> for _ in xrange ( self . q_ . size ( ) - <NUM_LIT:1> ) : <EOL> self . top_ = self . q_ . pop ( ) <EOL> self . q_ . push ( self . top_ ) <EOL> self . q_ . pop ( ) <EOL> def top ( self ) : <EOL> return self . top_ <EOL> def empty ( self ) : <EOL> return self . q_ . empty ( ) </s>
