import static java.lang.System.out;
import java.io.*;

public class MArray {
	private int size, capacity;
	private Object[] small, big;
	
	public int getSize() {
		return size;
	}
	
	public int getCapacity() {
		return capacity;
	}
	
	private void swap( int index ) {
		// assert( 0 <= index && index < size );
		Object tmp = small[ index ];
		small[ index ] = big[ index ];
		big[ index ] = tmp;
	}
	
	public MArray() {
		size = 0;
		capacity = 1;
		
		small = new Object[ capacity ];
		big = new Object[ capacity * 2 ];
	}
	
	public Object getElement( int index ) {
		if( index >= capacity / 2 || index < size - capacity / 2 ) {
			return big[ index ];
		}
		return small[ index ];
	}
	
	public void pushBack( Object e ) {
		if( size == capacity ) {
			capacity *= 2;
			small = big;
			big = new Object[ capacity * 2 ];
		}
		
		int lower = size - capacity / 2;
		swap( lower );
		
		big[ size++ ] = e;
	}
	
	public void popBack() {
		if( size == 0 ) {
			return;
		}
		big[ --size ] = null;
		
		int lower = size - capacity / 2;
		swap( lower );
		
		if( lower <= 0 && size > 0 ) {
			capacity /= 2;
			big = small;
			small = new Object[ capacity ];
		}
	}
	
	public void dump() {
		out.println( "Size: " + size + "/" + capacity );
		out.println( "Small\t\tBig\t\tgetElement" );
		for( int i = 0 ; i < capacity ; i++ ) {
			out.println( small[ i ] + "\t\t" + big[ i ] + "\t\t" + getElement( i ) );
		}
		for( int i = 0 ; i < capacity ; i++ ) {
			out.println( "\t\t" + big[ capacity + i ] );
		}
	}
	
	static public void main( String[] args ) {
		MArray arr = new MArray();
		InputStreamReader in = new InputStreamReader(System.in);
		
		out.println( "+: pushBack\t\t'-' popBack\t\t'q' quit");
		while( true ) {
			char c = ' ';
			try {
				c = (char) in.read();
			} catch( Exception e ) {
			}
				
			if( c == '+' ) {
				out.println( "PushBack" );
				arr.pushBack( arr.getSize() );
				arr.dump();
			} else if( c == '-' ) {
				out.println( "PopBack" );
				arr.popBack();
				arr.dump();
			} else if( c == 'd' ) {
				out.println( "Dump" );
				arr.dump();
			} else if( c == 'q' ) {
				return;
			}
		}
	}
}