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.*;
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
import static java.util.Collections.*;
import static java.util.Arrays.*;
public class C<Array, Target> {
    public static int swap(int... args) {
        return args[0];
    }
    //  static Scanner sc = new Scanner(System.in);
    static FastReader sc = new FastReader();
    public static void main(String[] args) throws IOException {
        do {
            startTime = currentTimeMillis();
            //setOut(new PrintStream("output"));
            //setIn(new FileInputStream("input"));
            int T = sc.nextInt();while (T-- != 0)
            {
                solve();

            }
            endTime = currentTimeMillis();
            long duration = endTime - startTime;
            //out.println(duration);
            if (false) {
                out.println(max(3, 2));
                Integer[] ARRAY = new Integer[2];
                ArrayList<Integer> LIST = new ArrayList<>();
                LIST.add(2);
                // sort(LIST, reverseOrder());
                LIST.sort(reverseOrder());
                sort(ARRAY, reverseOrder());
                out.println(LIST + " " + Arrays.toString(ARRAY));
            }
        } while (LOCAL);
    }
    public static boolean isPal(String s)
    {
        StringBuilder stringBuilder = new StringBuilder(s);
        return s.equals(stringBuilder.reverse().toString());
    }
    public static void solve() throws IOException {
        C main = new C<>();
/////////////////////////////////////////////////////////////////////
        int a=sc.nextInt(),b=sc.nextInt(),k=sc.nextInt();
        int [] aa = new int[k];
        int [] bb = new int[k];
        int []  freqA = new int[a+1];
        int []  freqB = new int[b+1];
        dbg(k);
        for (int i = 0; i < k; i++) {
            aa[i]=sc.nextInt();
            freqA[aa[i]]++;
        } 
        for (int i = 0; i < k; i++) {
            bb[i]=sc.nextInt();
            freqB[bb[i]]++;
        }
        long cn=0;
        for (int i = 0; i < k; i++) {
             cn+= k-i-1L;
            cn-=(freqA[aa[i]]+freqB[bb[i]]-2L);
            freqA[aa[i]]--; freqB[bb[i]]--;
        }
        out.println(cn);
///////////////////////////////////////////////////////////////////////
    }
    public static final boolean LOCAL = System.getProperty("ONLINE_JUDGE")==null;
    // public static final boolean LOCAL = System.getProperty("LOCAL")!=null;
    public static final String ANSI_RED = "\u001B[31m";
    public static final String ANSI_RESET = "\u001B[0m";
    static long startTime;
    static long endTime;
    static boolean[] prime;
    static final int M = (int) 1e9 + 7;
    static final long MM = (long) M * M;
    static final int MAX = Integer.MAX_VALUE;
    static final int MIN = Integer.MIN_VALUE;
    static final int SIZE = (int) 1e9 * 2;
    static 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;
        }
    }
    static class Pair implements Comparable<Pair> {
        private int key;
        private int value;
        public Pair(int key, int value) {
            this.key = key;
            this.value = value;
        }
        public int second() {
            return value;
        }
        @Override
        public int compareTo(Pair o) {
            return -Integer.compare(key, o.key);
        }
        @Override
        public String toString() {
            return "Pair{" + "x=" + key + ", y=" + value + '}';
        }
    }
    int count(Array[] array, Target target){
        int cn=0;
        for (Array value : array) {
            if (value.equals(target)) cn++;
        }
        return cn;
    }
    static int count (String string , char target){
        int cn=0;
        for (int i = 0; i < string.length(); i++) {
            if(string.charAt(i)==target)cn++;
        }
        return cn;
    }
    void revArray(Array [] arr) {
        int n = arr.length;
        for (int i = 0; i < n / 2; i++) {
            Array temp = arr[i];
            arr[i] = arr[n - i - 1];
            arr[n - i - 1] = temp;
        }
    }
    void printArray(Array [] arr) {
        int n = arr.length;
        for (Array array : arr)out.print(array + " ");
        out.println();
    }
    static void yes() {out.println("YES");}
    static void no() {out.println("NO");}
    public static int lowerBound(Integer[] array, int length, int value) {
        int low = -1;
        int hi = length;
        while (low + 1 < hi) {
            int mid = (low + hi) / 2;
            if (array[mid] <= value) {
                low = mid;
            } else {
                hi = mid;
            }
        }
        return low;
    }
    public static int upperBound(Integer[] array, int length, int value) {
        int low = -1;
        int hi = length;
        while (low + 1 < hi) {
            int mid = (low + hi) >> 1;
            if (array[mid] >= value) {
                hi = mid;
            } else low = mid;
        }
        return hi;
    }
    public static int binarySearch(Integer[] arr, int length, int value) {
        int low = 0;
        int hi = length - 1;
        int ans = -1;
        while (low <= hi) {
            int mid = (low + hi) >> 1;
            if (arr[mid] > value) {
                hi = mid - 1;
            } else if (arr[mid] < value) {
                low = mid + 1;
            } else {
                ans = mid;
                break;
            }
        }
        return ans;
    }
    public static int gcd(int a, int b) {
        return b==0?a:gcd(b, a % b);
    }
    public static long lcm(int a, int b) {
        return a / gcd(a, b) * b;
    }
    public static int countDivs(int n) {
        int cn = 0;
        int sqr = (int) Math.sqrt(n);
        for (int i = 1; i <= sqr; ++i) {
            if (n % i == 0) {
                ++cn;
            }
        }
        cn *= 2;
        if (sqr * sqr == n) cn--;
        return cn;
    }

    static void prime(int x) {
        //sieve algorithm. nlog(log(n)).
        prime = new boolean[(x + 1)];
        Arrays.fill(prime, true);
        prime[0] = prime[1] = false;
        for (int i = 2; i * i <= x; i++)
            if (prime[i])
                for (int j = i * i; j <= x; j += i)
                    prime[j] = false;
    }
    static boolean isEven(long x) {
        return x % 2 == 0;
    }
    static boolean isPrime(long x) {
        boolean flag = true;
        int sqr = (int) Math.sqrt(x);
        if (x < 2) return false;
        for (int i = 2; i <= sqr; i++) {
            if (x % i == 0) {
                flag = false;
                break;
            }
        }
        return flag;
    }

    static long factorial(long x) {
        long total = 1;
        for (int i = 2; i <= x; i++)
            total = (total * i) % M;
        return total;
    }

    static long power(long x, long n) {
        if (n == 0) {
            return 1;
        }
        long pow = power(x, n / 2L);
        if ((n & 1) == 1) {
            return (x * (pow) * (pow));
        }
        return (pow * pow);
    }
    private static <T> String ts(T t) {
        if(t==null) {
            return "null";
        }
        try {
            return ts((Iterable) t);
        }catch(ClassCastException e) {
            if(t instanceof int[]) {
                String s = Arrays.toString((int[]) t);
                return "{"+s.substring(1, s.length()-1)+"}";
            }else if(t instanceof long[]) {
                String s = Arrays.toString((long[]) t);
                return "{"+s.substring(1, s.length()-1)+"}";
            }else if(t instanceof char[]) {
                String s = Arrays.toString((char[]) t);
                return "{"+s.substring(1, s.length()-1)+"}";
            }else if(t instanceof double[]) {
                String s = Arrays.toString((double[]) t);
                return "{"+s.substring(1, s.length()-1)+"}";
            }else if(t instanceof boolean[]) {
                String s = Arrays.toString((boolean[]) t);
                return "{"+s.substring(1, s.length()-1)+"}";
            }
            try {
                return ts((Object[]) t);
            }catch(ClassCastException e1) {
                return t.toString();
            }
        }
    }
    private static <T> String ts(T[] arr) {
        StringBuilder ret = new StringBuilder();
        ret.append("{");
        boolean first = true;
        for(T t: arr) {
            if(!first) {
                ret.append(", ");
            }
            first = false;
            ret.append(ts(t));
        }
        ret.append("}");
        return ret.toString();
    }
    private static <T> String ts(Iterable<T> iter) {
        StringBuilder ret = new StringBuilder();
        ret.append("{");
        boolean first = true;
        for(T t: iter) {
            if(!first) {
                ret.append(", ");
            }
            first = false;
            ret.append(ts(t));
        }
        ret.append("}");
        return ret.toString();
    }
    public static void dbg(Object... o) {
        if(LOCAL) {
            System.err.print("Line #"+Thread.currentThread().getStackTrace()[2].getLineNumber()+": [");
            for(int i = 0; i<o.length; i++) {
                if(i!=0) {
                    System.err.print(", ");
                }
                System.err.print(ts(o[i]));
            }
            System.err.println("]");
        }
    }

}
