**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Iris's Full Binary Tree
time_limit_ms: 4000
memory_limit_mb: 1024
Description: Iris likes full binary trees.

Let's define the depth of a rooted tree as the maximum number of vertices on the simple paths from some vertex to the root. A full binary tree of depth $d$ is a binary tree of depth $d$ with exactly $2^d - 1$ vertices.

Iris calls a tree a $d$-binary tree if some vertices and edges can be added to it to make it a full binary tree of depth $d$. Note that any vertex can be chosen as the root of a full binary tree.

Since performing operations on large trees is difficult, she defines the binary depth of a tree as the minimum $d$ satisfying that the tree is $d$-binary. Specifically, if there is no integer $d \ge 1$ such that the tree is $d$-binary, the binary depth of the tree is $-1$.

Iris now has a tree consisting of only vertex $1$. She wants to add $n - 1$ more vertices to form a larger tree. She will add the vertices one by one. When she adds vertex $i$ ($2 \leq i \leq n$), she'll give you an integer $p_i$ ($1 \leq p_i < i$), and add a new edge connecting vertices $i$ and $p_i$.

Iris wants to ask you the binary depth of the tree formed by the first $i$ vertices for each $1 \le i \le n$. Can you tell her the answer?

Input: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2 \leq n \leq 5 \cdot 10^5$) — the final size of the tree.

The second line of each test case contains $n - 1$ integers $p_2, p_3, \ldots, p_n$ ($1 \leq p_i < i$) — descriptions of all edges of the tree.

It is guaranteed that the sum of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case output $n$ integers, $i$-th of them representing the binary depth of the tree formed by the first $i$ vertices.

Examples:
input:
7
3
1 1
6
1 2 3 4 5
7
1 1 3 2 5 1
10
1 1 2 1 4 2 4 5 8
10
1 1 3 1 3 2 2 2 6
20
1 1 2 2 4 4 5 5 7 6 8 6 11 14 11 8 13 13 12
25
1 1 3 3 1 5 4 4 6 8 11 12 8 7 11 13 7 13 15 6 19 14 10 23
output:
1 2 2
1 2 2 3 3 4
1 2 2 3 3 4 4
1 2 2 3 3 3 4 4 5 5
1 2 2 3 3 4 4 4 -1 -1
1 2 2 3 3 4 4 4 4 5 5 5 5 6 6 6 6 6 6 7
1 2 2 3 3 4 4 4 4 5 5 6 6 6 6 6 7 7 7 7 7 8 8 8 8

Note: In the first test case, the final tree is shown below:

![](CDN_BASE_URL/5045337022386beaeb8585d242e8d14a)

  * The tree consisting of the vertex $1$ has the binary depth $1$ (the tree itself is a full binary tree of depth $1$).    * The tree consisting of the vertices $1$ and $2$ has the binary depth $2$ (we can add the vertex $3$ to make it a full binary tree of depth $2$).    * The tree consisting of the vertices $1$, $2$ and $3$ has the binary depth $2$ (the tree itself is a full binary tree of depth $2$).

In the second test case, the formed full binary tree after adding some vertices to the tree consisting of $n$ vertices is shown below (bolded vertices are added):

![](CDN_BASE_URL/47a803b975dced95812a171507c56a8b)

The depth of the formed full binary tree is $4$.

In the fifth test case, the final tree is shown below:

![](CDN_BASE_URL/ffe91eb3e0db4e64598df8a805ba1e4a)

It can be proved that Iris can't form any full binary tree by adding vertices and edges, so the binary depth is $-1$.

Buggy Code:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll mod = 998244353;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;

#define ls k << 1
#define rs k << 1 | 1

struct segtree
{
    struct segnode
    {
        int l, r;
        int lz, mn;
    }t[maxn << 2];

    inline void pushup(int k) { t[k].mn = min(t[ls].mn, t[rs].mn); }
    inline void upd(int k, int d) { t[k].mn += d; t[k].lz += d; }
    inline void pushdown(int k) { if (t[k].lz) upd(ls, t[k].lz), upd(rs, t[k].lz), t[k].lz = 0; }

    void build(int k, int l, int r)
    {
        t[k].l = l, t[k].r = r, t[k].mn = inf, t[k].lz = 0;
        if (l == r) return; int mid = (l + r) >> 1;
        build(ls, l, mid); build(rs, mid + 1, r);
    }

    void update(int k, int l, int r, int d)
    {
        if (l <= t[k].l && t[k].r <= r) { upd(k, d); return; }
        pushdown(k); int mid = (t[k].l + t[k].r) >> 1;
        if (l <= mid) update(ls, l, r, d);
        if (r > mid) update(rs, l, r, d);
        pushup(k);
    }

    void change(int k, int x, int d)
    {
        if (t[k].l == t[k].r) { t[k].mn = d; return; }
        pushdown(k); int mid = (t[k].l + t[k].r) >> 1;
        if (x <= mid) change(ls, x, d); else change(rs, x, d);
        pushup(k);
    }
}T;

vector<int> g[maxn];
int deg[maxn], fa[maxn], dfn[maxn], siz[maxn], dep[maxn], cnt;
int f[maxn][19];

void dfs(int u)
{
    dfn[u] = ++cnt, siz[u] = 1;
    f[u][0] = fa[u]; for (int i = 1; i <= 18; i++) f[u][i] = f[f[u][i - 1]][i - 1];
    for (int v : g[u]) dep[v] = dep[u] + 1, dfs(v), siz[u] += siz[v];
}

int lca(int u, int v)
{
    if (dep[u] < dep[v]) swap(u, v);
    for (int i = 18; ~i; i--) if (dep[f[u][i]] >= dep[v]) u = f[u][i];
    if (u == v) return u;
    for (int i = 18; ~i; i--) if (f[u][i] != f[v][i]) u = f[u][i], v = f[v][i];
    return f[u][0];
}
int dist(int u, int v) { return dep[u] + dep[v] - 2 * dep[lca(u, v)]; }

int jump(int u, int x)
{
    for (int i = 18; ~i; i--)
        if ((x >> i) & 1) u = f[u][i];
    return u;
}

void work()
{
    int n; cin >> n; cnt = 0;
    for (int i = 1; i <= n; i++) g[i].clear(), deg[i] = 0;
    T.build(1, 1, n);
    for (int i = 2; i <= n; i++) cin >> fa[i], g[fa[i]].emplace_back(i);
    dep[0] = -1; dfs(1);

    bool Fl = 0; cout << "1 ";
    int pl = 1, pr = 1, len = 0;
    for (int i = 2; i <= n; i++)
    {
        deg[i]++, deg[fa[i]]++;
        if (deg[i] >= 4 || deg[fa[i]] >= 4) Fl = 1;
        if (Fl) { cout << "-1 "; continue; }
        if (deg[i] >= 3) T.change(1, dfn[i], inf);
        if (deg[fa[i]] >= 3) T.change(1, dfn[fa[i]], inf);

        int dx = dist(i, pl), dy = dist(i, pr), nlen = max(dx, dy);
        T.change(1, dfn[i], nlen);
        if (nlen > len)
        {
            if (dx < dy) swap(pl, pr), swap(dx, dy);
            if (len == 0) T.change(1, dfn[pl], 1);
            else
            {
                int nx = (len - 1) / 2, lc = lca(pl, pr), dt;
                if (dep[pr] - dep[lc] > nx)
                {
                    dt = jump(pr, nx);
                    T.update(1, 1, n, 1); T.update(1, dfn[dt], dfn[dt] + siz[dt] - 1, -1);
                }
                else
                {
                    dt = jump(pl, len - nx - 1);
                    T.update(1, dfn[dt], dfn[dt] + siz[dt] - 1, 1);
                }
            }
            len = nlen; pr = i;
        }
        cout << T.t[1].mn + 1 << " ";
    }
    cout << "\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int T; cin >> T;
    while (T--) work();
    return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a test input that exposes the bug in the given code, we need to focus on edge cases and scenarios where the code might fail. The code is designed to determine the binary depth of a tree as vertices are added one by one. The main issues in the code could arise from:

1. **Invalid Tree Structures**: The code might not handle cases where the tree cannot be a full binary tree correctly.
2. **Degree Constraints**: The code checks if any vertex has a degree of 4 or more, which is a valid condition to determine that the tree cannot be a full binary tree.
3. **Distance Calculation**: The code uses a segment tree to manage distances, which might fail if the tree structure is complex or if the distance calculations are incorrect.

Given these points, let's create a test input that includes a tree structure that is not a full binary tree and has vertices with high degrees.

### Test Input
```plaintext
1
10
1 1 3 1 3 2 2 2 6
```

### Explanation
- **Test Case**: The test case consists of a single tree with 10 vertices.
- **Tree Structure**:
  - Vertex 1 is the root.
  - Vertices 2 and 3 are children of vertex 1.
  - Vertex 4 is a child of vertex 3.
  - Vertices 5 and 6 are children of vertex 3.
  - Vertices 7, 8, and 9 are children of vertex 2.
  - Vertex 10 is a child of vertex 6.

### Why This Input?
- **High Degree**: Vertex 3 has a degree of 4 (children 4, 5, 6, and 3 itself), which should trigger the condition where the tree cannot be a full binary tree.
- **Complex Structure**: The tree is not a full binary tree, and the structure is complex enough to test the distance calculations and segment tree operations.

### Expected Output
The expected output for this test input should be:
```plaintext
1 2 2 3 3 -1 -1 -1 -1 -1
```

### Reasoning
- **Initial Vertices**: The first few vertices (1, 2, 3) form a valid tree with binary depth 1, 2, and 2 respectively.
- **High Degree Vertex**: When vertex 3 has a degree of 4 (after adding vertices 4 and 5), the binary depth should become -1.
- **Subsequent Vertices**: Any further additions to the tree should maintain the binary depth as -1 because the tree cannot be a full binary tree due to the high degree vertex.

This test input should expose the bug in the code by triggering the condition where the tree cannot be a full binary tree due to a vertex with a degree of 4 or more.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Iris's Full Binary Tree
time_limit_ms: 4000
memory_limit_mb: 1024
Description: Iris likes full binary trees.

Let's define the depth of a rooted tree as the maximum number of vertices on the simple paths from some vertex to the root. A full binary tree of depth $d$ is a binary tree of depth $d$ with exactly $2^d - 1$ vertices.

Iris calls a tree a $d$-binary tree if some vertices and edges can be added to it to make it a full binary tree of depth $d$. Note that any vertex can be chosen as the root of a full binary tree.

Since performing operations on large trees is difficult, she defines the binary depth of a tree as the minimum $d$ satisfying that the tree is $d$-binary. Specifically, if there is no integer $d \ge 1$ such that the tree is $d$-binary, the binary depth of the tree is $-1$.

Iris now has a tree consisting of only vertex $1$. She wants to add $n - 1$ more vertices to form a larger tree. She will add the vertices one by one. When she adds vertex $i$ ($2 \leq i \leq n$), she'll give you an integer $p_i$ ($1 \leq p_i < i$), and add a new edge connecting vertices $i$ and $p_i$.

Iris wants to ask you the binary depth of the tree formed by the first $i$ vertices for each $1 \le i \le n$. Can you tell her the answer?

Input: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2 \leq n \leq 5 \cdot 10^5$) — the final size of the tree.

The second line of each test case contains $n - 1$ integers $p_2, p_3, \ldots, p_n$ ($1 \leq p_i < i$) — descriptions of all edges of the tree.

It is guaranteed that the sum of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case output $n$ integers, $i$-th of them representing the binary depth of the tree formed by the first $i$ vertices.

Examples:
input:
7
3
1 1
6
1 2 3 4 5
7
1 1 3 2 5 1
10
1 1 2 1 4 2 4 5 8
10
1 1 3 1 3 2 2 2 6
20
1 1 2 2 4 4 5 5 7 6 8 6 11 14 11 8 13 13 12
25
1 1 3 3 1 5 4 4 6 8 11 12 8 7 11 13 7 13 15 6 19 14 10 23
output:
1 2 2
1 2 2 3 3 4
1 2 2 3 3 4 4
1 2 2 3 3 3 4 4 5 5
1 2 2 3 3 4 4 4 -1 -1
1 2 2 3 3 4 4 4 4 5 5 5 5 6 6 6 6 6 6 7
1 2 2 3 3 4 4 4 4 5 5 6 6 6 6 6 7 7 7 7 7 8 8 8 8

Note: In the first test case, the final tree is shown below:

![](CDN_BASE_URL/5045337022386beaeb8585d242e8d14a)

  * The tree consisting of the vertex $1$ has the binary depth $1$ (the tree itself is a full binary tree of depth $1$).    * The tree consisting of the vertices $1$ and $2$ has the binary depth $2$ (we can add the vertex $3$ to make it a full binary tree of depth $2$).    * The tree consisting of the vertices $1$, $2$ and $3$ has the binary depth $2$ (the tree itself is a full binary tree of depth $2$).

In the second test case, the formed full binary tree after adding some vertices to the tree consisting of $n$ vertices is shown below (bolded vertices are added):

![](CDN_BASE_URL/47a803b975dced95812a171507c56a8b)

The depth of the formed full binary tree is $4$.

In the fifth test case, the final tree is shown below:

![](CDN_BASE_URL/ffe91eb3e0db4e64598df8a805ba1e4a)

It can be proved that Iris can't form any full binary tree by adding vertices and edges, so the binary depth is $-1$.

Buggy Code:
import heapq

par = []
depth = []
def build(u, p):
    par[u][0] = p
    i = 0
    while par[u][i]:
        par[u][i + 1] = par[par[u][i]][i]
        i += 1
    depth[u] = depth[p] + 1

def lca(u, v):
    d = depth[u] + depth[v]
    if depth[v] > depth[u]:
        u, v = v, u
    for i in range(19, -1, -1):
        if depth[par[u][i]] >= depth[v]:
            u = par[u][i]
    for i in range(19, -1, -1):
        if par[u][i] != par[v][i]:
            u, v = par[u][i], par[v][i]
    p = u if u == v else par[u][0]
    return p, d - 2 * depth[p]

def solve():
    n = int(input())

    global par, depth
    par = [[0] * 20 for _ in range(n + 1)]
    depth = [0] * (n + 1)
    depth[1] = 1

    u, v = 1, 1
    dist = 0
    heap = [(0, 1)]
    deg = [0] * (n + 1)
    max_deg = 1

    print(1, end = ' ')
    i = 1
    for p in list(map(int, input().split())):
        i += 1
        build(i, p)
        deg[i] += 1
        deg[p] += 1
        max_deg = max(max_deg, deg[p])
        if max_deg > 3:
            print(-1, end = ' ')
            continue

        dist1 = lca(i, u)[1]
        dist2 = lca(i, v)[1]
        if dist1 > dist2:
            if dist1 > dist:
                v, dist = i, dist1
        else:
            if dist2 > dist:
                u, dist = i, dist2

        heapq.heappush(heap, (max(lca(i, u)[1], lca(i, v)[1]), i))
        while True:
            d, t = heap[0]
            if deg[t] > 2:
                heapq.heappop(heap)
                continue
            mx = max(lca(t, u)[1], lca(t, v)[1])
            if mx != d:
                heapq.heappop(heap)
                heapq.heappush(heap, (mx, t))
                continue
            print(d + 1, end = ' ')
            break
    print()

t = int(input())
for _ in range(t):
    solve()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
7
3
1 1
6
1 2 3 4 5
7
1 1 3 2 5 1
10
1 1 2 1 4 2 4 5 8
10
1 1 3 1 3 2 2 2 6
20
1 1 2 2 4 4 5 5 7 6 8 6 11 14 11 8 13 13 12
25
1 1 3 3 1 5 4 4 6 8 11 12 8 7 11 13 7 13 15 6 19 14 10 23
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Iris's Full Binary Tree
time_limit_ms: 4000
memory_limit_mb: 1024
Description: Iris likes full binary trees.

Let's define the depth of a rooted tree as the maximum number of vertices on the simple paths from some vertex to the root. A full binary tree of depth $d$ is a binary tree of depth $d$ with exactly $2^d - 1$ vertices.

Iris calls a tree a $d$-binary tree if some vertices and edges can be added to it to make it a full binary tree of depth $d$. Note that any vertex can be chosen as the root of a full binary tree.

Since performing operations on large trees is difficult, she defines the binary depth of a tree as the minimum $d$ satisfying that the tree is $d$-binary. Specifically, if there is no integer $d \ge 1$ such that the tree is $d$-binary, the binary depth of the tree is $-1$.

Iris now has a tree consisting of only vertex $1$. She wants to add $n - 1$ more vertices to form a larger tree. She will add the vertices one by one. When she adds vertex $i$ ($2 \leq i \leq n$), she'll give you an integer $p_i$ ($1 \leq p_i < i$), and add a new edge connecting vertices $i$ and $p_i$.

Iris wants to ask you the binary depth of the tree formed by the first $i$ vertices for each $1 \le i \le n$. Can you tell her the answer?

Input: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2 \leq n \leq 5 \cdot 10^5$) — the final size of the tree.

The second line of each test case contains $n - 1$ integers $p_2, p_3, \ldots, p_n$ ($1 \leq p_i < i$) — descriptions of all edges of the tree.

It is guaranteed that the sum of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case output $n$ integers, $i$-th of them representing the binary depth of the tree formed by the first $i$ vertices.

Examples:
input:
7
3
1 1
6
1 2 3 4 5
7
1 1 3 2 5 1
10
1 1 2 1 4 2 4 5 8
10
1 1 3 1 3 2 2 2 6
20
1 1 2 2 4 4 5 5 7 6 8 6 11 14 11 8 13 13 12
25
1 1 3 3 1 5 4 4 6 8 11 12 8 7 11 13 7 13 15 6 19 14 10 23
output:
1 2 2
1 2 2 3 3 4
1 2 2 3 3 4 4
1 2 2 3 3 3 4 4 5 5
1 2 2 3 3 4 4 4 -1 -1
1 2 2 3 3 4 4 4 4 5 5 5 5 6 6 6 6 6 6 7
1 2 2 3 3 4 4 4 4 5 5 6 6 6 6 6 7 7 7 7 7 8 8 8 8

Note: In the first test case, the final tree is shown below:

![](CDN_BASE_URL/5045337022386beaeb8585d242e8d14a)

  * The tree consisting of the vertex $1$ has the binary depth $1$ (the tree itself is a full binary tree of depth $1$).    * The tree consisting of the vertices $1$ and $2$ has the binary depth $2$ (we can add the vertex $3$ to make it a full binary tree of depth $2$).    * The tree consisting of the vertices $1$, $2$ and $3$ has the binary depth $2$ (the tree itself is a full binary tree of depth $2$).

In the second test case, the formed full binary tree after adding some vertices to the tree consisting of $n$ vertices is shown below (bolded vertices are added):

![](CDN_BASE_URL/47a803b975dced95812a171507c56a8b)

The depth of the formed full binary tree is $4$.

In the fifth test case, the final tree is shown below:

![](CDN_BASE_URL/ffe91eb3e0db4e64598df8a805ba1e4a)

It can be proved that Iris can't form any full binary tree by adding vertices and edges, so the binary depth is $-1$.

Buggy Code:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

class Tree {
public:
    int n; // number of nodes
    vector<vector<int>> adj; // adjacency list
    vector<int> depth, parent, subtree_size;
    vector<vector<int>> up; // for binary lifting in LCA

    Tree(int nodes) : n(nodes), adj(nodes), depth(nodes), parent(nodes), subtree_size(nodes) {
        int log = 1;
        while ((1 << log) <= n) log++;
        up.assign(n, vector<int>(log));
    }

    void add_edge(int u, int v) {
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    void dfs(int v, int p) {
        parent[v] = p;
        subtree_size[v] = 1;
        up[v][0] = p;
        for (int i = 1; i < up[v].size(); i++) {
            up[v][i] = up[up[v][i - 1]][i - 1];
        }
        for (int u : adj[v]) {
            if (u != p) {
                depth[u] = depth[v] + 1;
                dfs(u, v);
                subtree_size[v] += subtree_size[u];
            }
        }
    }

    void prepare(int root = 0) {
        depth[root] = 0;
        dfs(root, root);
    }

    int lca(int u, int v) {
        if (depth[u] < depth[v]) swap(u, v);
        int log = up[u].size();
        for (int i = log - 1; i >= 0; i--) {
            if (depth[u] - (1 << i) >= depth[v]) {
                u = up[u][i];
            }
        }
        if (u == v) return u;
        for (int i = log - 1; i >= 0; i--) {
            if (up[u][i] != up[v][i]) {
                u = up[u][i];
                v = up[v][i];
            }
        }
        return parent[u];
    }

    int dist(int u, int v) {
        int lca_uv = lca(u, v);
        return depth[u] + depth[v] - 2 * depth[lca_uv];
    }

    pair<int, int> find_midpoints(int u, int v) {
        int lca_uv = lca(u, v); // Get the LCA of u and v
        int dist_uv = depth[u] + depth[v] - 2 * depth[lca_uv]; // Calculate the distance between u and v

        // Ensure that `u` is the deeper node
        if (depth[u] < depth[v]) {
            swap(u, v);
        }

        // Calculate the first midpoint
        int midpoint1 = move_up(u, dist_uv / 2);

        // Calculate the second midpoint (if it exists)
        int midpoint2 = (dist_uv % 2 == 0) ? move_up(u, dist_uv / 2) : move_up(u, dist_uv / 2 + 1);

        return {midpoint1, midpoint2};
    }

    int move_up(int node, int steps) {
        for (int i = up[node].size() - 1; i >= 0; i--) {
            if (steps >= (1 << i)) {
                node = up[node][i];
                steps -= (1 << i);
            }
        }
        return node;
    }

};

void solve(){
    int n;
    cin>>n;
    Tree tree(n);
    vector<int> p(n);
    for(int i=1;i<n;i++) cin>>p[i];
    for(int i=1;i<n;i++) --p[i];
    for(int i=1;i<n;i++) tree.add_edge(i, p[i]);
    tree.prepare();
    auto diam = pair(0, 0);
    int diam_length = 0;
    vector<int> deg(n);
    cout<<"1 ";
    bool failed = 0;
    for(int u=1;u<n;u++){
        deg[u]++;
        deg[p[u]]++;
        if(deg[p[u]] > 3) failed = true;
        if(failed){
            cout<<"-1 ";
            continue;
        }
        if(tree.dist(u, diam.first) > diam_length){
            diam.second = u;
        }
        else if(tree.dist(u, diam.second) > diam_length){
            diam.first = u;
        }
        diam_length = tree.dist(diam.first, diam.second);
        auto centres = tree.find_midpoints(diam.first, diam.second);
        int ans = (diam_length + 1) / 2 + 2;
        if(deg[centres.first] < 3 || deg[centres.second] < 3){
            ans--;
        }
        cout<<ans<<" ";
    }
    cout<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T = 1;
    cin>>T;
    for(int t=1;t<=T;t++){
        solve();
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
5
1 1 1 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Iris's Full Binary Tree
time_limit_ms: 4000
memory_limit_mb: 1024
Description: Iris likes full binary trees.

Let's define the depth of a rooted tree as the maximum number of vertices on the simple paths from some vertex to the root. A full binary tree of depth $d$ is a binary tree of depth $d$ with exactly $2^d - 1$ vertices.

Iris calls a tree a $d$-binary tree if some vertices and edges can be added to it to make it a full binary tree of depth $d$. Note that any vertex can be chosen as the root of a full binary tree.

Since performing operations on large trees is difficult, she defines the binary depth of a tree as the minimum $d$ satisfying that the tree is $d$-binary. Specifically, if there is no integer $d \ge 1$ such that the tree is $d$-binary, the binary depth of the tree is $-1$.

Iris now has a tree consisting of only vertex $1$. She wants to add $n - 1$ more vertices to form a larger tree. She will add the vertices one by one. When she adds vertex $i$ ($2 \leq i \leq n$), she'll give you an integer $p_i$ ($1 \leq p_i < i$), and add a new edge connecting vertices $i$ and $p_i$.

Iris wants to ask you the binary depth of the tree formed by the first $i$ vertices for each $1 \le i \le n$. Can you tell her the answer?

Input: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2 \leq n \leq 5 \cdot 10^5$) — the final size of the tree.

The second line of each test case contains $n - 1$ integers $p_2, p_3, \ldots, p_n$ ($1 \leq p_i < i$) — descriptions of all edges of the tree.

It is guaranteed that the sum of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case output $n$ integers, $i$-th of them representing the binary depth of the tree formed by the first $i$ vertices.

Examples:
input:
7
3
1 1
6
1 2 3 4 5
7
1 1 3 2 5 1
10
1 1 2 1 4 2 4 5 8
10
1 1 3 1 3 2 2 2 6
20
1 1 2 2 4 4 5 5 7 6 8 6 11 14 11 8 13 13 12
25
1 1 3 3 1 5 4 4 6 8 11 12 8 7 11 13 7 13 15 6 19 14 10 23
output:
1 2 2
1 2 2 3 3 4
1 2 2 3 3 4 4
1 2 2 3 3 3 4 4 5 5
1 2 2 3 3 4 4 4 -1 -1
1 2 2 3 3 4 4 4 4 5 5 5 5 6 6 6 6 6 6 7
1 2 2 3 3 4 4 4 4 5 5 6 6 6 6 6 7 7 7 7 7 8 8 8 8

Note: In the first test case, the final tree is shown below:

![](CDN_BASE_URL/5045337022386beaeb8585d242e8d14a)

  * The tree consisting of the vertex $1$ has the binary depth $1$ (the tree itself is a full binary tree of depth $1$).    * The tree consisting of the vertices $1$ and $2$ has the binary depth $2$ (we can add the vertex $3$ to make it a full binary tree of depth $2$).    * The tree consisting of the vertices $1$, $2$ and $3$ has the binary depth $2$ (the tree itself is a full binary tree of depth $2$).

In the second test case, the formed full binary tree after adding some vertices to the tree consisting of $n$ vertices is shown below (bolded vertices are added):

![](CDN_BASE_URL/47a803b975dced95812a171507c56a8b)

The depth of the formed full binary tree is $4$.

In the fifth test case, the final tree is shown below:

![](CDN_BASE_URL/ffe91eb3e0db4e64598df8a805ba1e4a)

It can be proved that Iris can't form any full binary tree by adding vertices and edges, so the binary depth is $-1$.

Buggy Code:
#include <bits/stdc++.h>
int T,N,dg[500009],p[500009],anc[500009][19],hd[500009],to[1000009],nxt[1000009],k,vv[500009],
d[500009],as[500009][22],dep[500009],r[500009];
void l(int u,int v) {
	to[++k]=v;nxt[k]=hd[u];hd[u]=k;
}
inline int lca(int a,int b) {
    if(dep[a]<dep[b]) std::swap(a,b);
    for(int i=18;i>=0;i--)
        if(dep[a]-dep[b]>=(1<<i))
            a=anc[a][i];
    for(int i=18;i>=0;i--)
        if(anc[a][i]!=anc[b][i])
        	a=anc[a][i],b=anc[b][i];
    if(a!=b) a=anc[a][0];return a;
}
inline int jp(int a,int x) {
	for(int i=18;i>=0;i--) if(x>=(1<<i)) {
		x-=(1<<i);a=anc[a][i];
	}
	assert(a);
	return a;
}
inline int qiu(int x,int v) {
	for(int i=0;i<=21;i++) {
		if(as[x][i]>=v) return i;
	}
	return 22;
}
inline int dis(int x,int y) {
	return dep[x]+dep[y]-2*dep[lca(x,y)];
}
signed main(void) {
	scanf("%d",&T);
	while(T--) {
		scanf("%d",&N);
		for(int i=1;i<=N;i++) dg[i]=0,hd[i]=0;
		printf("1 ");
		k=0;
		bool ff=0;
		int ll=N+1;
		for(int i=1;i<=N;i++) r[i]=N,vv[i]=0;
		for(int i=2;i<=N;i++) {
			scanf("%d",&p[i]);
			anc[i][0]=p[i];
			dep[i]=dep[p[i]]+1;
			l(p[i],i);l(i,p[i]);
			dg[p[i]]++;
			dg[i]++;
			if(dg[p[i]]>3) ff=1;
			if(dg[i]>3) ff=1;
			if(dg[p[i]]==3) {
				r[p[i]]=i-1;
			}
			if(ff&&ll==N+1) {
				ll=i;
			}
		}
		for(int i=1;i<=18;i++) {
			for(int j=1;j<=N;j++) {
				anc[j][i]=anc[anc[j][i-1]][i-1];
			}
		}
		for(int i=1;i<ll;i++) {
			std::queue<int> q;
			q.push(i);
			vv[i]=i;
			d[i]=0;
			memset(as[i],0,sizeof(as[i]));
			while(!q.empty()) {
				int a=q.front();
				q.pop();
				as[i][d[a]]=std::max(as[i][d[a]],r[a]);
				assert(d[a]<=21);
				if(r[a]==N) break;
				for(int j=hd[a];j;j=nxt[j]) {
					if(vv[to[j]]!=i&&to[j]<ll) {
						d[to[j]]=d[i]+1;
						vv[to[j]]=i;
						q.push(to[j]);
					}
				}
			}
		}
		int a=1,b=1,dd=0;
		for(int i=2;i<ll;i++) {
			int aa=a,bb=b;
			int t1=dis(i,aa);
			if(t1>=dd) {
				dd=t1;
				a=i;b=aa;
			}
			int t2=dis(bb,i);
			if(t2>=dd) {
				dd=t2;
				a=bb;
				b=i;
			}
		//	printf("%d %d %d\n",a,b,dd);
			int ans=0;
			if(dd%2==0) {
				if(dep[a]<=dep[b]) {
					ans=qiu(jp(b,dd/2),i)+dd/2;
				} else {
					ans=qiu(jp(a,dd/2),i)+dd/2;
				}
			} else {
				if(dep[a]<=dep[b]) {
					int x=jp(b,dd/2);
					ans=std::min(qiu(x,i),qiu(p[x],i))+dd/2+1;
				} else {
					int x=jp(a,dd/2);
					ans=std::min(qiu(x,i),qiu(p[x],i))+dd/2+1;
				}
			}
			printf("%d ",ans+1);
		}
		for(int i=ll;i<=N;i++) printf("-1 ");
		printf("\n");
	}
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
4
1 1 1
5
1 2 2 2
6
1 1 2 2 3
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Iris's Full Binary Tree
time_limit_ms: 4000
memory_limit_mb: 1024
Description: Iris likes full binary trees.

Let's define the depth of a rooted tree as the maximum number of vertices on the simple paths from some vertex to the root. A full binary tree of depth $d$ is a binary tree of depth $d$ with exactly $2^d - 1$ vertices.

Iris calls a tree a $d$-binary tree if some vertices and edges can be added to it to make it a full binary tree of depth $d$. Note that any vertex can be chosen as the root of a full binary tree.

Since performing operations on large trees is difficult, she defines the binary depth of a tree as the minimum $d$ satisfying that the tree is $d$-binary. Specifically, if there is no integer $d \ge 1$ such that the tree is $d$-binary, the binary depth of the tree is $-1$.

Iris now has a tree consisting of only vertex $1$. She wants to add $n - 1$ more vertices to form a larger tree. She will add the vertices one by one. When she adds vertex $i$ ($2 \leq i \leq n$), she'll give you an integer $p_i$ ($1 \leq p_i < i$), and add a new edge connecting vertices $i$ and $p_i$.

Iris wants to ask you the binary depth of the tree formed by the first $i$ vertices for each $1 \le i \le n$. Can you tell her the answer?

Input: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2 \leq n \leq 5 \cdot 10^5$) — the final size of the tree.

The second line of each test case contains $n - 1$ integers $p_2, p_3, \ldots, p_n$ ($1 \leq p_i < i$) — descriptions of all edges of the tree.

It is guaranteed that the sum of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case output $n$ integers, $i$-th of them representing the binary depth of the tree formed by the first $i$ vertices.

Examples:
input:
7
3
1 1
6
1 2 3 4 5
7
1 1 3 2 5 1
10
1 1 2 1 4 2 4 5 8
10
1 1 3 1 3 2 2 2 6
20
1 1 2 2 4 4 5 5 7 6 8 6 11 14 11 8 13 13 12
25
1 1 3 3 1 5 4 4 6 8 11 12 8 7 11 13 7 13 15 6 19 14 10 23
output:
1 2 2
1 2 2 3 3 4
1 2 2 3 3 4 4
1 2 2 3 3 3 4 4 5 5
1 2 2 3 3 4 4 4 -1 -1
1 2 2 3 3 4 4 4 4 5 5 5 5 6 6 6 6 6 6 7
1 2 2 3 3 4 4 4 4 5 5 6 6 6 6 6 7 7 7 7 7 8 8 8 8

Note: In the first test case, the final tree is shown below:

![](CDN_BASE_URL/5045337022386beaeb8585d242e8d14a)

  * The tree consisting of the vertex $1$ has the binary depth $1$ (the tree itself is a full binary tree of depth $1$).    * The tree consisting of the vertices $1$ and $2$ has the binary depth $2$ (we can add the vertex $3$ to make it a full binary tree of depth $2$).    * The tree consisting of the vertices $1$, $2$ and $3$ has the binary depth $2$ (the tree itself is a full binary tree of depth $2$).

In the second test case, the formed full binary tree after adding some vertices to the tree consisting of $n$ vertices is shown below (bolded vertices are added):

![](CDN_BASE_URL/47a803b975dced95812a171507c56a8b)

The depth of the formed full binary tree is $4$.

In the fifth test case, the final tree is shown below:

![](CDN_BASE_URL/ffe91eb3e0db4e64598df8a805ba1e4a)

It can be proved that Iris can't form any full binary tree by adding vertices and edges, so the binary depth is $-1$.

Buggy Code:
#include<map>
#include<set>
#include<ctime>
#include<cmath>
#include<queue>
#include<bitset>
#include<cstdio>
#include<vector>
#include<random>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
#define I ll
#define her1 20081214
#define IV void
#define cht 998244353
#define ld long double
#define Aestas16 392699
#define ull unsigned long long
#define cp(x,y)memcpy(x,y,sizeof y)
#define mem(x,val)memset(x,val,sizeof x)
#define D(i,j,n)for(register int i=j;i>=n;i--)
#define E(i,now)for(register int i=first[now];i;i=e[i].nxt)
#define F(i,j,n)for(register int i=j;i<=n;i++)
#define DL(i,j,n)for(register i64 i=j;i>=n;i--)
#define EL(i,now)for(register i64 i=first[now];i;i=e[i].nxt)
#define FL(i,j,n)for(register i64 i=j;i<=n;i++)
//#define D(i,j,n)for(int i=j;i>=n;i--)
//#define E(i,now)for(int i=first[now];i;i=e[i].nxt)
//#define F(i,j,n)for(int i=j;i<=n;i++)
//#define DL(i,j,n)for(register ll i=j;i>=n;i--)
//#define EL(i,now)for(register ll i=first[now];i;i=e[i].nxt)
//#define FL(i,j,n)for(register ll i=j;i<=n;i++)
ll read(){
	ll ans=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')ans=ans*10+c-'0',c=getchar();
	return ans*f;
}
#undef ll
#include "assert.h"
mt19937_64 rnd(her1);
#include "functional"
using i64 = long long;
const int maxn = 5e5+5;
i64 n,f[maxn][22],p[maxn],s[maxn][22],d[maxn],zk[maxn];
i64 lca(i64 x,i64 y){
    if(d[x]<d[y])swap(x,y);i64 a=d[x]-d[y];D(i,20,0)if(a>>i&1)x=f[x][i];
	D(i,20,0)if(f[x][i]!=f[y][i])x=f[x][i],y=f[y][i];return x==y?x:f[x][0];
}
i64 sp(i64 x){i64 e=0;while(!s[x][e])e++;return e;}
i64 dis(i64 x,i64 y){return d[x]+d[y]-2*d[lca(x,y)];}
i64 kth(i64 x,i64 k){F(i,0,20)if(k>>i&1)x=f[x][i];return x;}
IV doi(i64 x,i64 z){i64 o=x;F(i,0,20){if(i)o=p[o];if(!o)break;s[o][i]+=z;}}
i64 ask2(i64 x){
	i64 fk=1e9,o=x;
	F(i,0,20){
		if(i)o=p[o];if(!o)break;
		fk=min(fk,i+sp(o));
	}
	return fk;
}
i64 ask1(i64 x){
	i64 fk=1e9,o=x;
	F(i,0,20){
		if(i)o=p[o];if(!o)break;
		fk=min(fk,max(0,i-1)+sp(o));
	}
	return fk;
}
IV solve(){
	n=read();F(i,2,n)f[i][0]=p[i]=read(),d[i]=d[p[i]]+1;
	F(o,1,20)F(i,1,n)f[i][o]=f[f[i][o-1]][o-1];F(i,1,n)F(o,0,20)s[i][0]=0;
	i64 a=1,b=1;F(i,1,n)zk[i]=0;zk[1]=-1;bool gg=0;
	F(i,1,n){
        if(gg){printf("-1 ");continue;}
        if(dis(a,b)<dis(b,i))a=i;if(dis(a,b)<dis(a,i))b=i;
        if(d[a]<d[b])swap(a,b);doi(i,1);
        if(i>1){
            i64 f=p[i];zk[f]++;
            if(zk[f]>2){gg=1,printf("-1 ");continue;}
            if(zk[f]==2)doi(f,-1);
        }
        i64 lc=lca(a,b),di=d[a]+d[b]-d[lc]*2;
        if((d[a]^d[b])&1)printf("%lld ",1+ask1(kth(a,di/2))+(di+1)/2);
        else printf("%lld ",1+ask2(kth(a,di/2))+di/2);
    }
    puts("");
}
int main(){
	// freopen("1.in","r",stdin);
	// freopen("1.out","w",stdout);
	i64 T=read();while(T--)solve();return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
5
1 1 1 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Iris's Full Binary Tree
time_limit_ms: 4000
memory_limit_mb: 1024
Description: Iris likes full binary trees.

Let's define the depth of a rooted tree as the maximum number of vertices on the simple paths from some vertex to the root. A full binary tree of depth $d$ is a binary tree of depth $d$ with exactly $2^d - 1$ vertices.

Iris calls a tree a $d$-binary tree if some vertices and edges can be added to it to make it a full binary tree of depth $d$. Note that any vertex can be chosen as the root of a full binary tree.

Since performing operations on large trees is difficult, she defines the binary depth of a tree as the minimum $d$ satisfying that the tree is $d$-binary. Specifically, if there is no integer $d \ge 1$ such that the tree is $d$-binary, the binary depth of the tree is $-1$.

Iris now has a tree consisting of only vertex $1$. She wants to add $n - 1$ more vertices to form a larger tree. She will add the vertices one by one. When she adds vertex $i$ ($2 \leq i \leq n$), she'll give you an integer $p_i$ ($1 \leq p_i < i$), and add a new edge connecting vertices $i$ and $p_i$.

Iris wants to ask you the binary depth of the tree formed by the first $i$ vertices for each $1 \le i \le n$. Can you tell her the answer?

Input: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2 \leq n \leq 5 \cdot 10^5$) — the final size of the tree.

The second line of each test case contains $n - 1$ integers $p_2, p_3, \ldots, p_n$ ($1 \leq p_i < i$) — descriptions of all edges of the tree.

It is guaranteed that the sum of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case output $n$ integers, $i$-th of them representing the binary depth of the tree formed by the first $i$ vertices.

Examples:
input:
7
3
1 1
6
1 2 3 4 5
7
1 1 3 2 5 1
10
1 1 2 1 4 2 4 5 8
10
1 1 3 1 3 2 2 2 6
20
1 1 2 2 4 4 5 5 7 6 8 6 11 14 11 8 13 13 12
25
1 1 3 3 1 5 4 4 6 8 11 12 8 7 11 13 7 13 15 6 19 14 10 23
output:
1 2 2
1 2 2 3 3 4
1 2 2 3 3 4 4
1 2 2 3 3 3 4 4 5 5
1 2 2 3 3 4 4 4 -1 -1
1 2 2 3 3 4 4 4 4 5 5 5 5 6 6 6 6 6 6 7
1 2 2 3 3 4 4 4 4 5 5 6 6 6 6 6 7 7 7 7 7 8 8 8 8

Note: In the first test case, the final tree is shown below:

![](CDN_BASE_URL/5045337022386beaeb8585d242e8d14a)

  * The tree consisting of the vertex $1$ has the binary depth $1$ (the tree itself is a full binary tree of depth $1$).    * The tree consisting of the vertices $1$ and $2$ has the binary depth $2$ (we can add the vertex $3$ to make it a full binary tree of depth $2$).    * The tree consisting of the vertices $1$, $2$ and $3$ has the binary depth $2$ (the tree itself is a full binary tree of depth $2$).

In the second test case, the formed full binary tree after adding some vertices to the tree consisting of $n$ vertices is shown below (bolded vertices are added):

![](CDN_BASE_URL/47a803b975dced95812a171507c56a8b)

The depth of the formed full binary tree is $4$.

In the fifth test case, the final tree is shown below:

![](CDN_BASE_URL/ffe91eb3e0db4e64598df8a805ba1e4a)

It can be proved that Iris can't form any full binary tree by adding vertices and edges, so the binary depth is $-1$.

Buggy Code:
#include <bits/stdc++.h>
int T,N,dg[500009],p[500009],anc[500009][19],hd[500009],to[1000009],nxt[1000009],k,vv[500009],
d[500009],as[500009][22],dep[500009],r[500009];
void l(int u,int v) {
	to[++k]=v;nxt[k]=hd[u];hd[u]=k;
}
inline int lca(int a,int b) {
    if(dep[a]<dep[b]) std::swap(a,b);
    for(int i=18;i>=0;i--)
        if(dep[a]-dep[b]>=(1<<i))
            a=anc[a][i];
    for(int i=18;i>=0;i--)
        if(anc[a][i]!=anc[b][i])
        	a=anc[a][i],b=anc[b][i];
    if(a!=b) a=anc[a][0];return a;
}
inline int jp(int a,int x) {
	for(int i=18;i>=0;i--) if(x>=(1<<i)) {
		x-=(1<<i);a=anc[a][i];
	}
	assert(a);
	return a;
}
inline int qiu(int x,int v) {
	for(int i=0;i<=21;i++) {
		if(as[x][i]>=v) return i;
	}
	return 22;
}
inline int dis(int x,int y) {
	return dep[x]+dep[y]-2*dep[lca(x,y)];
}
signed main(void) {
	scanf("%d",&T);
	while(T--) {
		scanf("%d",&N);
		for(int i=1;i<=N;i++) dg[i]=0,hd[i]=0;
		printf("1 ");
		k=0;
		bool ff=0;
		int ll=N+1;
		for(int i=1;i<=N;i++) r[i]=N,vv[i]=0;
		for(int i=2;i<=N;i++) {
			scanf("%d",&p[i]);
			anc[i][0]=p[i];
			dep[i]=dep[p[i]]+1;
			l(p[i],i);l(i,p[i]);
			dg[p[i]]++;
			dg[i]++;
			if(dg[p[i]]>3) ff=1;
			if(dg[i]>3) ff=1;
			if(dg[p[i]]==3) {
				r[p[i]]=i-1;
			}
			if(ff&&ll==N+1) {
				ll=i;
			}
		}
		for(int i=1;i<=18;i++) {
			for(int j=1;j<=N;j++) {
				anc[j][i]=anc[anc[j][i-1]][i-1];
			}
		}
		for(int i=1;i<ll;i++) {
			std::queue<int> q;
			q.push(i);
			vv[i]=i;
			d[i]=0;
			memset(as[i],0,sizeof(as[i]));
			while(!q.empty()) {
				int a=q.front();
				q.pop();
				as[i][d[a]]=std::max(as[i][d[a]],r[a]);
				assert(d[a]<=21);
				if(r[a]==N) break;
				for(int j=hd[a];j;j=nxt[j]) {
					if(vv[to[j]]!=i&&to[j]<ll) {
						d[to[j]]=d[i]+1;
						vv[to[j]]=i;
						q.push(to[j]);
					}
				}
			}
		}
		int a=1,b=1,dd=0;
		for(int i=2;i<ll;i++) {
			int t1=dis(i,a);
			if(t1>dd) {
				dd=t1;
				b=i;
			}
			int t2=dis(i,b);
			if(t2>dd) {
				dd=t2;
				a=i;
			}
		//	printf("%d %d %d\n",a,b,dd);
			int ans=0;
			if(dd%2==0) {
				if(dep[a]<=dep[b]) {
					ans=qiu(jp(b,dd/2),i)+dd/2;
				} else {
					ans=qiu(jp(a,dd/2),i)+dd/2;
				}
			} else {
				if(dep[a]<=dep[b]) {
					int x=jp(b,dd/2);
					ans=std::min(qiu(x,i),qiu(p[x],i))+dd/2+1;
				} else {
					int x=jp(a,dd/2);
					ans=std::min(qiu(x,i),qiu(p[x],i))+dd/2+1;
				}
			}
			printf("%d ",ans+1);
		}
		for(int i=ll;i<=N;i++) printf("-1 ");
		printf("\n");
	}
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
6
1 2 3 4 5
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Iris's Full Binary Tree
time_limit_ms: 4000
memory_limit_mb: 1024
Description: Iris likes full binary trees.

Let's define the depth of a rooted tree as the maximum number of vertices on the simple paths from some vertex to the root. A full binary tree of depth $d$ is a binary tree of depth $d$ with exactly $2^d - 1$ vertices.

Iris calls a tree a $d$-binary tree if some vertices and edges can be added to it to make it a full binary tree of depth $d$. Note that any vertex can be chosen as the root of a full binary tree.

Since performing operations on large trees is difficult, she defines the binary depth of a tree as the minimum $d$ satisfying that the tree is $d$-binary. Specifically, if there is no integer $d \ge 1$ such that the tree is $d$-binary, the binary depth of the tree is $-1$.

Iris now has a tree consisting of only vertex $1$. She wants to add $n - 1$ more vertices to form a larger tree. She will add the vertices one by one. When she adds vertex $i$ ($2 \leq i \leq n$), she'll give you an integer $p_i$ ($1 \leq p_i < i$), and add a new edge connecting vertices $i$ and $p_i$.

Iris wants to ask you the binary depth of the tree formed by the first $i$ vertices for each $1 \le i \le n$. Can you tell her the answer?

Input: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2 \leq n \leq 5 \cdot 10^5$) — the final size of the tree.

The second line of each test case contains $n - 1$ integers $p_2, p_3, \ldots, p_n$ ($1 \leq p_i < i$) — descriptions of all edges of the tree.

It is guaranteed that the sum of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case output $n$ integers, $i$-th of them representing the binary depth of the tree formed by the first $i$ vertices.

Examples:
input:
7
3
1 1
6
1 2 3 4 5
7
1 1 3 2 5 1
10
1 1 2 1 4 2 4 5 8
10
1 1 3 1 3 2 2 2 6
20
1 1 2 2 4 4 5 5 7 6 8 6 11 14 11 8 13 13 12
25
1 1 3 3 1 5 4 4 6 8 11 12 8 7 11 13 7 13 15 6 19 14 10 23
output:
1 2 2
1 2 2 3 3 4
1 2 2 3 3 4 4
1 2 2 3 3 3 4 4 5 5
1 2 2 3 3 4 4 4 -1 -1
1 2 2 3 3 4 4 4 4 5 5 5 5 6 6 6 6 6 6 7
1 2 2 3 3 4 4 4 4 5 5 6 6 6 6 6 7 7 7 7 7 8 8 8 8

Note: In the first test case, the final tree is shown below:

![](CDN_BASE_URL/5045337022386beaeb8585d242e8d14a)

  * The tree consisting of the vertex $1$ has the binary depth $1$ (the tree itself is a full binary tree of depth $1$).    * The tree consisting of the vertices $1$ and $2$ has the binary depth $2$ (we can add the vertex $3$ to make it a full binary tree of depth $2$).    * The tree consisting of the vertices $1$, $2$ and $3$ has the binary depth $2$ (the tree itself is a full binary tree of depth $2$).

In the second test case, the formed full binary tree after adding some vertices to the tree consisting of $n$ vertices is shown below (bolded vertices are added):

![](CDN_BASE_URL/47a803b975dced95812a171507c56a8b)

The depth of the formed full binary tree is $4$.

In the fifth test case, the final tree is shown below:

![](CDN_BASE_URL/ffe91eb3e0db4e64598df8a805ba1e4a)

It can be proved that Iris can't form any full binary tree by adding vertices and edges, so the binary depth is $-1$.

Buggy Code:
#include <bits/stdc++.h>

using namespace std;

// #define int long long
typedef long long ll;
typedef long double ld;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define ar(x) array<int, x>
const int INF = (int) 2e9;
const int L = 20;

void solve() {
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    cout << "1 ";
    bool ban = false;
    vector<int> xx(n - 1);
    vector<vector<int>> g0(n);
    for (int i = 0; i < n - 1; i++) {
        cin >> xx[i];
        xx[i]--;
        g0[xx[i]].pb(i + 1);
        g0[i + 1].pb(xx[i]);
    }

    vector<int> d(n);
    vector<vector<int>> up(n, vector<int>(L));

    auto dfs = [&](auto dfs, int v, int p = -1) -> void {
        for (auto u: g0[v]) {
            if (u == p)continue;
            up[u][0] = v;
            d[u] = 1 + d[v];
            dfs(dfs, u, v);
        }
    };

    dfs(dfs, 0);
    for (int l = 1; l < L; l++) {
        for (int v = 0; v < n; v++) {
            up[v][l] = up[up[v][l - 1]][l - 1];
        }
    }

    auto lca = [&](int v, int u) {
        if (d[v] > d[u]) {
            swap(v, u);
        }
        int diff = d[u] - d[v];
        for (int i = 0; i < L; i++) {
            if ((diff >> i) & 1) {
                u = up[u][i];
            }
        }
        if (v == u)return v;
        for (int i = L - 1; i >= 0; i--) {
            if (up[u][i] != up[v][i]) {
                v = up[v][i];
                u = up[u][i];
            }
        }
        return up[u][0];
    };

    auto dist = [&](int v, int u) {
        return d[v] + d[u] - 2 * d[lca(v, u)];
    };

    int v1 = 0, v2 = 0, curr = 0;
    int ans = INF;

    set<int> good = {0};

    for (int i = 0; i < n - 1; i++) {
        int x = xx[i];
        g[x].pb(i + 1);
        g[i + 1].pb(x);
        good.insert(i + 1);
        if (g[x].size() >= 4 || g[i + 1].size() >= 4) {
            ban = true;
        }
        if (g[x].size() >= 3) {
            good.erase(x);
        }
        if (ban) {
            cout << "-1 ";
            continue;
        }

        {
            int w1 = dist(v1, i + 1);
            int w2 = dist(v2, i + 1);
            if (w1 == max({w1, w2, curr})) {
                curr = w1;
                v2 = i + 1;
            } else if (w2 == max({w1, w2, curr})) {
                curr = w2;
                v1 = i + 1;
            }
        }

        ans = INF;

        int tick=0;

        for (auto v: good) {
            ++tick;
            ans = min(ans, 1 + max(dist(v, v2), dist(v, v1)));
            if(tick==90)break;
        }

        cout << ans << ' ';
    }

    cout << '\n';

}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the provided buggy code, we need to focus on edge cases and scenarios that can cause the code to fail. The main issues in the buggy code are related to how it handles the structure of the tree and the conditions for forming a full binary tree.

### Key Points to Consider:
1. **Tree Structure**: The code should correctly handle trees that cannot form a full binary tree.
2. **Node Degrees**: The code should correctly handle nodes with more than 3 children, which would make it impossible to form a full binary tree.
3. **LCA and Distance Calculation**: The code should correctly calculate the least common ancestor (LCA) and distances between nodes.

### Test Case:
We will create a small tree that has nodes with more than 3 children, which should cause the code to output `-1` when it tries to form a full binary tree.

### Test Input:
```plaintext
1
7
1 1 1 1 2 2 2
```

### Explanation:
- **Test Case 1**:
  - **n = 7**: The tree will have 7 vertices.
  - **Edges**:
    - Vertex 1 is connected to vertices 2, 3, 4, and 5.
    - Vertex 2 is connected to vertices 6 and 7.

### Expected Output:
```plaintext
1 2 2 2 2 -1 -1
```

### Reasoning:
- **Step 1**: The tree starts with a single vertex (1), so the binary depth is 1.
- **Step 2**: Adding vertex 2 (connected to 1) increases the binary depth to 2.
- **Step 3**: Adding vertex 3 (connected to 1) keeps the binary depth at 2.
- **Step 4**: Adding vertex 4 (connected to 1) keeps the binary depth at 2.
- **Step 5**: Adding vertex 5 (connected to 1) keeps the binary depth at 2.
- **Step 6**: Adding vertex 6 (connected to 2) keeps the binary depth at 2.
- **Step 7**: Adding vertex 7 (connected to 2) increases the binary depth to -1 because vertex 1 has more than 3 children, making it impossible to form a full binary tree.

This test case should effectively expose the bug in the code by causing it to output `-1` when it should.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Iris's Full Binary Tree
time_limit_ms: 4000
memory_limit_mb: 1024
Description: Iris likes full binary trees.

Let's define the depth of a rooted tree as the maximum number of vertices on the simple paths from some vertex to the root. A full binary tree of depth $d$ is a binary tree of depth $d$ with exactly $2^d - 1$ vertices.

Iris calls a tree a $d$-binary tree if some vertices and edges can be added to it to make it a full binary tree of depth $d$. Note that any vertex can be chosen as the root of a full binary tree.

Since performing operations on large trees is difficult, she defines the binary depth of a tree as the minimum $d$ satisfying that the tree is $d$-binary. Specifically, if there is no integer $d \ge 1$ such that the tree is $d$-binary, the binary depth of the tree is $-1$.

Iris now has a tree consisting of only vertex $1$. She wants to add $n - 1$ more vertices to form a larger tree. She will add the vertices one by one. When she adds vertex $i$ ($2 \leq i \leq n$), she'll give you an integer $p_i$ ($1 \leq p_i < i$), and add a new edge connecting vertices $i$ and $p_i$.

Iris wants to ask you the binary depth of the tree formed by the first $i$ vertices for each $1 \le i \le n$. Can you tell her the answer?

Input: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2 \leq n \leq 5 \cdot 10^5$) — the final size of the tree.

The second line of each test case contains $n - 1$ integers $p_2, p_3, \ldots, p_n$ ($1 \leq p_i < i$) — descriptions of all edges of the tree.

It is guaranteed that the sum of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case output $n$ integers, $i$-th of them representing the binary depth of the tree formed by the first $i$ vertices.

Examples:
input:
7
3
1 1
6
1 2 3 4 5
7
1 1 3 2 5 1
10
1 1 2 1 4 2 4 5 8
10
1 1 3 1 3 2 2 2 6
20
1 1 2 2 4 4 5 5 7 6 8 6 11 14 11 8 13 13 12
25
1 1 3 3 1 5 4 4 6 8 11 12 8 7 11 13 7 13 15 6 19 14 10 23
output:
1 2 2
1 2 2 3 3 4
1 2 2 3 3 4 4
1 2 2 3 3 3 4 4 5 5
1 2 2 3 3 4 4 4 -1 -1
1 2 2 3 3 4 4 4 4 5 5 5 5 6 6 6 6 6 6 7
1 2 2 3 3 4 4 4 4 5 5 6 6 6 6 6 7 7 7 7 7 8 8 8 8

Note: In the first test case, the final tree is shown below:

![](CDN_BASE_URL/5045337022386beaeb8585d242e8d14a)

  * The tree consisting of the vertex $1$ has the binary depth $1$ (the tree itself is a full binary tree of depth $1$).    * The tree consisting of the vertices $1$ and $2$ has the binary depth $2$ (we can add the vertex $3$ to make it a full binary tree of depth $2$).    * The tree consisting of the vertices $1$, $2$ and $3$ has the binary depth $2$ (the tree itself is a full binary tree of depth $2$).

In the second test case, the formed full binary tree after adding some vertices to the tree consisting of $n$ vertices is shown below (bolded vertices are added):

![](CDN_BASE_URL/47a803b975dced95812a171507c56a8b)

The depth of the formed full binary tree is $4$.

In the fifth test case, the final tree is shown below:

![](CDN_BASE_URL/ffe91eb3e0db4e64598df8a805ba1e4a)

It can be proved that Iris can't form any full binary tree by adding vertices and edges, so the binary depth is $-1$.

Buggy Code:
//A tree without skin will surely die.
//A man without face will be alive.
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for (int i=j;i<=k;++i)
#define per(i,j,k) for (int i=j;i>=k;--i)
int const N=5e5+10;
int n,p[N],siz[N],du[N],mx,maxn[N],rt;
vector<int>a[N];
inline void dfs(int x,int fa,int dep){
    mx=max(mx,dep);
    int cnt=0;
    for (auto v:a[x]) if (v^fa) dfs(v,x,dep+1),++cnt;
    if (cnt>2) mx=1e9;
}
inline void solve(){
    cin>>n;
    rep(i,1,n) a[i].clear();
    rep(i,2,n) cin>>p[i];
    cout<<"1 ";
    rep(i,2,n){
        a[p[i]].push_back(i);
        a[i].push_back(p[i]);
        int ans=1e9;
        rep(j,1,i)
            mx=0,dfs(j,0,1),ans=min(ans,mx);
        if (ans==1e9) ans=-1;
        cout<<ans<<' ';
    }
    cout<<'\n';
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t=1;
    cin>>t;
    while (t--) solve();
    // cerr<<"Time: "<<(double)clock()/CLOCKS_PER_SEC<<" s\n";
    return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
5
1 1 2 2
```

**Explanation:**
This test case is designed to expose a potential issue in the buggy code by creating a tree that does not form a full binary tree at any point. Here's the step-by-step reasoning:

1. **Initial Tree:**
   - Start with a single vertex `1`.

2. **Adding Vertex 2:**
   - Connect `2` to `1`.
   - The tree now consists of vertices `1` and `2`, which is not a full binary tree. The binary depth should be `2` because adding one more vertex would form a full binary tree of depth `2`.

3. **Adding Vertex 3:**
   - Connect `3` to `1`.
   - The tree now consists of vertices `1`, `2`, and `3`.
   - This tree is not a full binary tree. The binary depth should be `2` because adding one more vertex would form a full binary tree of depth `2`.

4. **Adding Vertex 4:**
   - Connect `4` to `2`.
   - The tree now consists of vertices `1`, `2`, `3`, and `4`.
   - This tree is not a full binary tree. The binary depth should be `3` because adding three more vertices would form a full binary tree of depth `3`.

5. **Adding Vertex 5:**
   - Connect `5` to `2`.
   - The tree now consists of vertices `1`, `2`, `3`, `4`, and `5`.
   - This tree is not a full binary tree. The binary depth should be `3` because adding three more vertices would form a full binary tree of depth `3`.

The expected output for this test case is:
```
1 2 2 3 3
```

This test case is designed to be small and manageable while ensuring that the faulty logic in the buggy code is exposed. The tree structure is such that it does not form a full binary tree at any point, which should help in identifying issues with the depth calculation.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Iris's Full Binary Tree
time_limit_ms: 4000
memory_limit_mb: 1024
Description: Iris likes full binary trees.

Let's define the depth of a rooted tree as the maximum number of vertices on the simple paths from some vertex to the root. A full binary tree of depth $d$ is a binary tree of depth $d$ with exactly $2^d - 1$ vertices.

Iris calls a tree a $d$-binary tree if some vertices and edges can be added to it to make it a full binary tree of depth $d$. Note that any vertex can be chosen as the root of a full binary tree.

Since performing operations on large trees is difficult, she defines the binary depth of a tree as the minimum $d$ satisfying that the tree is $d$-binary. Specifically, if there is no integer $d \ge 1$ such that the tree is $d$-binary, the binary depth of the tree is $-1$.

Iris now has a tree consisting of only vertex $1$. She wants to add $n - 1$ more vertices to form a larger tree. She will add the vertices one by one. When she adds vertex $i$ ($2 \leq i \leq n$), she'll give you an integer $p_i$ ($1 \leq p_i < i$), and add a new edge connecting vertices $i$ and $p_i$.

Iris wants to ask you the binary depth of the tree formed by the first $i$ vertices for each $1 \le i \le n$. Can you tell her the answer?

Input: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2 \leq n \leq 5 \cdot 10^5$) — the final size of the tree.

The second line of each test case contains $n - 1$ integers $p_2, p_3, \ldots, p_n$ ($1 \leq p_i < i$) — descriptions of all edges of the tree.

It is guaranteed that the sum of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case output $n$ integers, $i$-th of them representing the binary depth of the tree formed by the first $i$ vertices.

Examples:
input:
7
3
1 1
6
1 2 3 4 5
7
1 1 3 2 5 1
10
1 1 2 1 4 2 4 5 8
10
1 1 3 1 3 2 2 2 6
20
1 1 2 2 4 4 5 5 7 6 8 6 11 14 11 8 13 13 12
25
1 1 3 3 1 5 4 4 6 8 11 12 8 7 11 13 7 13 15 6 19 14 10 23
output:
1 2 2
1 2 2 3 3 4
1 2 2 3 3 4 4
1 2 2 3 3 3 4 4 5 5
1 2 2 3 3 4 4 4 -1 -1
1 2 2 3 3 4 4 4 4 5 5 5 5 6 6 6 6 6 6 7
1 2 2 3 3 4 4 4 4 5 5 6 6 6 6 6 7 7 7 7 7 8 8 8 8

Note: In the first test case, the final tree is shown below:

![](CDN_BASE_URL/5045337022386beaeb8585d242e8d14a)

  * The tree consisting of the vertex $1$ has the binary depth $1$ (the tree itself is a full binary tree of depth $1$).    * The tree consisting of the vertices $1$ and $2$ has the binary depth $2$ (we can add the vertex $3$ to make it a full binary tree of depth $2$).    * The tree consisting of the vertices $1$, $2$ and $3$ has the binary depth $2$ (the tree itself is a full binary tree of depth $2$).

In the second test case, the formed full binary tree after adding some vertices to the tree consisting of $n$ vertices is shown below (bolded vertices are added):

![](CDN_BASE_URL/47a803b975dced95812a171507c56a8b)

The depth of the formed full binary tree is $4$.

In the fifth test case, the final tree is shown below:

![](CDN_BASE_URL/ffe91eb3e0db4e64598df8a805ba1e4a)

It can be proved that Iris can't form any full binary tree by adding vertices and edges, so the binary depth is $-1$.

Buggy Code:
#include<bits/stdc++.h>
using namespace std;

void dfs(int i, int depth, vector<vector<int>> &adj, vector<bool> &visited, vector<int> &order, vector<pair<int,int>> &idx){
		if(visited[i]) return;
		// cerr << i << " ";
		visited[i] = true;
		idx[i].first = order.size();
		order.push_back(depth);
		for(int c : adj[i]) dfs(c, depth + 1, adj, visited, order, idx);
		idx[i].second = order.size();
}

void update(vector<int> &order, int l, int r){
	for(int i = l; i < r; i++) order[i]++;
}

void u1(set<int> &m, int i, vector<vector<int>> &adj, vector<pair<int,int>> &idx, vector<int> &order){
	int mm = *m.begin();
	// cerr << mm << endl;
	if(idx[i].first < idx[mm].first || idx[mm].second < idx[i].first + 1){
		int to = adj[mm][0];
		m.insert(to);
		update(order, idx[mm].first, idx[mm].second);
		return;
	}
	for(int j = 0; j < adj[mm].size(); j++){
		int cur = adj[mm][j];
		if(cur < mm) continue;
		if(idx[cur].first - 1 < idx[i].first && idx[i].first < idx[cur].second) m.insert(cur);
		else update(order, idx[cur].first, idx[cur].second);
	}
	update(order, 0, idx[mm].first + 1);
	update(order, idx[mm].second, order.size());
}

void u2(set<int> &m, int i, vector<vector<int>> &adj, vector<pair<int,int>> &idx, vector<int> &order){
	int m1 = *m.begin(), m2 = *m.rbegin();
	// cerr << m1 << " " << m2 << endl;
	if(idx[m2].first - 1 < idx[i].first && idx[i].first < idx[m2].second){
		m.erase(m1);
		for(int j = 0; j < adj[m1].size(); j++){
			int cur = adj[m1][j];
			if(cur < m1) continue;
			if(cur == m2) continue;
			update(order, idx[cur].first, idx[cur].second);
		}
		update(order, 0, idx[m1].first + 1);
		update(order, idx[m1].second, order.size());
		return;
	}
	m.erase(m2);
	update(order, idx[m2].first, idx[m2].second);
	return;
}

void solve(){
	// Basic Approach
	// Once every vertex is added, run dfs from that vertex.
	// Update max distance based dfs. O(n)
	// Compute minimum. O(n)
	// Total complexity O(n^2)
	// Optimizing - All the nodes which get +1 are in a subtree.
	// One of the diameter endpoints must get a +1
	// If diameter root gets updated, then everything either on left or right gets updated.
	// How do we update the diameter connections - point towards furthest node?
	// I can dfs on the whole tree initially.
	// start - distance to node 1 from every node.
	// adding node 2 - all tree apart from subtree with node 2 get +1
	// if I create a new diameter, the midpoints don't change (one or two)
	// adding a vertex which increases the diameter
	// two midpoints to one - subtrees of vanishing midpoint increases.
	// one midpoint to two - the one midpoint and it's subtree increases.
	int n; cin >> n;
	vector<vector<int>> adj(n, vector<int>());
	for(int i = 0; i < n - 1; i++){
		int p; cin >> p;
		adj[p-1].push_back(i+1);
		adj[i+1].push_back(p-1);
	}

	vector<pair<int,int>> idx(n);
	vector<int> order;
	vector<bool> visited(n,false);
	dfs(0, 1, adj, visited, order, idx);
	// cerr << endl << endl;

	// for(int i : order) cerr << i << " ";
	// cerr << endl;

	int diam = order[0];
	bool can = true;
	vector<int> ans(1, order[0]), deg(n, 0);
	set<int> m({0});
	for(int i = 1; i < n; i++){
		deg[i] = 1;
		int p = adj[i][0];
		deg[p]++;
		if(deg[p] > 2) order[idx[p].first] = n + 1;
		if(deg[p] > 3) can = false;
		if(order[idx[i].first] > diam){
			diam++;
			if(m.size() == 1) u1(m, i, adj, idx, order);
			else u2(m, i, adj, idx, order);
		}
		// for(int j : order) cerr << j << " ";
		// cerr << endl;
		ans.push_back(n+1);
		for(int j = 0; j < i + 1; j++) ans.back() = min(ans.back(), order[idx[j].first]);
		if(n < ans.back() || !can) ans.back() = -1;
	}
	// cerr << endl;
	for(int &i : ans) cout << i << " ";
	cout << endl;
	// cerr << endl;
}

void testcases(){
	int t = 0;
	cin >> t;
	while(t--) solve();
}

int main() {
	cin.tie(nullptr);
	cout.tie(nullptr);
	ios::sync_with_stdio(false);
	testcases();
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
2
1
4
1 1 1
5
1 1 1 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Iris's Full Binary Tree
time_limit_ms: 4000
memory_limit_mb: 1024
Description: Iris likes full binary trees.

Let's define the depth of a rooted tree as the maximum number of vertices on the simple paths from some vertex to the root. A full binary tree of depth $d$ is a binary tree of depth $d$ with exactly $2^d - 1$ vertices.

Iris calls a tree a $d$-binary tree if some vertices and edges can be added to it to make it a full binary tree of depth $d$. Note that any vertex can be chosen as the root of a full binary tree.

Since performing operations on large trees is difficult, she defines the binary depth of a tree as the minimum $d$ satisfying that the tree is $d$-binary. Specifically, if there is no integer $d \ge 1$ such that the tree is $d$-binary, the binary depth of the tree is $-1$.

Iris now has a tree consisting of only vertex $1$. She wants to add $n - 1$ more vertices to form a larger tree. She will add the vertices one by one. When she adds vertex $i$ ($2 \leq i \leq n$), she'll give you an integer $p_i$ ($1 \leq p_i < i$), and add a new edge connecting vertices $i$ and $p_i$.

Iris wants to ask you the binary depth of the tree formed by the first $i$ vertices for each $1 \le i \le n$. Can you tell her the answer?

Input: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2 \leq n \leq 5 \cdot 10^5$) — the final size of the tree.

The second line of each test case contains $n - 1$ integers $p_2, p_3, \ldots, p_n$ ($1 \leq p_i < i$) — descriptions of all edges of the tree.

It is guaranteed that the sum of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case output $n$ integers, $i$-th of them representing the binary depth of the tree formed by the first $i$ vertices.

Examples:
input:
7
3
1 1
6
1 2 3 4 5
7
1 1 3 2 5 1
10
1 1 2 1 4 2 4 5 8
10
1 1 3 1 3 2 2 2 6
20
1 1 2 2 4 4 5 5 7 6 8 6 11 14 11 8 13 13 12
25
1 1 3 3 1 5 4 4 6 8 11 12 8 7 11 13 7 13 15 6 19 14 10 23
output:
1 2 2
1 2 2 3 3 4
1 2 2 3 3 4 4
1 2 2 3 3 3 4 4 5 5
1 2 2 3 3 4 4 4 -1 -1
1 2 2 3 3 4 4 4 4 5 5 5 5 6 6 6 6 6 6 7
1 2 2 3 3 4 4 4 4 5 5 6 6 6 6 6 7 7 7 7 7 8 8 8 8

Note: In the first test case, the final tree is shown below:

![](CDN_BASE_URL/5045337022386beaeb8585d242e8d14a)

  * The tree consisting of the vertex $1$ has the binary depth $1$ (the tree itself is a full binary tree of depth $1$).    * The tree consisting of the vertices $1$ and $2$ has the binary depth $2$ (we can add the vertex $3$ to make it a full binary tree of depth $2$).    * The tree consisting of the vertices $1$, $2$ and $3$ has the binary depth $2$ (the tree itself is a full binary tree of depth $2$).

In the second test case, the formed full binary tree after adding some vertices to the tree consisting of $n$ vertices is shown below (bolded vertices are added):

![](CDN_BASE_URL/47a803b975dced95812a171507c56a8b)

The depth of the formed full binary tree is $4$.

In the fifth test case, the final tree is shown below:

![](CDN_BASE_URL/ffe91eb3e0db4e64598df8a805ba1e4a)

It can be proved that Iris can't form any full binary tree by adding vertices and edges, so the binary depth is $-1$.

Buggy Code:
#include<bits/stdc++.h>
#define Pr pair<int,int>
#define fi first
#define nd second
#define psb push_back
using namespace std;
typedef long long LL;
inline int read(){
	char ch=getchar();
	while(!isdigit(ch) && ch!='-') ch=getchar();
	int x=0,ff=1; if(ch=='-') ff=-1,ch=getchar();
	while(isdigit(ch)) x=(x<<3) + (x<<1) + (ch^48),ch=getchar();
	return x*ff;
}
const int N=5e5+5,inf=1e9;
int n,p[N],b[N],ld[N],tot,son[N],fa[N],top[N],dep[N],sz[N],ru,rv,rds,ans,ind[N],gfa[N],rT; bool vis[N]; vector<int> e[N],kf[N],kd[N]; set<Pr> st[N];
void dfs1(int u,int Fa){
	sz[u]=1; fa[u]=Fa; dep[u]=dep[Fa]+1;
	for(int v:e[u]) if(v!=Fa){
		dfs1(v,u);  sz[u]+=sz[v];
		if(sz[v]>sz[son[u]]) son[u]=v;
	}
}
void dfs2(int u,int tpp){
	top[u]=tpp; b[ld[u]=++tot]=u;
	if(son[u]){
		dfs2(son[u],tpp);
		for(int v:e[u]) if(v!=son[u] && v!=fa[u]) dfs2(v,v);
	}
}
int LCA(int u,int v){
	while(top[u]!=top[v]){
		if(dep[top[u]]<dep[top[v]]) swap(u,v);
		u=fa[top[u]];
	} return dep[u]<dep[v]?u:v;
}
int K_fa(int u,int kx){
	kx=dep[u]-kx; while(dep[top[u]]>kx) u=fa[top[u]];
	return b[ld[u]-dep[u]+kx];
}
int gdis(int x,int y) {return dep[x]+dep[y]-2*dep[LCA(x,y)];}
void getrt(int u,int Fa,int S){
	sz[u]=1; int mx=0;
	for(int v:e[u]) if(v!=Fa && !vis[v]) {
		getrt(v,u,S); sz[u]+=sz[v];
		mx=max(mx,sz[v]);
	} mx=max(mx,S-sz[u]); rT=mx*2<=S?u:rT;
}
void rdfs(int u,int Fa,int d,int gf){
    kf[u].psb(gf); kd[u].psb(d);
    for(int v:e[u]) if(v!=Fa && v!=Fa) rdfs(v,u,d+1,gf);
}
void dfz(int u,int Fa,int S){
	getrt(u,0,S); u=rT; gfa[u]=Fa; vis[u]=1; rdfs(u,0,0,u); getrt(u,0,S);
	for(int v:e[u]) if(!vis[v]) dfz(v,u,sz[v]);
}
void addx(int x,int o){
    int len=kf[x].size(),u;
    for(int i=len-1;i>=0;i--){
        u=kf[x][i]; Pr bf={kd[x][i],x};
		if(o) st[u].insert(bf);
		else st[u].erase(bf);
    }
}
int qry(int x){
	int len=kf[x].size(),u; Pr z={inf,0};
	for(int i=len-1;i>=0;i--){ u=kf[x][i];
		if(st[u].size()){
			Pr bf=*st[u].begin(); bf.fi+=kd[x][i];
			z=min(z,bf);
		}
	} return z.nd;
}
void vmain(){
	n=read(); tot=0; for(int i=1;i<=n;i++) son[i]=ind[i]=gfa[i]=vis[i]=0,e[i].clear(),st[i].clear(),kd[i].clear(),kf[i].clear();
	for(int i=2;i<=n;i++) p[i]=read(),e[p[i]].push_back(i),e[i].push_back(p[i]);
	dfs1(1,0); dfs2(1,1); dfz(1,0,n); ans=0;
	for(int i=1;i<=n;i++){
		if(~ans){
			addx(i,1);
			if(i==1) ans=1,ru=rv=1,rds=0;
			else { int x=p[i]; ++ind[x]; ind[i]=1;
				if(ind[x]<=3){
					if(ind[x]==3) addx(x,0);
					if(gdis(ru,i)>rds) ++rds,rv=i;
					if(gdis(rv,i)>rds) ++rds,ru=i;
					int lc=LCA(ru,rv),px=0,z=rds/2; px=(z<=dep[ru]-dep[lc])?K_fa(ru,z):K_fa(rv,rds-z);
					px=qry(px); ans=max(gdis(ru,px),gdis(rv,px))+1;
					if(rds&1){
						++z; px=(z<=dep[ru]-dep[lc])?K_fa(ru,z):K_fa(rv,rds-z); px=qry(px);
						ans=min(ans,max(gdis(ru,px),gdis(rv,px))+1);
					}
				} else ans=-1;
			}
		}
		printf("%d ",ans);
	} puts("");
}
int main(){
	int T=read(); while(T--) vmain();
	return 0;
}
/*
g++ 1.cpp -o 1 -std=c++20 -Wall -Wl,-stack=999999999
*/

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
5
1 1 3 3
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Iris's Full Binary Tree
time_limit_ms: 4000
memory_limit_mb: 1024
Description: Iris likes full binary trees.

Let's define the depth of a rooted tree as the maximum number of vertices on the simple paths from some vertex to the root. A full binary tree of depth $d$ is a binary tree of depth $d$ with exactly $2^d - 1$ vertices.

Iris calls a tree a $d$-binary tree if some vertices and edges can be added to it to make it a full binary tree of depth $d$. Note that any vertex can be chosen as the root of a full binary tree.

Since performing operations on large trees is difficult, she defines the binary depth of a tree as the minimum $d$ satisfying that the tree is $d$-binary. Specifically, if there is no integer $d \ge 1$ such that the tree is $d$-binary, the binary depth of the tree is $-1$.

Iris now has a tree consisting of only vertex $1$. She wants to add $n - 1$ more vertices to form a larger tree. She will add the vertices one by one. When she adds vertex $i$ ($2 \leq i \leq n$), she'll give you an integer $p_i$ ($1 \leq p_i < i$), and add a new edge connecting vertices $i$ and $p_i$.

Iris wants to ask you the binary depth of the tree formed by the first $i$ vertices for each $1 \le i \le n$. Can you tell her the answer?

Input: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2 \leq n \leq 5 \cdot 10^5$) — the final size of the tree.

The second line of each test case contains $n - 1$ integers $p_2, p_3, \ldots, p_n$ ($1 \leq p_i < i$) — descriptions of all edges of the tree.

It is guaranteed that the sum of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case output $n$ integers, $i$-th of them representing the binary depth of the tree formed by the first $i$ vertices.

Examples:
input:
7
3
1 1
6
1 2 3 4 5
7
1 1 3 2 5 1
10
1 1 2 1 4 2 4 5 8
10
1 1 3 1 3 2 2 2 6
20
1 1 2 2 4 4 5 5 7 6 8 6 11 14 11 8 13 13 12
25
1 1 3 3 1 5 4 4 6 8 11 12 8 7 11 13 7 13 15 6 19 14 10 23
output:
1 2 2
1 2 2 3 3 4
1 2 2 3 3 4 4
1 2 2 3 3 3 4 4 5 5
1 2 2 3 3 4 4 4 -1 -1
1 2 2 3 3 4 4 4 4 5 5 5 5 6 6 6 6 6 6 7
1 2 2 3 3 4 4 4 4 5 5 6 6 6 6 6 7 7 7 7 7 8 8 8 8

Note: In the first test case, the final tree is shown below:

![](CDN_BASE_URL/5045337022386beaeb8585d242e8d14a)

  * The tree consisting of the vertex $1$ has the binary depth $1$ (the tree itself is a full binary tree of depth $1$).    * The tree consisting of the vertices $1$ and $2$ has the binary depth $2$ (we can add the vertex $3$ to make it a full binary tree of depth $2$).    * The tree consisting of the vertices $1$, $2$ and $3$ has the binary depth $2$ (the tree itself is a full binary tree of depth $2$).

In the second test case, the formed full binary tree after adding some vertices to the tree consisting of $n$ vertices is shown below (bolded vertices are added):

![](CDN_BASE_URL/47a803b975dced95812a171507c56a8b)

The depth of the formed full binary tree is $4$.

In the fifth test case, the final tree is shown below:

![](CDN_BASE_URL/ffe91eb3e0db4e64598df8a805ba1e4a)

It can be proved that Iris can't form any full binary tree by adding vertices and edges, so the binary depth is $-1$.

Buggy Code:
// Author: YE Minghan
#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "templates/debug.h"
#else
#define dbg(...) (void)0
#define msg(...) (void)0
#endif
#define ll long long
#define endl '\n'
#define PB emplace_back
#define PPB pop_back
#define MP make_pair
#define ALL(Name) Name.begin(),Name.end()
#define PII pair<int,int>
#define VI vector<int>
#define GI greater<int>
#define fi first
#define se second

const int N=500005,L=20,inf=1e9;
int n,f[N<<1][L],dep[N],dfn[N],ed[N],df,deg[N];
VI g[N<<1];

void dfs(int x)
{
	dfn[x]=++df,dep[x]=dep[f[x][0]]+1;
	for(int i=1;i<L;i++)f[x][i]=f[f[x][i-1]][i-1];
	for(int y:g[x])dfs(y);
	ed[x]=df;
}
int anc(int x,int k)
{
	while(k){int t=__builtin_ctz(k);k^=1<<t,x=f[x][t];}
	return x;
}
int lca(int x,int y)
{
	if(dep[x]>dep[y])swap(x,y);
	y=anc(y,dep[y]-dep[x]);
	if(x==y)return x;
	for(int i=L-1;~i;i--)
		if(f[x][i]!=f[y][i])x=f[x][i],y=f[y][i];
	return f[x][0];
}
int dis(int x,int y){return dep[x]+dep[y]-(dep[lca(x,y)]<<1);}

struct info
{
	int add,mn;
}tr[1<<21];
#define lid id<<1
#define rid lid|1
#define mid (l+r>>1)
#define rmd (mid+1)
void atg(int id,int v){tr[id].add+=v,tr[id].mn+=v;}
void push_down(int id)
{
	atg(lid,tr[id].add),atg(rid,tr[id].add);
	tr[id].add=0;
}
void add(int L,int R,int v,int l=1,int r=(n<<1)-1,int id=1)
{
	if(L==l&&R==r)return atg(id,v);
	push_down(id);
	if(L<=mid)add(L,min(R,mid),v,l,mid,lid);
	if(R>=rmd)add(max(L,rmd),R,v,rmd,r,rid);
	tr[id].mn=min(tr[lid].mn,tr[rid].mn);
}
int mn(){return tr[1].mn;}

int main()
{
	ios::sync_with_stdio(false),cin.tie(nullptr);
	int _;cin>>_;while(_--)
{
	cin>>n;
	for(int i=2;i<=n;i++)cin>>f[n+i-1][0],f[i][0]=n+i-1,g[f[n+i-1][0]].PB(n+i-1),g[n+i-1].PB(i);
	dfs(1);
	add(2,(n<<1)-1,inf);
	cout<<"1 ";
	int x=1,y=1,z=1,d=0;
	bool bang=0;
	for(int i=2;i<=n;i++)
	{
		deg[i]++,add(dfn[i],dfn[i],dis(i,1)-inf);
		if(++deg[f[i][1]]==3)add(dfn[f[i][1]],dfn[f[i][1]],inf);
		if(deg[f[i][1]]>3)bang=1;
		if(bang){cout<<-1<<" \n"[i==n];continue;}
		int b=dis(i,x),c=dis(i,y);
		d=max({b,c,d});
		if(b==d)y=i;
		else if(c==d)x=i;
		int m=anc(dep[x]>dep[y]?x:y,d>>1);
		if(dep[z]>dep[m])add(1,(n<<1)-1,-1),add(dfn[z],ed[z],2);
		if(dep[z]<dep[m])add(1,(n<<1)-1,1),add(dfn[m],ed[m],-2);
		z=m;
		cout<<((d>>1)+mn()>>1)+1<<" \n"[i==n];
	}
	fill(deg+1,deg+n+1,0),df=0,fill(g+1,g+(n<<1),VI());
	memset(tr+1,0,sizeof(info)<<33-__builtin_clz(n-1<<1));
}

	return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
4
1 1 2
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Iris's Full Binary Tree
time_limit_ms: 4000
memory_limit_mb: 1024
Description: Iris likes full binary trees.

Let's define the depth of a rooted tree as the maximum number of vertices on the simple paths from some vertex to the root. A full binary tree of depth $d$ is a binary tree of depth $d$ with exactly $2^d - 1$ vertices.

Iris calls a tree a $d$-binary tree if some vertices and edges can be added to it to make it a full binary tree of depth $d$. Note that any vertex can be chosen as the root of a full binary tree.

Since performing operations on large trees is difficult, she defines the binary depth of a tree as the minimum $d$ satisfying that the tree is $d$-binary. Specifically, if there is no integer $d \ge 1$ such that the tree is $d$-binary, the binary depth of the tree is $-1$.

Iris now has a tree consisting of only vertex $1$. She wants to add $n - 1$ more vertices to form a larger tree. She will add the vertices one by one. When she adds vertex $i$ ($2 \leq i \leq n$), she'll give you an integer $p_i$ ($1 \leq p_i < i$), and add a new edge connecting vertices $i$ and $p_i$.

Iris wants to ask you the binary depth of the tree formed by the first $i$ vertices for each $1 \le i \le n$. Can you tell her the answer?

Input: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2 \leq n \leq 5 \cdot 10^5$) — the final size of the tree.

The second line of each test case contains $n - 1$ integers $p_2, p_3, \ldots, p_n$ ($1 \leq p_i < i$) — descriptions of all edges of the tree.

It is guaranteed that the sum of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case output $n$ integers, $i$-th of them representing the binary depth of the tree formed by the first $i$ vertices.

Examples:
input:
7
3
1 1
6
1 2 3 4 5
7
1 1 3 2 5 1
10
1 1 2 1 4 2 4 5 8
10
1 1 3 1 3 2 2 2 6
20
1 1 2 2 4 4 5 5 7 6 8 6 11 14 11 8 13 13 12
25
1 1 3 3 1 5 4 4 6 8 11 12 8 7 11 13 7 13 15 6 19 14 10 23
output:
1 2 2
1 2 2 3 3 4
1 2 2 3 3 4 4
1 2 2 3 3 3 4 4 5 5
1 2 2 3 3 4 4 4 -1 -1
1 2 2 3 3 4 4 4 4 5 5 5 5 6 6 6 6 6 6 7
1 2 2 3 3 4 4 4 4 5 5 6 6 6 6 6 7 7 7 7 7 8 8 8 8

Note: In the first test case, the final tree is shown below:

![](CDN_BASE_URL/5045337022386beaeb8585d242e8d14a)

  * The tree consisting of the vertex $1$ has the binary depth $1$ (the tree itself is a full binary tree of depth $1$).    * The tree consisting of the vertices $1$ and $2$ has the binary depth $2$ (we can add the vertex $3$ to make it a full binary tree of depth $2$).    * The tree consisting of the vertices $1$, $2$ and $3$ has the binary depth $2$ (the tree itself is a full binary tree of depth $2$).

In the second test case, the formed full binary tree after adding some vertices to the tree consisting of $n$ vertices is shown below (bolded vertices are added):

![](CDN_BASE_URL/47a803b975dced95812a171507c56a8b)

The depth of the formed full binary tree is $4$.

In the fifth test case, the final tree is shown below:

![](CDN_BASE_URL/ffe91eb3e0db4e64598df8a805ba1e4a)

It can be proved that Iris can't form any full binary tree by adding vertices and edges, so the binary depth is $-1$.

Buggy Code:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define N 500000

int i,j,k,n,m,t,dfn[N+50],it,fa[N+50],in[N+50],mx;
basic_string<int> v[N+50];
int dep[N+50];

struct SB{
	int i,j,k,n;
	int f[21][N+50];
	int _get(int l,int r){
		return (dfn[l]<dfn[r]?l:r);
	}
	void init(int nn){
		n=nn;
		for(i=1;i<=20;i++)for(j=1;j+(1<<i)-1<=n;j++)f[i][j]=_get(f[i-1][j],f[i-1][j+(1<<(i-1))]);
	}
	int lca(int l,int r){
		if(l==r)return l;
		l=dfn[l]; r=dfn[r]; if(l>r)swap(l,r);
		l++; int k=__lg(r-l+1);
		return _get(f[k][l],f[k][r-(1<<k)+1]);
	}
	int dis(int x,int y){
		int z=lca(x,y);
		return dep[x]+dep[y]-2*dep[z];
	}
}sb;

void dfs0(int x){
	dfn[x]=++it; sb.f[0][it]=fa[x];
	for(auto i:v[x])dfs0(i);
}

struct JB{
	int x,y,w;
}f,tmp;

JB hb(JB x,JB y){
	auto [x1,y1,w1]=x;
	auto [x2,y2,w2]=y;
	vector<int> v={x1,y1,x2,y2};
	int rx=0,ry=0,rw=-1,k;
	for(int i=0;i<4;i++)for(int j=i+1;j<4;j++){
		k=sb.dis(v[i],v[j]);
		if(k>rw){rw=k; rx=v[i]; ry=v[j];}
	}
	return {rx,ry,rw};
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>t;
	while(t--){
		cin>>n; it=0; mx=0;
		for(i=2;i<=n;i++){
			cin>>fa[i];
			v[fa[i]]+=i; dep[i]=dep[fa[i]]+1;
		}
		dfs0(1); sb.init(n);

		f={1,1,0};
		cout<<"1 ";
		for(i=2;i<=n;i++){
			in[fa[i]]++; in[i]++;
			mx=max({mx,in[fa[i]],in[i]});
			if(mx>=4){cout<<-1<<' '; continue;}
			tmp={i,i,0};
			f=hb(f,tmp);

			int res=1e9;
			for(j=1;j<=i;j++)if(in[j]<=2){
				res=min(res,max(sb.dis(f.x,j),sb.dis(f.y,j))+1);
			}
			if(res>1e8)res=-1;
			cout<<res<<' ';
		}
		cout<<'\n';

		for(i=1;i<=n;i++){
			v[i]={}; in[i]=0;
		}
	}
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
2
4
1 2 1
5
1 2 2 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Iris's Full Binary Tree
time_limit_ms: 4000
memory_limit_mb: 1024
Description: Iris likes full binary trees.

Let's define the depth of a rooted tree as the maximum number of vertices on the simple paths from some vertex to the root. A full binary tree of depth $d$ is a binary tree of depth $d$ with exactly $2^d - 1$ vertices.

Iris calls a tree a $d$-binary tree if some vertices and edges can be added to it to make it a full binary tree of depth $d$. Note that any vertex can be chosen as the root of a full binary tree.

Since performing operations on large trees is difficult, she defines the binary depth of a tree as the minimum $d$ satisfying that the tree is $d$-binary. Specifically, if there is no integer $d \ge 1$ such that the tree is $d$-binary, the binary depth of the tree is $-1$.

Iris now has a tree consisting of only vertex $1$. She wants to add $n - 1$ more vertices to form a larger tree. She will add the vertices one by one. When she adds vertex $i$ ($2 \leq i \leq n$), she'll give you an integer $p_i$ ($1 \leq p_i < i$), and add a new edge connecting vertices $i$ and $p_i$.

Iris wants to ask you the binary depth of the tree formed by the first $i$ vertices for each $1 \le i \le n$. Can you tell her the answer?

Input: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2 \leq n \leq 5 \cdot 10^5$) — the final size of the tree.

The second line of each test case contains $n - 1$ integers $p_2, p_3, \ldots, p_n$ ($1 \leq p_i < i$) — descriptions of all edges of the tree.

It is guaranteed that the sum of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case output $n$ integers, $i$-th of them representing the binary depth of the tree formed by the first $i$ vertices.

Examples:
input:
7
3
1 1
6
1 2 3 4 5
7
1 1 3 2 5 1
10
1 1 2 1 4 2 4 5 8
10
1 1 3 1 3 2 2 2 6
20
1 1 2 2 4 4 5 5 7 6 8 6 11 14 11 8 13 13 12
25
1 1 3 3 1 5 4 4 6 8 11 12 8 7 11 13 7 13 15 6 19 14 10 23
output:
1 2 2
1 2 2 3 3 4
1 2 2 3 3 4 4
1 2 2 3 3 3 4 4 5 5
1 2 2 3 3 4 4 4 -1 -1
1 2 2 3 3 4 4 4 4 5 5 5 5 6 6 6 6 6 6 7
1 2 2 3 3 4 4 4 4 5 5 6 6 6 6 6 7 7 7 7 7 8 8 8 8

Note: In the first test case, the final tree is shown below:

![](CDN_BASE_URL/5045337022386beaeb8585d242e8d14a)

  * The tree consisting of the vertex $1$ has the binary depth $1$ (the tree itself is a full binary tree of depth $1$).    * The tree consisting of the vertices $1$ and $2$ has the binary depth $2$ (we can add the vertex $3$ to make it a full binary tree of depth $2$).    * The tree consisting of the vertices $1$, $2$ and $3$ has the binary depth $2$ (the tree itself is a full binary tree of depth $2$).

In the second test case, the formed full binary tree after adding some vertices to the tree consisting of $n$ vertices is shown below (bolded vertices are added):

![](CDN_BASE_URL/47a803b975dced95812a171507c56a8b)

The depth of the formed full binary tree is $4$.

In the fifth test case, the final tree is shown below:

![](CDN_BASE_URL/ffe91eb3e0db4e64598df8a805ba1e4a)

It can be proved that Iris can't form any full binary tree by adding vertices and edges, so the binary depth is $-1$.

Buggy Code:
#include<bits/stdc++.h>
using namespace std;
#define int         long long
#define pii         pair<int,int>
#define all(v)      v.begin(),v.end()
#define pb          push_back
#define REP(i,b,e)  for(int i=(b);i<(int)(e);++i)
#define over(x)     {cout<<(x)<<endl;return;}
struct ds{
	int seg[2000005],tag[2000005];
	void build(int l,int r,int p){
		seg[p]=(l==0? 0:1e18),tag[p]=0;
		if(l==r)return;
		int m=(l+r)>>1;
		build(l,m,p*2+1);build(m+1,r,p*2+2);
	}
	void pushdown(int p){
		if(!tag[p])return;
		tag[p*2+1]+=tag[p];tag[p*2+2]+=tag[p];
		seg[p*2+1]+=tag[p];seg[p*2+2]+=tag[p];
		tag[p]=0;
	}
	void add(int l,int r,int s,int t,int p,int val){
		if(l<=s&&t<=r){
			seg[p]+=val;tag[p]+=val;
			return;
		}
		int m=(s+t)>>1;pushdown(p);
		if(m>=l)add(l,r,s,m,p*2+1,val);
		if(m<r)add(l,r,m+1,t,p*2+2,val);
		seg[p]=min(seg[p*2+1],seg[p*2+2]);
	}
	void update(int pos,int l,int r,int p,int val){
		if(l==r){
			seg[p]=val;
			return;
		}
		int m=(l+r)>>1;pushdown(p);
		if(m>=pos)update(pos,l,m,p*2+1,val);
		else update(pos,m+1,r,p*2+2,val);
		seg[p]=min(seg[p*2+1],seg[p*2+2]);
	}
}seg;
int n;
vector<int>v[500005];
int fa[500005],an[500005][21];
int dep[500005],dfn[500005],rev[500005];
int tot,deg[500005],ls[500005];
void dfs(int x,int pre,int d){
	dep[x]=d;fa[x]=pre;an[x][0]=fa[x];ls[x]=1;
	REP(i,0,__lg(n+1))if(an[x][i]==-1)an[x][i+1]=-1;else an[x][i+1]=an[an[x][i]][i];
	rev[tot]=x;dfn[x]=tot++;
	for(auto i:v[x])dfs(i,x,d+1),ls[x]+=ls[i];
}
int getlca(int x,int y){
	if(dep[x]<dep[y])swap(x,y);
	int d=dep[x]-dep[y];
	for(int i=__lg(d);i>=0;--i)if((d>>i)&1)x=an[x][i];
	if(x==y)return x;
	d=dep[x];
	for(int i=__lg(d);i>=0;--i)if((1<<i)<=dep[x]&&an[x][i]!=an[y][i])x=an[x][i],y=an[y][i];
	return fa[x];
}
int getan(int x,int y){
	if(dfn[y]>=dfn[x]&&dfn[y]<=ls[x]){
		int d=dep[y]-dep[x]-1;
		for(int i=0;(1<<i)<=d;++i)if((d>>i)&1)y=an[y][i];
		return y;
	}else return fa[x];
}
void updside(int x,int y){
	if(dfn[y]>=dfn[x]&&dfn[y]<=ls[x]){
		seg.add(0,n-1,0,n-1,0,1);
		x=getan(x,y);
		seg.add(dfn[x],ls[x],0,n-1,0,-1);
	}else seg.add(dfn[x],ls[x],0,n-1,0,1);
}
int getdist(int x,int y){return dep[x]+dep[y]-2*dep[getlca(x,y)];}
struct diameter{
	int x,y,len;
	int update(int z){
		if(x==y){
			int d=getdist(x,z);
			if(d<=len)return d+len;
			updside(y,z);
			y=getan(y,z);
			return d+len;
		}else{
			int d1=getdist(x,z),d2=getdist(y,z),d3=min(d1,d2);
			if(d3<=len)return d3+len+1;
			if(d1>d2)swap(x,y);
			updside(y,z);
			y=x;++len;return len*2;
		}
	}
	int query(int z){
		if(x==y)return len+getdist(x,z);
		else return len+min(getdist(x,z),getdist(y,z))+1;
	}
};
void Main() {
	cin>>n;
	REP(i,0,n)v[i].clear();
	REP(i,1,n){
		cin>>fa[i];--fa[i];
		v[fa[i]].pb(i);
	}
	tot=0;dfs(0,-1,0);seg.build(0,n-1,0);
	REP(i,0,n)deg[i]=0,ls[i]+=dfn[i]-1;
	diameter d={0,0,0};
	cout<<"1 ";
	REP(i,1,n){
		++deg[fa[i]];++deg[i];
		if(deg[fa[i]]==4){
			REP(j,i,n)cout<<-1<<' ';
			cout<<endl;return;
		}
		if(deg[fa[i]]==3)seg.update(dfn[fa[i]],0,n-1,0,1e18);
		seg.update(dfn[i],0,n-1,0,d.update(i));
		cout<<seg.seg[0]+1<<' ';
	}
	cout<<endl;
}
void TC() {
    int tc=1;
    cin>>tc;
	while(tc--){
		Main();
		cout.flush();
	}
}
signed main() {
	return cin.tie(0),cout.tie(0),ios::sync_with_stdio(0),TC(),0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the provided code, we need to focus on edge cases where the binary depth of the tree might be incorrectly calculated. The code uses a segment tree and dynamic programming to maintain the tree's structure and compute the binary depth. The key points to consider are:

1. **Tree Structure**: The tree should have a structure that makes it difficult to form a full binary tree.
2. **Edge Cases**: The tree should have vertices with high degrees, especially vertices with degree 3 or 4, which the code handles specifically.
3. **Dynamic Changes**: The tree should evolve in a way that the binary depth changes non-trivially as vertices are added.

Let's construct a test case that meets these criteria:

1. **Initial Tree**: Start with a simple tree and add vertices in a way that maximizes the difficulty of forming a full binary tree.
2. **High Degree Vertices**: Ensure there are vertices with degree 3 or 4.
3. **Non-Trivial Changes**: The binary depth should change significantly as vertices are added.

Here is a small-scale test input that meets these criteria:

```plaintext
1
7
1 1 2 2 4 4
```

Explanation:
- The tree starts with vertex 1.
- Vertex 2 and 3 are added as children of vertex 1.
- Vertex 4 and 5 are added as children of vertex 2.
- Vertex 6 and 7 are added as children of vertex 4.

This structure ensures:
- Vertex 1 has degree 2.
- Vertex 2 has degree 3.
- Vertex 4 has degree 3.
- The tree evolves in a way that makes it difficult to form a full binary tree, especially after adding vertex 4 and its children.

This test case should expose the bug in the code, particularly in handling vertices with high degrees and the dynamic changes in the binary depth.