#include <iostream> #include <math.h> #include <vector> using namespace std; int main()
{ int total_line;  int vector_x;  int vector_y;  int step_number;  cin >> total_line;  vector<int>step;  for (int i = 0; i < total_line; ++i)
    { int temp;  cin >> vector_x >> vector_y >> step_number;  ///全部丢到第一象限  vector_x = abs(vector_x);  vector_y = abs(vector_y);  ///横纵坐标一样的时候,步数小于横纵坐标是不能走到的,步数大于等于横纵坐标时候,可以反复走重复路径//还得考虑奇偶数情况  if(vector_x == vector_y)
        { if(step_number < vector_x)
            {
                temp = -1;  step.push_back(temp);  } if(step_number >= vector_x)
            { int temp_diffrence;  temp_diffrence = step_number - vector_x;  if(temp_diffrence % 2 == 0)
                {
                    step.push_back(step_number);  } else  {
                    step.push_back(step_number-2);  }
            }
        } ////////vector_x和vector_y不一样的时候  if(vector_x != vector_y)
        { int temp_min;  int temp_max;  int temp_diff;  int temp_sum;  temp_min = min(vector_x,vector_y);  temp_max = max(vector_x,vector_y);  temp_diff = temp_max - temp_min;  temp_sum = temp_diff + temp_min;  //走到一条边之后直接走直线到终点所需要的步数  int temp_steps = temp_min; //走斜线,最小的那个正方形,便可以走到正方形的一条边上  ///到达不了终点的情况  if(step_number < temp_sum)
            {
                temp = -1;  step.push_back(temp);  } ///步数先走最小正方形后,再走直线刚好到终点的情况,讨论直线可以变为斜线的情况  if(step_number == temp_sum)
            { if(temp_diff % 2 == 0)
                {
                    step.push_back(step_number);  } else  {
                    step.push_back(step_number-1);  }
            } ///步数先走完最小正方形后,再走直线到达终点步数小于给出步数的情况,考虑反复走  if(step_number > temp_sum)
            { if(temp_max % 2 == 0)
                { if(temp_min % 2 == 0)
                    { if((step_number-temp_max) % 2 == 0)
                        {
                            step.push_back(step_number);  } else  {
                            step.push_back(step_number-2);  }
                    } else  {
                        step.push_back(step_number-1);  }
                } else  { if(temp_min % 2 == 0)
                    {
                        step.push_back(step_number-1);  } else  { if((step_number-temp_max) % 2 == 0)
                       {
                           step.push_back(step_number);  } else  {
                           step.push_back(step_number-2);  }
                    }
                }
            }
        }
    } for (int j = 0; j < step.size(); ++j)
    {
        cout << step[j] << endl;  } return 0; }