The first line contains two integers nnn (2≤n≤200000)(2 \le n \le 200\,000)(2≤n≤200000) and qqq (1≤q≤200000)(1 \le q \le 200\,000)(1≤q≤200000), indicating the number of cities in Byteland and the number of days of the chief test driver's journey in Byteland.
In each of the next nnn lines, three integers uuu, vvv (1≤u,v≤n,u≠v)(1 \le u, v \le n, u \neq v)(1≤u,v≤n,u=v) and kkk (≥1)(\ge 1)(≥1) comes first, indicating that the uuu-th city and the vvv-th city is connected by a road, where the garage sells car paints of kkk colours. Then kkk distinct integers c1,c2,...,ckc_1, c_2, ..., c_kc1,c2,...,ck (1≤ci≤500000)(1 \le c_i \le 500\,000)(1≤ci≤500000) follows, indicating the colours of car paints sold by the garage. It is guaranteed that the sum of kkk does not exceed 500000500\,000500000.
Each of the next qqq lines contains two integers aaa and bbb (1≤a,b≤n,a≠b)(1 \le a, b \le n, a \neq b)(1≤a,b≤n,a=b), indicating a journey from the aaa-th city to the bbb-th city.