You will be given a list L. Each element Li will contain a list of integers. You have to perform two types of queries in list L.
1ilrxy
This is the query of type 1 which asks you to replace the elements Lik(l≤k≤r) with y if Lik=x.
2i
Query type 2 asks you to determine the number of anagrams of Li in list L.
Definitions:
Anagram: Two arrays are anagrams if one can be formed by rearranging the elements of the other. Note that, in this problem, we consider an array to be an anagram of itself.
Input
The first line of the input file will contain a positive integer N(1≤N≤105) which denotes the number of elements in list L.
Each of the next N lines will start with a positive integer M denoting the number of elements of Li. Following by a space there will be M space separated positive integers. Note that, (1≤Lij≤104).
Then, you will be given a positive integer Q(1≤Q≤6×105) in a new line.
After that you will be given the queries in the next Q lines as described in the statement.
1ilrxy
Here, (1≤i≤N), (1≤l≤r≤∣Li∣), (1≤x,y≤104)
2i
Here, (1≤i≤N)
Note that, (1≤∑i=1N∣Li∣≤105) and there will be at least one query of type 2.
Output
For each query of type 2, print the answer in a new line.