{"problem":{"name":"C. Component Tree","description":{"content":"This problem is a little bit unusual. Here you are to write a program to process queries in online mode. That means that your program will be allowed to read a query only after writing answer for the ","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":6000,"memory_limit":524288},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10051C"},"statements":[{"statement_type":"Markdown","content":"This problem is a little bit unusual. Here you are to write a program to process queries in online mode. That means that your program will be allowed to read a query only after writing answer for the previous query. Please be sure to use the stream flushing operation after each query's output in order not to leave part of your output in some buffer. For example, in С++ you've got to use the _fflush(stdout)_ function, in Java — call _System.out.flush()_, and in Pascal — _flush(output)_.\n\nImagine a complex application that consists of n components (the application itself is not essential in this problem, so we omit its description). All components form a tree-like hierarchy: each component except one (let's call this special component a _main component_) is contained in exactly one other component (let's call it a _parent component_). For the sake of convenience, let's assume that the components are numbered with integers from 1 to n with the main component having the number 1.\n\nEach component has a set of properties associated with it. Each property is given in the form _\"KEY=VALUE\"_. All property keys within a single component are distinct.\n\nYou are given the component tree together with all properties. Your task is to handle several queries for finding the property of a component. Each query is given as a pair (c, key), which means that you have to find the value of the property key for the component number c.\n\nTo answer the query, you have to follow this algorithm:\n\nThe first line of the input contains an integer n (1 ≤ n ≤ 3·105) — the number of components. Then the input contains the descriptions of components 1, 2, ..., n. \n\nEach description starts with a line containing two space-separated integers pi and ki (0 ≤ pi ≤ n, ki ≥ 0) — the number of parent component and the number of properties. For the first component pi is equal to 0. Each of the following ki lines contains a single property in the form _KEY=VALUE_, where both _KEY_ and _VALUE_ are strings of Latin letters and digits with length between 1 and 10 characters each. All keys for a given component are distinct. The keys are case-sensitive, so, for example, properties with keys \"_Length_\" and \"_length_\" are considered distinct. The values are also case-sensitive.\n\nThe next line contains an integer q (1 ≤ q ≤ 3·105) — the number of queries you have to answer. Each of the following q lines contains an integer cj (1 ≤ cj ≤ n) and a string keyj, separated by a single space, where keyj is a string of Latin letters and digits with length between 1 and 10 characters. Note that for each query, starting from the second, you will be able to read it only when you print the answer for the previous query and make a flush operation.\n\nIt is guaranteed that the total number of properties does not exceed 3·105.\n\nFor each query, print a line with the value of the required property. You should make a flush operation after each line.\n\n## Input\n\nThe first line of the input contains an integer n (1 ≤ n ≤ 3·105) — the number of components. Then the input contains the descriptions of components 1, 2, ..., n. Each description starts with a line containing two space-separated integers pi and ki (0 ≤ pi ≤ n, ki ≥ 0) — the number of parent component and the number of properties. For the first component pi is equal to 0. Each of the following ki lines contains a single property in the form _KEY=VALUE_, where both _KEY_ and _VALUE_ are strings of Latin letters and digits with length between 1 and 10 characters each. All keys for a given component are distinct. The keys are case-sensitive, so, for example, properties with keys \"_Length_\" and \"_length_\" are considered distinct. The values are also case-sensitive.The next line contains an integer q (1 ≤ q ≤ 3·105) — the number of queries you have to answer. Each of the following q lines contains an integer cj (1 ≤ cj ≤ n) and a string keyj, separated by a single space, where keyj is a string of Latin letters and digits with length between 1 and 10 characters. Note that for each query, starting from the second, you will be able to read it only when you print the answer for the previous query and make a flush operation.It is guaranteed that the total number of properties does not exceed 3·105.\n\n## Output\n\nFor each query, print a line with the value of the required property. You should make a flush operation after each line.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ s \\in \\Sigma^* $ be the encrypted string, where $ \\Sigma = \\{a, b, \\dots, z\\} $ and $ 1 \\leq |s| \\leq 10^5 $.\n\n**Constraints**  \nEach character of $ s $ is a lowercase English letter.\n\n**Objective**  \nOutput the original (decrypted) string corresponding to $ s $, under the unknown decryption algorithm.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10051C","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}