using namespace std;

void startgame()

{

```
int I, N, Q;
cin >> I;
cin >> N;
cin >> Q;
vector<string> arr;
if (I == 1)
{
arr = vector<string>(N, "H");
}
else
{
arr = vector<string>(N, "T");
}
//log
/* cout << "array before change"
<< "\n";
for (int i = 0; i < arr.size(); i++)
{
cout << arr[i] << "\t";
} */
//log end
int arrIndex = 0;
for (int j = N; j > 0; --j)
{
if (j % 2 > 0)
{
if (arr[arrIndex] == "H")
{
arr.at(arrIndex) = "T";
}
else
{
arr.at(arrIndex) = "H";
}
}
arrIndex = arrIndex + 1;
}
//log
/* cout << "\narray after change"
<< "\n";
for (int i = 0; i < arr.size(); i++)
{
cout << arr[i] << "\t";
} */
//log end
int result = 0;
if (Q == 1)
{
for (int i = 0; i < arr.size(); i++)
{
if (arr[i] == "H")
{
result = result + 1;
}
}
}
else
{
for (int i = 0; i < arr.size(); i++)
{
if (arr[i] == "T")
{
result = result + 1;
}
}
}
cout << result << "\n";
```

}

void solve()

{

```
int G;
cin >> G;
while (G--)
{
startgame();
}
```

}

int main()

{

```
int T;
cin >> T;
while (T--)
{
solve();
}
```

}