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.math.*;
import java.io.*; 
 public class A{
 
static FastReader scan=new FastReader();
 public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
  static LinkedList<Integer>edges[];
 // static LinkedList<Pair>edges[];
  static boolean stdin = true;
    static String filein = "input";
    static String fileout = "output";
static int dx[] = { -1, 0, 1, 0 };
static int dy[] = { 0, 1, 0, -1 };
int dx_8[]={1,1,1,0,0,-1,-1,-1};
int dy_8[]={-1,0,1,-1,1,-1,0,1};
static char sts[]={'U','R','D','L'};
static boolean prime[];
static long LCM(long a,long b){
    return (Math.abs(a*b))/gcd(a,b);
   }
    public static int upperBound(long[] array, int length, long value) {
        int low = 0;
        int high = length;
        while (low < high) {
            final int mid = low+(high-low) / 2;
            if ( array[mid]>value) {
                high = mid ;
            } else {
                low = mid+1;
            }
        }
        return low;
    }
   static long gcd(long a, long b) {
    if(a!=0&&b!=0)
        while((a%=b)!=0&&(b%=a)!=0);
    return a^b;
}
static int countSetBits(int n) 
    { 
        int count = 0; 
        while (n > 0) { 
            if((n&1)!=1)
                count++;
            //count += n & 1; 
            n >>= 1; 
        } 
        return count; 
    } 
 static void sieve(long n) 
    { 
        
        prime = new boolean[(int)n+1]; 
        for(int i=0;i<n;i++) 
            prime[i] = true; 
          
        for(int p = 2; p*p <=n; p++) 
        { 
           
            if(prime[p] == true) 
            { 
                
                for(int i = p*p; i <= n; i += p) 
                    prime[i] = false; 
            } 
        } 
    }  
  
 
 
           static boolean isprime(long x)
           {
            for(long i=2;i*i<=x;i++)
                if(x%i==0)
                    return false;
                return true;
           }
           static int perm=0,FOR=0;
           
     
 
static boolean flag=false;
static int len=100000000;
 
static ArrayList<Pair>inters=new ArrayList<Pair>();
 
  
static class comp1 implements  Comparator<Pair>{  
public int compare(Pair o1,Pair o2){
return  Integer.compare((int)o2.x,(int)o1.x);
}
  }
  public static class comp2 implements Comparator<Pair>{  
public int compare(Pair o1,Pair o2){
return Integer.compare((int)o2.x,(int)o1.x); 
}
  }
  static StringBuilder a,b;
 
    static boolean isPowerOfTwo(int n)
{
    if(n==0)
    return false;
 
return (int)(Math.ceil((Math.log(n) / Math.log(2)))) == 
       (int)(Math.floor(((Math.log(n) / Math.log(2)))));
}
static ArrayList<Integer>v;
static ArrayList<Integer>pows;
static void block(long x) 
{ 
   v = new ArrayList<Integer>(); 
      
    pows=new ArrayList<Integer>();
   
    while (x > 0)  
    { 
        v.add((int)x % 2); 
        x = x / 2; 
    } 
  
    // Displaying the output when 
    // the bit is '1' in binary 
    // equivalent of number. 
    for (int i = 0; i < v.size(); i++)  
    { 
        if (v.get(i)==1)  
        { 
      pows.add(i); 
        } 
    } 
 
} 
 
 
   static long ceil(long a,long b)
   {
    if(a%b==0)
        return a/b;
    return a/b+1;
   }
   static int n,m;
   static int arr[];
   static long ans=0;
   static boolean vis[]=new boolean[21];
   static int c[]=new int[21];
   static ArrayList<Integer>comps[];
static   int idx=0;
   static void add(int x)
   {
    vis[x]=true;
    comps[idx].add(x);
    for(int v:edges[x])
        if(!vis[v])
            add(v);
   }
static int k;
static boolean can=false;
 static void dfs(int x,int y,int res)
 {
    if(x==n&&y==m)
    {
  //     out.println(res);
        if(res==k){
            can=true;
            return;
        }
        return;
    }
    if(x>n||y>m){
        //System.out.println("FUCK");
        return;
    }
   // out.println(x);
    dfs(x+1,y,res+y);
   // out.println(x);
    dfs(x,y+1,res+x);

    
    
 }
public static void main(String[] args)  throws Exception 
{
//SUCK IT UP AND DO IT ALRIGHT
//scan=new FastReader("hps.in");
//out = new PrintWriter("hps.out");
   //System.out.println( 1005899102^431072812);
    //int elem[]={1,2,3,4,5};
//System.out.println("avjsmlfpb".compareTo("avjsmbpfl"));
int tt=1;

/*for(int i=0;i<=100;i++)
    if(prime[i])
        arr.add(i);
    System.out.println(arr.size());*/
   // check(new StringBuilder("05:11"));
   // System.out.println(26010000000000L%150);
 
tt=scan.nextInt();
  //  System.out.println(2^6^4);
    //StringBuilder o=new StringBuilder("GBGBGG");
    //o.insert(2,"L");
 int T=tt;
//System.out.println(gcd(99970002,99980000));
 
outer:while(tt-->0)
{
int a=scan.nextInt(),b=scan.nextInt(),k=scan.nextInt();
Map<Integer,Long>mp1=new HashMap<Integer,Long>();
Map<Integer,Long>mp2=new HashMap<Integer,Long>();
int arr1[]=new int[k];
int arr2[]=new int[k];
for(int i=0;i<k;i++)
{
    int x=scan.nextInt();
    arr1[i]=x;
    if(mp1.containsKey(x))
        mp1.put(x,mp1.get(x)+1);
    else mp1.put(x,1L);
}
for(int i=0;i<k;i++)
{
    int x=scan.nextInt();
    arr2[i]=x;
    if(mp2.containsKey(x))
        mp2.put(x,mp2.get(x)+1);
    else mp2.put(x,1L);
}
long k2=(long)k;
long res=0;
for(int i=0;i<k;i++)
{
    res+=k2-(mp1.get(arr1[i])+mp2.get(arr2[i])-1);
    k2--;
    mp1.put(arr1[i],mp1.get(arr1[i])-1);
    mp2.put(arr2[i],mp2.get(arr2[i])-1);
}
out.println(res);
}


out.close();
 
//SEE UP 
 
}
static class special implements Comparable<special>{
    int x,y;
    String s;
    special(int x,String s,int y)
    {
        this.x=x;
        this.s=s;
        this.y=y;
    }
 
 @Override
        public boolean equals(Object o){
            if (o == this) return true;
            if (o.getClass() != getClass()) return false;
            special t = (special)o;
            return t.x == x && t.y == y&&t.s.equals(s);
        }
 
public int compareTo(special o)
{
    return Integer.compare(x,o.x);
}
}
static long binexp(long a,long n)
{
    if(n==0)
        return 1;
    long res=binexp(a,n/2);
    if(n%2==1)
        return res*res*a;
    else 
        return res*res;
}
 
static long powMod(long base, long exp, long mod) {
       if (base == 0 || base == 1) return base;
       if (exp == 0) return 1;
       if (exp == 1) return (base % mod+mod)%mod;
       long R = (powMod(base, exp/2, mod) % mod+mod)%mod;
       R *= R;
       R %= mod;
       if ((exp & 1) == 1) {
           return (base * R % mod+mod)%mod;
       }
       else return (R %mod+mod)%mod;
   }
static double dis(double x1,double y1,double x2,double y2)
{
    return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
static long mod(long x,long y)
    {
        if(x<0)
            x=x+(-x/y+1)*y;
        return x%y;
    }
 public static  long pow(long b, long e) {
            long r = 1;
            while (e > 0) {
                if (e % 2 == 1) r = r * b ;
                b = b * b;
                e >>= 1;
            }
            return r;
        }
private static void sort(int[] arr) {
        List<Integer> list = new ArrayList<>();
        for (int object : arr) list.add(object);
        Collections.sort(list);
    //Collections.reverse(list);
        for (int i = 0; i < list.size(); ++i) arr[i] = list.get(i);
    }
private static void sort2(int[] arr) {
        List<Integer> list = new ArrayList<>();
        for (int object : arr) list.add(object);
        Collections.sort(list);
    Collections.reverse(list);
        for (int i = 0; i < list.size(); ++i) arr[i] = list.get(i);
    }
 public static class FastReader {
        BufferedReader br;
        StringTokenizer root;
        
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        FastReader(String filename)throws Exception
        {
 
            br=new BufferedReader(new FileReader(filename));
        }
 
        boolean hasNext(){
            String line;
            while(root.hasMoreTokens())
                return true;
            return false;
        }
 
        String next() {
            while (root == null || !root.hasMoreTokens()) {
                try {
                    root = new StringTokenizer(br.readLine());
                } catch (Exception addd) {
                    addd.printStackTrace();
                }
            }
            return root.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (Exception addd) {
                addd.printStackTrace();
            }
            return str;
        }
         public int[] nextIntArray(int arraySize) {
            int array[] = new int[arraySize];
 
            for (int i = 0; i < arraySize; i++) {
                array[i] = nextInt();
            }
 
            return array;
        }
}
 static class Pair implements Comparable<Pair>{
        public long x, y;
        public Pair(long x1, long y1) {
            x=x1;
            y=y1;
        }
        @Override
        public int hashCode() {
            return (int)(x + 31 * y);
        }
        public String toString() {
            return x + " " + y;
        }
        @Override
        public boolean equals(Object o){
            if (o == this) return true;
            if (o.getClass() != getClass()) return false;
            Pair t = (Pair)o;
            return t.x == x && t.y == y;
        }
public int compareTo(Pair o)
{
    return (int)(o.x-x);
 
    }
 
}
 static class tuple{
        int x,y,z;
        tuple(int a,int b,int c){
            x=a;
            y=b;
            z=c;
        }
    }
    static class Edge{
        int d,w;
        Edge(int d,int w)
        {
            this.d=d;
            this.w=w;
        }
    }
}
 
 