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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Codeforces {

    private static final Scanner sc = new Scanner(System.in);
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final long MOD = (long) (1e9 + 7);

    public static int[] LPS(String p){
        int[] lps = new int[p.length()];

        int i=1;
        int j=0;
        while (i < p.length()){
            if (p.charAt(i) == p.charAt(j)){
                lps[i] = j+1;
                i++;
                j++;
            }
            else{
                if (j == 0){
                    lps[i] = 0;
                    i++;
                }
                else{
                    j = lps[j-1];
                }
            }
        }
        return lps;
    }

    public static void KMP(String text,String pattern){
        int[] lps = LPS(pattern);
        int i = 0;
        int j = 0;
        ArrayList<Integer> matches = new ArrayList<>();
        while (i < text.length()){
            if (text.charAt(i) == pattern.charAt(j)){
                i++;
                j++;
            }
            else{
                if (j != 0){
                    j = lps[j-1];
                }
                else {
                    i++;
                }
            }
            if (j == pattern.length()) {
                matches.add(i - j);
                j = lps[j-1];
            }
        }
        for (int x : matches){
            System.out.println("Match at : " + x);
        }
    }

    private static class SegmentTree{
        private long[] st;
        private int size;
        private int n;
        private long[] a;
        SegmentTree(long[] a,int n){
            this.size = 4*n;
            this.n = n;
            this.a = a;
            st = new long[size];
            //Arrays.fill(st,Integer.MIN_VALUE);
            buildSegmentTree(0,0,n-1);
            //printSegmentTree();
        }
        public long buildSegmentTree(int index,int l,int r){
            if (l == r){
                st[index] = a[l];
                return a[l];
            }
            int mid = (r+l) >> 1;
            return st[index] = buildSegmentTree(2*index+1,l,mid) + buildSegmentTree(2*index+2,mid+1,r);
        }
        public void printSegmentTree(){
            for (long x : st){
                System.out.print(x + " ");
            }
            System.out.println();
        }
        public long query(int ql,int qr){
            return getQuery(0,0,n-1,ql-1,qr-1);
        }
        private long getQuery(int index,int sl,int sr,int ql,int qr){
            //System.out.println("#" + index);
            if (qr < sl || ql > sr)
                return 0;
            if (ql <= sl && qr >= sr)
                return st[index];
            int mid = (sr + sl) >> 1;
            return getQuery(2*index+1,sl,mid,ql,qr) + getQuery(2*index+2,mid+1,sr,ql,qr);
        }
        public void update(int i,long newVal){
            //long diff = newVal - a[i];
            a[i] = newVal;
            updateSegmentTree(0,i,0,n-1,newVal);
        }
        private void updateSegmentTree(int index,int i,int sl,int sr,long diff){
            if (sl == sr){
                st[index] = diff;
                return;
            }
            int mid = (sl + sr) >> 1;
            if (i <= mid)
                updateSegmentTree(2*index+1,i,sl,mid,diff);
            else
                updateSegmentTree(2*index+2,i,mid+1,sr,diff);
            st[index] = st[2*index+1] + st[2*index+2];
        }
    }

    public static class Pair<T1,T2>{
        T1 first;
        T2 second;
        Pair(T1 a,T2 b){
            this.first = a;
            this.second = b;
        }

        @Override
        public String toString() {
            return "[" + first + ", " + second + "]";
        }
    }

    public static long GCD(long a,long b){
        if (b == 0)
            return a;
        return GCD(b,a%b);
    }

    static int highestPowerOf2(int n) {
        int p = (int)(Math.log(n) /
                Math.log(2));
        return (int)Math.pow(2, p);
    }

    public static int binSearch(long[] a,long x){
        int l = 0;
        int r = a.length - 1;
        while (l <= r){
            int mid = l + (r-l)/2;
            if (a[mid]==x)
                return 1;
            else if (a[mid] < x)
                l = mid+1;
            else
                r = mid-1;
        }
        return -1;
    }

    public static int upperBound(long[] arr,long key){
        int start=0;int end=arr.length-1;
        int idx=-1;
        int mid;
        while(start<=end){
            int i=(start+end)/2;
            if(arr[i]<key){
                start=i+1;
            }
            else if(arr[i]>key){
                end=i-1;
            }
            else{
                idx=i;
                start=i+1;
            }
        }

        return idx;    }

    public static int lowerBound(long[] arr,long key){
        int start=0;int end=arr.length-1;
        int idx=-1;
        int mid;
        while(start<=end){
            int i=(start+end)/2;
            if(arr[i]<key){
                start=i+1;
            }
            else if(arr[i]>key){
                end=i-1;
            }
            else{
                idx=i;
                end=i-1;
            }
        }
        return idx;
    }

    public static int searchInsert(long[] nums, long target) {
        int s=0,e=nums.length-1;
        int mid;
        if(target<nums[0]){
            return 0;
        }
        while(s<=e){
            mid=(s+e)/2;
            if(nums[mid]>target){
                e=mid-1;
            }
            else if(nums[mid]==target){
                return mid;
            }
            else{
                s=mid+1;
            }
        }
        return s;
    }

    static boolean isPrime(long n) {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;

        if (n % 2 == 0 || n % 3 == 0)
            return false;

        for (long i = 5; i <= Math.sqrt(n) + 1; i += 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;

        return true;
    }

    public static long fastExpo(long a,long n,long mod){
        if (n == 0)
            return 1;
        else{
            long x = fastExpo(a,n/2,mod);
            if ((n&1) == 1){
                return (((a*x)%mod)*x)%mod;
            }
            else{
                return (((x%mod)*(x%mod))%mod)%mod;
            }
        }
    }

    public static long modInverse(long n,long p){
        return fastExpo(n,p-2,p);
    }

    public static long nCr(int n,int r,long[] fact,long mod){
        long val =  (((fact[n] * modInverse(fact[r],mod))%mod)*modInverse(fact[n-r],mod))%mod;
        return val;
    }

    public static void factorial(long[] fact,int n,long mod){
        for (int i=1;i<=n;i++){
            fact[i] = (fact[i-1] * i)%mod;
        }
    }

    public static int log2(long val){
        return (int) Math.floor(Math.log(val)/Math.log(2));
    }

    public static boolean isSubSequence(String s,String t){
        int i = 0;
        int j = 0;
        while (i < s.length() && j < t.length()){
            if (s.charAt(i) == t.charAt(j))
                j++;
            i++;
        }
        return j == t.length();
    }

    public static ArrayList<Long> getAllFactors(long x){
        ArrayList<Long> ans = new ArrayList<>();
        for (long i = 1; i <= Math.sqrt(x); i++) {
            if (x%i == 0){
                if (x/i == i){
                    ans.add(i);
                }
                else{
                    ans.add(i);
                    ans.add(x/i);
                }
            }
        }
        return ans;
    }

    public static boolean isPerfectSquare(long x){
        double val = Math.sqrt(x);
        return val*val == (double)x;
    }

    public static ArrayList<Integer> buildSieve(int n){
        boolean[] sieve = new boolean[n+1];
        Arrays.fill(sieve,true);
        sieve[0] = sieve[1] = false;
        for (int i = 2; i <= Math.sqrt(n+1) ; i++) {
            if (sieve[i]){
                for (int j = 2*i; j < n+1; j += i) {
                    sieve[j] = false;
                }
            }
        }
        ArrayList<Integer> primes = new ArrayList<>();
        for (int i = 0; i < sieve.length; i++) {
            if (sieve[i]){
                primes.add(i);
            }
        }
        return primes;
    }

    public static int getLowBit(int n){
        int x = 0;
        while ((n&1) != 1){
            x++;
            n >>= 1;
        }
        return 1 << x;
    }

    static boolean isDiophantinePossible(int a, int b, int c) {
        return (c % GCD(a, b) == 0);
    }

    public static void solve() throws IOException {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        Map<Integer,Integer> mpB = new HashMap<>();
        Map<Integer,Integer> mpG = new HashMap<>();
        long ans = 0;
        int[] A = new int[k];
        int[] B = new int[k];

        for (int i = 0; i < k; i++) {
            A[i] = sc.nextInt();
        }
        for (int i = 0; i < k; i++) {
            B[i] = sc.nextInt();
        }
        for (int i = 0; i < k; i++) {
            int x = A[i];
            int y = B[i];
            int valx = mpB.getOrDefault(x,0);
            int valy = mpG.getOrDefault(y,0);
            ans += i - (valx + valy);
            mpB.put(x,mpB.getOrDefault(x,0) + 1);
            mpG.put(y,mpG.getOrDefault(y,0) + 1);
        }
        System.out.println(ans);
    }
    public static void main(String[] args) throws IOException {
        int t;
        t = sc.nextInt();
//        t = 1;
        while (t-- > 0){
            solve();
        }
        System.gc();
    }
}