Write a function to build a tree from a given string.
Use the format A(B,C(D,E)), where each node has a single-character value and optional comma-separated children inside parentheses. Return the tree as nested dictionaries with value and children keys.
Function signature: build_tree(s). The input is non-empty, valid, and contains no whitespace. A leaf node has an empty children list.
def build_tree(s):