Handlers fire capture-phase root→target, then bubble-phase target→root. Input: line 1 — JSON array path from root to target (e.g. ["div","form","button"]); line 2 — JSON array of nodes that have BOTH capture and bubble handlers. Print fired handlers in order, one per line, as NODE capture / NODE bubble.
Input: two lines. Output: handler firings in order.
Your program reads from stdin and prints to stdout.
Example 1
Input: ["div","form","button"] ["div","button"]
Output: div capture button capture button bubble div bubble
Hints
Handlers fire capture-phase root→target, then bubble-phase target→root. Input: line 1 — JSON array path from root to target (e.g. ["div","form","button"]); line 2 — JSON array of nodes that have BOTH capture and bubble handlers. Print fired handlers in order, one per line, as NODE capture / NODE bubble.
Input: two lines. Output: handler firings in order.
Your program reads from stdin and prints to stdout.
Example 1
Input: ["div","form","button"] ["div","button"]
Output: div capture button capture button bubble div bubble
Hints