#include <iostream>
#include <fstream>
#include "function.h"

void tryTestCase(MyBinaryTreeOps &mbtops)
{
    // parse each case
    std::string treeSExp;
    while( std::cin >> treeSExp )
    {
        // the pointer to the tree root
        Node *root;
        
        // construct the tree
        root = mbtops.constructTree( root, treeSExp );
        
        std::cout << mbtops.treeHeight( root ) << " ";
        std::cout << mbtops.treeWeight( root ) << " ";
        std::cout << mbtops.leafNum( root ) << " ";
        std::cout << mbtops.maxPathWeight( root ) << std::endl;
        
        // release the tree
        root = mbtops.deleteTree( root );
    }
}


int main(int argc, char* argv[])
{
    MyBinaryTreeOps mbtops;
    tryTestCase( mbtops );

    return 0;
}
