/**
 * Few things make less sense
 * than does fir tree poetry
 * in java comments.
 */
class AndrewS {
	private static String treeStar(
		int treeWidth
 	) {
		String star = "";
		for( int i = 0; i <= treeWidth / 2 - 2; i++ ) {
			star += " ";
		}

		star += "_/\\_\n";

		for( int i = 0; i <= treeWidth / 2 - 2; i++ ) {
			star += " ";
		}

		star += " \\/\n";
	
		return( star );
	}

	private static String treeRow(
		int treeWidth,
		int segmentWidth,
		boolean bottomRow
	) {
		String treePod = "";
		for( int i = 0; i <= treeWidth / 2 - segmentWidth / 2; i++ ) {
			treePod += " ";
		}

		treePod += "/";

		for( int i = 0; i < segmentWidth - 2; i++ ) {
			if( bottomRow ) {
				treePod += '_';
			}
			else {
				treePod += i % 2 == 1 ? ')' : '(';
			}
		}

		treePod += "\\\n";

		return( treePod );
	}

	private static String treeAngle(
		int treeWidth,
		int maxWidth
	) {
		return(
			treeRow( treeWidth, maxWidth - 2, false ) +
			treeRow( treeWidth, maxWidth, true )
		);
	}

	private static String treeStem( int treeWidth, int treeHeight ) {
		String stemRow= "";
		int stemWidth = treeHeight / 2 - (treeHeight / 2) % 2;
		for( int i = 0; i < treeWidth / 2 - stemWidth / 2; i++ ) {
			stemRow += ' ';
		}

		stemRow += '|';

		for( int i = 0; i < stemWidth; i++ ) {
			stemRow += ' ';
		}

		stemRow += "|";
		
		String stem = "";
		for( int i = 0; i <= treeHeight / 2; i++ ) {
			stem = stem + stemRow;
			if( treeHeight >= 5 ) {
				if( i == (treeHeight / 2) - 2 ) {
					stem = stem + "      |\\_/|";
				}
				else if( i == (treeHeight / 2) - 1) {
					stem = stem + " nyo~ ='_'=";
				}
				else if( i == treeHeight / 2 ) {
					stem = stem + "      |._.|-*";
				}
			}
			stem = stem + "\n";
		}

		return( stem );
	}

	private static String treeGraph( int treeHeight ) {
		String tree = "";
		
		int maxWidth = (treeHeight + 1) * 2;

		if( treeHeight > 3 ) {
			tree += treeStar( maxWidth );
		}

		int currentWidth = 4;
		while( currentWidth <= maxWidth ) {
			tree += treeAngle( maxWidth, currentWidth );
			currentWidth += 2;
		}
		tree += treeStem( maxWidth, treeHeight );
		return( tree );
	}

	public static void main( String args[] ) {
		Terminal.println( "Let's make happy trees!" ); 
		int height = Terminal.askInt( 
			"How much tree is enough tree? " );

		Terminal.print( treeGraph( height ) );

		Terminal.println( "(Actually, you can't have enough tree! " +
			"But this will have to do for now!)" ); 
	}
}
