The garden has a tree with too many leaves on it and gardner wants to cut the unwanted leaves. This is a rooted tree, where a node $v$ is called parent of another node $u$, if there exists a directed edge from $v$ to $u$. Leaf node is a node with no outgoing edges.
Gardner cuts the tree in a peculiar way:
- For each parent node(which has a valid leaf node attached to it), he cuts $x$ leaf nodes, such that $x$ is a multiple of 3.
Example : If a parent node has 7 leaf nodes, 6 leaf nodes will be cut and 1 will be left.
- If a parent has all its leaf nodes cut, only then the parent node itself becomes a new leaf node. If new leaf nodes are created, Gardner repeats step 1 until he can cut no more leaf nodes.
After completing all operations, gardner wants to know the minimum number of nodes left on the tree.

It is guaranteed that the given input is a rooted tree.
The root of the tree is vertex 1.

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow. 
- First line of each testcase contains an integer $n$, the number of vertices in the tree. 
- Second line of each testcase contains array $A$ of size $n-1$, where $A_{i}(1≤i≤n-1)$, is the index of the parent of the $(i+1)^{th}$ vertex. 

-----Output:-----
For each testcase, output single integer, the number of nodes finally left on the tree.  

-----Constraints-----
- $1 \leq T \leq 10$
- $2 \leq n \leq 10^5$ 
- $1 \leq A_i \leq i$

-----Sample Input:-----
1

13

1 1 1 1 1 4 3 4 4 3 4 3 

-----Sample Output:-----
4

-----EXPLANATION:-----

```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 = 'from collections import defaultdict\nimport sys\nsys.setrecursionlimit(10**6)\n\n\n\n\ndef dfs(node):\n visited[node]=True\n n0[node]+=1\n for x in d[node]:\n  if visited[x]==False:\n   dfs(x)\n   n0[node]+=n0[x]\ndef dfs1(node):\n nonlocal ans\n visited[node]=True\n co=0\n for x in d[node]:\n  if visited[x]==False:\n\n   dfs1(x)\n   if n0[x]==1:\n    co+=1\n\n ans1=co//3\n ##print(ans1,node)\n if 3*ans1==len(d[node]):\n  n0[node]=1\n  ##print(n0[node],node)\n ans-=3*ans1\n\n\n\n\n\nfor _ in range(int(input())):\n n=int(input())\n a=list(map(int,input().split()))\n d=defaultdict(list)\n ans=n\n for i in range(len(a)):\n  d[a[i]].append(i+2)\n ##print(d)\n visited = [False] * (n + 1)\n n0 = [0] * (n + 1)\n ##print(n0)\n dfs(1)\n ## print(n0)\n visited=[False]*(n+1)\n dfs1(1)\n print(ans)\n\n\n\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: