Chef and his mother are going travelling. Chef's world consists of $N$ cities (numbered $1$ through $N$) connected by $N-1$ bidirectional roads such that each city can be reached from any other city using roads. For each city, we know its age — the number of years elapsed since the foundation of the city; let's denote the age of city $i$ by $a_i$.
First of all, Chef and his mother have to decide what city they should visit first. Suppose that Chef chooses a city $c_c$ and his mother chooses a (not necessarily different) city $c_m$. The difference of their choices is the number of different bits in the binary representations of $a_{c_c}$ and $a_{c_m}$.
Chef will not argue with his mother if the parity of this difference is not equal to the parity of the length of the shortest path between cities $c_c$ and $c_m$ (the number of roads on the shortest path between them). Find the number of ways to choose the cities $c_c$ and $c_m$ such that Chef avoids quarreling with his mother.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first line of each test case contains a single integer $N$. 
- Each of the following $N-1$ lines contains two space-separated integers $A$ and $B$ denoting a road between cities $A$ and $B$.
- The last line contains $N$ space-separated integers $a_1, a_2, \dots, a_N$.

-----Output-----
For each test case, print a single line containing one integer — the number of valid pairs $c_c, c_m$.

-----Constraints-----
- $1 \le T \le 10$
- $1 \le N \le 10^5$
- $1 \le A, B \le N$
- $0 \le a_i \le 10^9$ for each valid $i$

-----Sample Input-----
1
3
1 2
1 3
1 2 3

-----Sample Output-----
2

-----Explanation-----
Example case 1: The two possible choices are $c_c=2, c_m=3$ (their binary representations differ by one bit, the shortest path has length $2$) and $c_c=1, c_m=2$ (there are two different bits in their binary representations and the shortest path has length $1$).

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = '\'\'\'input\n1\n3\n1 2\n1 3\n1 2 3\n\'\'\'\nimport sys\nsys.setrecursionlimit(1000000)\nfor _ in range(eval(input())):\n C=[]\n n=eval(input())\n for i in range(n):\n  C.append([])\n for i in range(n-1):\n  a,b=[int(x)-1 for x in input().split()]\n  C[a].append(b)\n  C[b].append(a)\n cnt=0\n Co=[bin(int(x)).count("1") for x in input().split()]\n Q=[0]*(n+100)\n cur=0\n done=[0]*n\n done[0]=1\n H=[0]*n\n for i in range(n):\n  r=Q[i]\n  if H[r]&1 == Co[r]&1:\n   cnt+=1\n  for i in C[r]:\n   if done[i]==0:\n    done[i]=1\n    Q[cur+1]=i\n    cur+=1\n    H[i]=H[r]+1\n #dfs(0,-1)\n print(cnt*(n-cnt))\n\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 17923