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.*;

public class E {

	public static void main(String args[]) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		int t = sc.nextInt();
		while (t-- > 0) {
			int b = sc.nextInt();
			int g = sc.nextInt();
			int k = sc.nextInt();
			pair a[] = new pair[k];
			int tig[] = new int[g];
			int tib[] = new int[b];
			int w[]=sc.intArr(k);
			int e[]=sc.intArr(k);
			for (int i = 0; i < k; i++) {
				int x = w[i]-1;
				int y = e[i]-1;
				tib[x]++;
				tig[y]++;
				a[i] = new pair(x, y);
			}
			Arrays.sort(a);
			int temp[] = new int[g];
			int l = 0;
			int last = -1;
			long ans = 0;
			int c=0;
//			System.out.println(Arrays.toString(tig));
			for (int i = 0; i < a.length; i++) {

				if (last != a[i].x) {
					for (; l < a.length; l++) {
						last = a[i].x;
						if (a[l].x != last) {
							break;
						}
						temp[a[l].y]++;
					}
					c+=tib[a[i].x];
				}
//				System.out.println(Arrays.toString(temp)+" "+(tig[a[i].y] - temp[a[i].y]));
				ans += (k-(tig[a[i].y] - temp[a[i].y])-c);
			}
			pw.println(ans);

		}
		pw.flush();
	}

	///////////////////////////////////////////////////////////////////////////////////////////

	static class tri {
		int x, y, z;

		public tri(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

	}

	static class pair implements Comparable<pair> {
		int x, y;
		boolean w, l;
		PriorityQueue<Long> pq;

		public pair(boolean a, boolean b) {
			w = a;
			l = b;
		}

		pair(int s, int d) {
			x = s;
			y = d;
		}

		@Override
		public int compareTo(pair p) {
			return x - p.x;
		}

		@Override
		public String toString() {
			return x + " " + y;

		}

	}

	static long mod(long ans, int mod) {
		return (ans % mod + mod) % mod;
	}

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

	static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}

	public static int log(int n, int base) {
		int ans = 0;
		while (n + 1 > base) {
			ans++;
			n /= base;
		}
		return ans;
	}

	static long pow(long b, long e) {
		long ans = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				ans = ((ans * 1l * b));
			e >>= 1;
			{

			}
			b = ((b * 1l * b));
		}
		return ans;
	}

	static long powmod(long r, long e, int mod) {
		long ans = 1;
		r %= mod;
		while (e > 0) {
			if ((e & 1) == 1)
				ans = (int) ((ans * 1l * r) % mod);
			e >>= 1;
			r = (int) ((r * 1l * r) % mod);
		}
		return ans;
	}

	static int ceil(int a, int b) {
		int ans = a / b;
		return a % b == 0 ? ans : ans + 1;
	}

	static long ceil(long a, long b) {
		long ans = a / b;
		return a % b == 0 ? ans : ans + 1;
	}

	static HashMap<Integer, Integer> compress(int a[]) {
		TreeSet<Integer> ts = new TreeSet<>();
		HashMap<Integer, Integer> hm = new HashMap<>();
		for (int x : a)
			ts.add(x);
		for (int x : ts) {
			hm.put(x, hm.size() + 1);
		}
		return hm;
	}

	// Returns nCr % p
	static int C[];

	static int nCrModp(int n, int r, int p) {
		if (r > n - r)
			r = n - r;
		if (C[r] != 0)
			return C[r];
		// The array C is going to store last
		// row of pascal triangle at the end.
		// And last entry of last row is nCr

		C[0] = 1; // Top row of Pascal Triangle

		// One by constructs remaining rows of Pascal
		// Triangle from top to bottom
		for (int i = 1; i <= n; i++) {

			// Fill entries of current row using previous
			// row values
			for (int j = Math.min(i, r); j > 0; j--)

				// nCj = (n-1)Cj + (n-1)C(j-1);
				C[j] = (C[j] + C[j - 1]) % p;
		}
		return C[r];
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public int[] intArr(int n) throws IOException {
			int a[] = new int[n];
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
			return a;
		}

		public long[] longArr(int n) throws IOException {
			long a[] = new long[n];
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
			return a;
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

	public static void shuffle(int[] times2) {
		int n = times2.length;
		for (int i = 0; i < n; i++) {
			int r = i + (int) (Math.random() * (n - i));
			int tmp = times2[i];
			times2[i] = times2[r];
			times2[r] = tmp;
		}
	}

}