Write an efficient algorithm to serialize and deserialize an n-ary tree structure.
Represent the input tree as [value, [children...]], where each value is an integer. Implement serialize_and_deserialize(root) to return both a serialized string and the reconstructed tree in the same nested representation. Use preorder encoding, storing each node's value followed by its number of children, separated by spaces. Serialize an empty tree as an empty string.
def serialize_and_deserialize(root):