you give tree connect undirected acyclic graph S TCount number subtree connect subgraph S isomorphic tree t since number large output modulo 1097two subtree tree S consider different exist vertex S belong exactly themtree g call isomorphic tree h exist bijection f set vertex g set vertex h follow property edge vertex a b tree g edge vertex fA fb tree h and vice versa edge vertex a b tree h edge f1a f1b tree g