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). 
import java.util.*;
import java.io.*;  
import java.util.Map.Entry;
 
public class Solution{
    public static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
        public String next() {
			while (st == null || !st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) {
				a[i]=nextInt();
			}
			return a;
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
    }
    public static class unionFind{
        public static int[] p;
        public static int find(int u){
            while(p[u]!=u){
                u=p[u];
            }
            return u;
        }
        public static void union(int u,int v){
            int x=find(u);
            int y=find(v);
            p[x]=y;
        }
    }
    static class Point{ 
        double x; 
        double y; 
        public Point(double x, double y){ 
            this.x = x; 
            this.y = y; 
        } 
    }
    public static class SegmentTree{ 
        int st1[];
        int st2[];
        SegmentTree(int arr[], int n){ 
            int x = (int) (Math.ceil(Math.log(n) / Math.log(2))); 
            int max_size = 2 * (int) Math.pow(2, x) - 1;
            st1 = new int[max_size];
            st2 = new int[max_size];
            constructSTUtil1(arr, 0, n - 1, 0);
            constructSTUtil2(arr, 0, n - 1, 0); 
        }
        int getMid(int s, int e) { 
            return s + (e - s) / 2; 
        }
        int getSumUtil(int ss, int se, int qs, int qe, int si){
            if (qs <= ss && qe >= se){
                return st1[si]; 
            }
            if (se < qs || ss > qe) {
                return 0; 
            }
            int mid = getMid(ss, se); 
            return getSumUtil(ss, mid, qs, qe, 2 * si + 1) + getSumUtil(mid + 1, se, qs, qe, 2 * si + 2); 
        }
        int getMinUtil(int ss, int se, int qs, int qe, int si){
            if (qs <= ss && qe >= se){
                return st2[si]; 
            }
            if (se < qs || ss > qe) {
                return Integer.MAX_VALUE; 
            }
            int mid = getMid(ss, se); 
            return Math.min(getMinUtil(ss, mid, qs, qe, 2 * si + 1),getMinUtil(mid + 1, se, qs, qe, 2 * si + 2)); 
        }
        int getMaxUtil(int ss, int se, int qs, int qe, int si){
            if (qs <= ss && qe >= se){
                return st1[si]; 
            }
            if (se < qs || ss > qe) {
                return Integer.MIN_VALUE; 
            }
            int mid = getMid(ss, se); 
            return Math.max(getMaxUtil(ss, mid, qs, qe, 2 * si + 1),getMaxUtil(mid + 1, se, qs, qe, 2 * si + 2)); 
        }
        void updateValueUtil(int ss, int se, int i, int diff, int si){ 
            if (i < ss || i > se){
                return; 
            }
            st1[si] = st1[si] + diff; 
            if (se != ss) { 
                int mid = getMid(ss, se); 
                updateValueUtil(ss, mid, i, diff, 2 * si + 1); 
                updateValueUtil(mid + 1, se, i, diff, 2 * si + 2); 
            } 
        }
        void updateValue(int arr[], int n, int i, int new_val){
            if (i < 0 || i > n - 1) {
                return; 
            }
            int diff = new_val - arr[i]; 
            arr[i] = new_val; 
            updateValueUtil(0, n - 1, i, diff, 0); 
        }
        int getSum(int n, int qs, int qe){
            if (qs < 0 || qe > n - 1 || qs > qe) {
                return -1; 
            } 
            return getSumUtil(0, n - 1, qs, qe, 0); 
        }
        int getMin(int n, int qs, int qe){
            if (qs < 0 || qe > n - 1 || qs > qe) {
                return Integer.MIN_VALUE; 
            } 
            return getMinUtil(0, n - 1, qs, qe, 0); 
        }
        int getMax(int n, int qs, int qe){
            if (qs < 0 || qe > n - 1 || qs > qe) {
                return Integer.MAX_VALUE; 
            } 
            return getMaxUtil(0, n - 1, qs, qe, 0); 
        }
        int constructSTUtil1(int arr[], int ss, int se, int si){
            if (ss == se) { 
                st1[si] = arr[ss]; 
                return arr[ss]; 
            }
            int mid = getMid(ss, se); 
            st1[si] = Math.max(constructSTUtil1(arr, ss, mid, si * 2 + 1),constructSTUtil1(arr, mid + 1, se, si * 2 + 2)); 
            return st1[si]; 
        }
        int constructSTUtil2(int arr[], int ss, int se, int si){
            if (ss == se) { 
                st2[si] = arr[ss]; 
                return arr[ss]; 
            }
            int mid = getMid(ss, se); 
            st2[si] = Math.min(constructSTUtil2(arr, ss, mid, si * 2 + 1),constructSTUtil2(arr, mid + 1, se, si * 2 + 2)); 
            return st2[si]; 
        } 
    }
    public static double area(Point A, Point B, Point C){ 
        double area = (A.x * (B.y - C.y) + B.x * (C.y - A.y) + C.x * (A.y - B.y)) / (double)2; 
        return Math.abs(area);
    }
    public static void sort(int[] array){
		ArrayList<Integer> copy = new ArrayList<>();
		for(int i:array){
			copy.add(i);
		}
		Collections.sort(copy);
		for(int i=0;i<array.length;i++){
			array[i]=copy.get(i);
		}
    }
    static long[] fact(){
        long[] fac = new long[200001];
        fac[0] = (long)1;
        for (int i = 1; i < (int)fac.length; i++){
            fac[i] = (fac[i - 1] * i) % 1000000007;
        }
        return fac;
    }
    public static long nCr(long n, long r,long p,long[] fac){
        if (n<r) 
              return (long)0;
        if (r == 0)
            return (long)1;
        return (fac[(int)n] * modInverse(fac[(int)r], p)% p * modInverse(fac[(int)(n - r)], p)% p)% p;
    }
    public static long modInverse(long n, long p){
        return power(n, p - 2, p);
    }
    static long power(long x, long y, long p){
        long res = 1;
        x = x % p;
        while (y > 0) {
            if (y % 2 == 1)
                res = (res * x) % p;
            y = y >> 1; // y = y/2
            x = (x * x) % p;
        }
        return res;
    }
    public static int upp(int[] arr,int v){
        int low=0;
        int high=arr.length-1;
        int ans=-1;
        while(low<=high){
            int m=(low+high)/2;
            if(arr[m]<v){
                ans=m;
                low=m+1;
            }else{
                high=m-1;
            }
        }
        return ans;
    }
    public static int low(int[] arr,int v){
        int low=0;
        int high=arr.length-1;
        int ans=-1;
        while(low<=high){
            int m=(low+high)/2;
            if(arr[m]>v){
                ans=m;
                high=m-1;
            }else{
                low=m+1;
            }
        }
        return ans;
    }
    public static class Comp implements Comparator<pair>{
        public int compare(pair a,pair b){
            return a.x-b.x;
        }
    }
    public static int gcd(int a,int b){
        if (b == 0) 
        return a; 
        return gcd(b, a % b);
    }
    public static int lcm(int a,int b){
        int x=Math.max(a,b);
        int y=Math.min(a,b);
        long ans=x;
        while(ans%y!=0){
            ans+=x;
        }
        if(ans>Integer.MAX_VALUE){
            return -1;
        }
        return (int)ans;
    }
    public static class pair{
        int x;
        int y;
        public pair(int a,int b){
            x=a;
            y=b;
        }
    }
    static boolean isPowerOfTwo(long n)
{
    if(n==0)
    return false;
 
return (long)(Math.ceil((Math.log(n) / Math.log(2)))) == 
       (long)(Math.floor(((Math.log(n) / Math.log(2)))));
}
    public static int ans;
    public static void main(String[] args) throws IOException{
        FastScanner fs=new FastScanner();
		int t=1;
		t=fs.nextInt();
		long mod=1000000007;
		long[] fact=fact();
		PrintWriter out=new PrintWriter(System.out);
		while(t-->0){
		    int a=fs.nextInt();
		    int b=fs.nextInt();
		    int k=fs.nextInt();
		    int[] as=fs.readArray(k);
		    int[] bs=fs.readArray(k);
		    HashMap<Integer,Integer> map1=new HashMap<>();
		    HashMap<Integer,Integer> map2=new HashMap<>();
		    for(int i=1;i<=a;i++){
		        map1.put(i,0);
		    }
		    for(int i=1;i<=b;i++){
		        map2.put(i,0);
		    }
		    for(int i=0;i<k;i++){
		        map1.put(as[i],map1.getOrDefault(as[i],0)+1);
		        map2.put(bs[i],map2.getOrDefault(bs[i],0)+1);
		    }
		    long total=((long)(k-1)*(long)k)/(long)2;
		    if(k==1){
		        total=0;
		    }
		  //  System.out.println(total);
		    for(int key:map1.keySet()){
		        if(map1.get(key)>1){
		            int v=map1.get(key);
		            total-=(long)(((long)(v-1)*(long)v)/(long)2);
		        }
		    }
		    for(int key:map2.keySet()){
		        if(map2.get(key)>1){
		            int v=map2.get(key);
		            total-=(long)(((long)(v-1)*(long)v)/(long)2);
		        }
		    }
		    System.out.println(total);
		}
        out.close();
    }
}