Serge came to the school dining room and discovered that there is a big queue here. There are $m$ pupils in the queue. He's not sure now if he wants to wait until the queue will clear, so he wants to know which dish he will receive if he does. As Serge is very tired, he asks you to compute it instead of him.

Initially there are $n$ dishes with costs $a_1, a_2, \ldots, a_n$. As you already know, there are the queue of $m$ pupils who have $b_1, \ldots, b_m$ togrogs respectively (pupils are enumerated by queue order, i.e the first pupil in the queue has $b_1$ togrogs and the last one has $b_m$ togrogs)

Pupils think that the most expensive dish is the most delicious one, so every pupil just buys the most expensive dish for which he has money (every dish has a single copy, so when a pupil has bought it nobody can buy it later), and if a pupil doesn't have money for any dish, he just leaves the queue (so brutal capitalism...)

But money isn't a problem at all for Serge, so Serge is buying the most expensive dish if there is at least one remaining.

Moreover, Serge's school has a very unstable economic situation and the costs of some dishes or number of togrogs of some pupils can change. More formally, you must process $q$ queries:

  change $a_i$ to $x$. It means that the price of the $i$-th dish becomes $x$ togrogs.  change $b_i$ to $x$. It means that the $i$-th pupil in the queue has $x$ togrogs now. 

Nobody leaves the queue during those queries because a saleswoman is late.

After every query, you must tell Serge price of the dish which he will buy if he has waited until the queue is clear, or $-1$ if there are no dishes at this point, according to rules described above.


-----Input-----

The first line contains integers $n$ and $m$ ($1 \leq n, m \leq 300\ 000$) — number of dishes and pupils respectively. The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \leq a_i \leq 10^{6}$) — elements of array $a$. The third line contains $m$ integers $b_1, b_2, \ldots, b_{m}$ ($1 \leq b_i \leq 10^{6}$) — elements of array $b$. The fourth line conatins integer $q$ ($1 \leq q \leq 300\ 000$) — number of queries.

Each of the following $q$ lines contains as follows:   if a query changes price of some dish, it contains $1$, and two integers $i$ and $x$ ($1 \leq i \leq n$, $1 \leq x \leq 10^{6}$), what means $a_i$ becomes $x$.  if a query changes number of togrogs of some pupil, it contains $2$, and two integers $i$ and $x$ ($1 \leq i \leq m$, $1 \leq x \leq 10^{6}$), what means $b_i$ becomes $x$. 


-----Output-----

For each of $q$ queries prints the answer as the statement describes, the answer of the $i$-th query in the $i$-th line (the price of the dish which Serge will buy or $-1$ if nothing remains)


-----Examples-----
Input
1 1
1
1
1
1 1 100

Output
100

Input
1 1
1
1
1
2 1 100

Output
-1

Input
4 6
1 8 2 4
3 3 6 1 5 2
3
1 1 1
2 5 10
1 1 6

Output
8
-1
4



-----Note-----

In the first sample after the first query, there is one dish with price $100$ togrogs and one pupil with one togrog, so Serge will buy the dish with price $100$ togrogs.

In the second sample after the first query, there is one dish with price one togrog and one pupil with $100$ togrogs, so Serge will get nothing.

In the third sample after the first query, nobody can buy the dish with price $8$, so Serge will take it. After the second query, all dishes will be bought, after the third one the third and fifth pupils will by the first and the second dishes respectively and nobody will by the fourth one.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = "import sys\nfrom itertools import accumulate \nclass Lazysegtree:\n    #RAQ\n    def __init__(self, A, intv, initialize = True, segf = min):\n        #区間は 1-indexed で管理\n        self.N = len(A)\n        self.N0 = 2**(self.N-1).bit_length()\n        self.intv = intv\n        self.segf = segf\n        self.lazy = [0]*(2*self.N0)\n        if initialize:\n            self.data = [intv]*self.N0 + A + [intv]*(self.N0 - self.N)\n            for i in range(self.N0-1, 0, -1):\n                self.data[i] = self.segf(self.data[2*i], self.data[2*i+1]) \n        else:\n            self.data = [intv]*(2*self.N0)\n\n    def _ascend(self, k):\n        k = k >> 1\n        c = k.bit_length()\n        for j in range(c):\n            idx = k >> j\n            self.data[idx] = self.segf(self.data[2*idx], self.data[2*idx+1]) \\\n            + self.lazy[idx]\n            \n    def _descend(self, k):\n        k = k >> 1\n        idx = 1\n        c = k.bit_length()\n        for j in range(1, c+1):\n            idx = k >> (c - j)\n            ax = self.lazy[idx]\n            if not ax:\n                continue\n            self.lazy[idx] = 0\n            self.data[2*idx] += ax\n            self.data[2*idx+1] += ax\n            self.lazy[2*idx] += ax\n            self.lazy[2*idx+1] += ax\n    \n    def query(self, l, r):\n        L = l+self.N0\n        R = r+self.N0\n        Li = L//(L & -L)\n        Ri = R//(R & -R)\n        self._descend(Li)\n        self._descend(Ri - 1)\n        \n        s = self.intv                                                              \n        while L < R:\n            if R & 1:\n                R -= 1\n                s = self.segf(s, self.data[R])\n            if L & 1:\n                s = self.segf(s, self.data[L])\n                L += 1\n            L >>= 1\n            R >>= 1\n        return s\n    \n    def add(self, l, r, x):\n        L = l+self.N0\n        R = r+self.N0\n\n        Li = L//(L & -L)\n        Ri = R//(R & -R)\n        \n        while L < R :\n            if R & 1:\n                R -= 1\n                self.data[R] += x\n                self.lazy[R] += x\n            if L & 1:\n                self.data[L] += x\n                self.lazy[L] += x\n                L += 1\n            L >>= 1\n            R >>= 1\n        \n        self._ascend(Li)\n        self._ascend(Ri-1)\n    \n    def binsearch(self, l, r, check, reverse = False):\n        L = l+self.N0\n        R = r+self.N0\n        Li = L//(L & -L)\n        Ri = R//(R & -R)\n        self._descend(Li)\n        self._descend(Ri-1)\n        SL, SR = [], []\n        while L < R:\n            if R & 1:\n                R -= 1\n                SR.append(R)\n            if L & 1:\n                SL.append(L)\n                L += 1\n            L >>= 1\n            R >>= 1\n        \n        if reverse:\n            for idx in (SR + SL[::-1]):\n                if check(self.data[idx]):\n                    break\n            else:\n                return -1\n            while idx < self.N0:\n                ax = self.lazy[idx]\n                self.lazy[idx] = 0\n                self.data[2*idx] += ax\n                self.data[2*idx+1] += ax\n                self.lazy[2*idx] += ax\n                self.lazy[2*idx+1] += ax\n                idx = idx << 1\n                if check(self.data[idx+1]):\n                    idx += 1\n            return idx - self.N0\n        else:\n            for idx in (SL + SR[::-1]):\n                if check(self.data[idx]):\n                    break\n            else:\n                return -1\n            while idx < self.N0:\n                ax = self.lazy[idx]\n                self.lazy[idx] = 0\n                self.data[2*idx] += ax\n                self.data[2*idx+1] += ax\n                self.lazy[2*idx] += ax\n                self.lazy[2*idx+1] += ax\n                idx = idx << 1\n                if not check(self.data[idx]):\n                    idx += 1\n            return idx - self.N0\n    def provfunc(self):\n        idx =  1\n        if self.data[1] >= 0:\n            return -1\n        while idx < self.N0:\n            ax = self.lazy[idx]\n            self.lazy[idx] = 0\n            self.data[2*idx] += ax\n            self.data[2*idx+1] += ax\n            self.lazy[2*idx] += ax\n            self.lazy[2*idx+1] += ax\n            idx = idx << 1\n            if self.data[idx+1] < 0:\n                idx += 1\n        return idx - self.N0\n\nN, M = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\ntable = [0]*(10**6+1)\nfor a in A:\n    table[a] -= 1\nfor b in B:\n    table[b] += 1\ntable = list(accumulate(table[::-1]))[::-1]\nT = Lazysegtree(table, 0, True, min)\nQ = int(input())\nAns = [None]*Q\nfor q in range(Q):\n    t, i, x = list(map(int, sys.stdin.readline().split()))\n    i -= 1\n    if t == 1:\n        T.add(0, x+1, -1)\n        T.add(0, A[i]+1, 1)\n        A[i] = x\n    else:\n        T.add(0, x+1, 1)\n        T.add(0, B[i]+1, -1)\n        B[i] = x\n    Ans[q] = T.provfunc()\n\nprint('\\n'.join(map(str, Ans)))        \n"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 58342823