#include <iostream>
/**2018数据结构实验3.2**/
#include <string>
#include <cstring>
using namespace std;
struct Node
{
int data;
Node *left_tree;
Node *right_tree;
}node, *root;
//插入元素
bool Insert(Node *&r, int a)
{
if (r == NULL)
{
r = new Node;
r->data = a;
r->left_tree = NULL;
r->right_tree = NULL;
return true;
}
if (r->data < a || r->data == a)
{
return Insert(r->right_tree, a);
}
if (r->data > a)
{
return Insert(r->left_tree, a);
}
return true;
}
//借助insert建立树
bool Build(Node * &r, int a[], int k)
{
if (k == 0)return false;
r = NULL;
int i = 0;
for (i; i < k; i++)
{
Insert(r, a[i]);
}
return true;
}
//查找树的高度
int findHeight(Node*& T)
{
if (T == NULL) return 0;
else
{
int m = findHeight(T->left_tree);
int n = findHeight(T->right_tree);
return (m > n) ? (m + 1) : (n + 1);
}
}
int main()
{
int i = 0, data,nn;
cin >> nn;
int k[20] = { 0 };
int arr[20][100];
for (int x = 0; x < nn; x++)
{
while (cin >> data)
{
arr[x][i++] = data;
k[x]++;
if (cin.get() == '\n')break;
}
i = 0;
}
root = new Node;
for (int x = 0; x < nn; x++)
{
Build(root, arr[x], k[x]);
int h = findHeight(root);
cout << h << endl;
root = new Node;
}
return 0;
}