At the school where Vasya is studying, preparations are underway for the graduation ceremony. One of the planned performances is a ball, which will be attended by pairs of boys and girls.

Each class must present two couples to the ball. In Vasya's class, a boys and b girls wish to participate. But not all boys and not all girls are ready to dance in pairs.

Formally, you know k possible one-boy-one-girl pairs. You need to choose two of these pairs so that no person is in more than one pair.

For example, if a=3, b=4, k=4 and the couples (1, 2), (1, 3), (2, 2), (3, 4) are ready to dance together (in each pair, the boy's number comes first, then the girl's number), then the following combinations of two pairs are possible (not all possible options are listed below): 

  * (1, 3) and (2, 2); 
  * (3, 4) and (1, 3); 



But the following combinations are not possible: 

  * (1, 3) and (1, 2) — the first boy enters two pairs; 
  * (1, 2) and (2, 2) — the second girl enters two pairs; 



Find the number of ways to select two pairs that match the condition above. Two ways are considered different if they consist of different pairs.

Input

The first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.

The first line of each test case contains three integers a, b and k (1 ≤ a, b, k ≤ 2 ⋅ 10^5) — the number of boys and girls in the class and the number of couples ready to dance together.

The second line of each test case contains k integers a_1, a_2, … a_k. (1 ≤ a_i ≤ a), where a_i is the number of the boy in the pair with the number i.

The third line of each test case contains k integers b_1, b_2, … b_k. (1 ≤ b_i ≤ b), where b_i is the number of the girl in the pair with the number i.

It is guaranteed that the sums of a, b, and k over all test cases do not exceed 2 ⋅ 10^5.

It is guaranteed that each pair is specified at most once in one test case.

Output

For each test case, on a separate line print one integer — the number of ways to choose two pairs that match the condition above.

Example

Input


3
3 4 4
1 1 2 3
2 3 2 4
1 1 1
1
1
2 2 4
1 1 2 2
1 2 1 2


Output


4
0
2

Note

In the first test case, the following combinations of pairs fit: 

  * (1, 2) and (3, 4); 
  * (1, 3) and (2, 2); 
  * (1, 3) and (3, 4); 
  * (2, 2) and (3, 4). 



There is only one pair in the second test case.

In the third test case, the following combinations of pairs fit: 

  * (1, 1) and (2, 2); 
  * (1, 2) and (2, 1). 
//Avoid division by decimal digits :). Always try to multiply with whole numbers or fractions instead.
//if getting wrong answer then use long/double instead of int/float
//e + e = o; o + o = e; e + o = o;
//see stuff in a jugaad way... if you are being complicated you are doing it wrong baby girl :)
//If a=b+1 and b is even, then a∧b=1
//
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        FastReader reader = new FastReader();
        int test = reader.nextInt();
        for (int o = 0; o < test; o++){
         int a = reader.nextInt();
         int b = reader.nextInt();
         int k = reader.nextInt();
         int[] arrBoys = new int[k];
         for (int i = 0; i < k ; i++){arrBoys[i] = reader.nextInt();}
         int[] arrGirls = new int[k];
         for (int i = 0; i < k; i++){arrGirls[i] = reader.nextInt();}
         HashSet<Integer>[] set1 = new HashSet[a + 1];
         for (int i = 0; i <= a; i++){set1[i]  = new HashSet<>();}
         long[] set2 = new long[b + 1];
         for (int i = 0; i < k; i++) {
             set1[arrBoys[i]].add(arrGirls[i]);
             set2[arrGirls[i]] += 1;
         }
          //  System.out.println(Arrays.toString(set2));
         long u = k*(k - 1)/2;
         long ans = 0;
         for (int i = 1; i <= a; i++){
             HashSet<Integer> setty = set1[i];

             for (int aj: setty){
                 ans += (k - (setty.size() - 1 + set2[aj] - 1 + 1));
             }
         }
         ans = ans/2;
            System.out.println(ans);
        }
    }
}
class Noddy {
    int att; int h;
    public Noddy(int att, int h){
        this.att = att; this.h = h;
    }
}
class FastReader
{
    BufferedReader br;
    StringTokenizer st;

    public FastReader()
    {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}

/** Class for buffered reading int and double values */
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}
