#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &os, const pair<T, T> &p) {
  return os << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, const pair<const T, T> &p) {
  return os << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, const array<T, 3> &p) {
  return os << "(" << p[0] << "," << p[1] << "," << p[2] << ")";
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &p) {
  for (auto x : p) os << x << ' ';
  return os;
}
const double EPS = 1e-9, PI = acos(-1);
const long long LINF = 0x3f3f3f3f3f3f3f3f, mod = 1e9 + 7;
const long long INF = 0x3f3f3f3f, SZ = 2e5 + 20;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long q;
  cin >> q;
  while (q--) {
    long long x, y, k;
    cin >> x >> y >> k;
    long long mini = min(x, y);
    long long extra = abs(x - y);
    if (max(x, y) > k) {
      cout << -1 << '\n';
      continue;
    }
    if (x == y) {
      k -= x - mini;
      k -= y - mini;
      if ((mini & 1) == (k & 1))
        cout << k << '\n';
      else
        cout << k - 2 << '\n';
    } else {
      if (((k - extra) & 1) == (mini & 1)) {
        cout << k - extra + (extra & 1 ? extra - 1 : extra) << '\n';
      } else {
        if (extra & 1)
          cout << k - 1 << '\n';
        else
          cout << k - 2 << '\n';
      }
    }
  }
  return 0;
}
