Implement a function that processes a series of queries involving updates and queries on two lists, using a segment tree data structure to efficiently manage the updates and retrieve values.
Function Signature
python
def process_queries(n, m, a, b, queries):
Functional Requirements
Segment Tree Implementation: Create a segment tree to handle range modifications and point queries efficiently.
Handle Queries: The function should process a list of queries, where each query can either modify a range of values in the segment tree or return a value based on the modifications.
Query Types
Modification Query (Type 1): Given parameters (x, y, k), it signifies that from the y-th (1-indexed) position, the next k positions should be marked with the index of the current query (to identify the most recent modification).
Value Retrieval Query (Type 2): Given a parameter pos, it retrieves a value based on the latest modification affecting that position:
If a modification exists for pos, return the value from list a computed as a[x + (pos - y)] where (x, y, k) are the parameters of the latest modification.
If no modification exists, return the value from list b at position pos.
Input and Output Requirements
Input
n: An integer representing the size of the list a (the number of elements).
m: An integer representing the number of queries to process.
a: A list of integers of size n.
b: A list of integers of size n.
queries: A list of m queries where each query is a list structured as follows:
Type 1 (Modification): [1, x, y, k]
Type 2 (Value Retrieval): [2, pos]
Output
Returns a list of results for all Type 2 queries in the order they were processed.
Example
python
n = 5
m = 3
a = [10, 20, 30, 40, 50]
b = [1, 2, 3, 4, 5]
queries = [[1, 0, 1, 3], [2, 1], [2, 2]]
result = process_queries(n, m, a, b, queries)
# Expected Output: [20, 30]
Deliverables
The solution should be implemented in a file named /app/solution.py.