#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  long long int arr[n][5];
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < 5; j++) {
      cin >> arr[i][j];
    }
  }
  if (n == 1) {
    cout << 1 << endl;
    return;
  }
  long long int k = 0, i = 1;
  while (i < n) {
    long long int cnt = 0;
    long long int j = 0;
    while (j < 5) {
      if (arr[i][j] < arr[k][j]) cnt++;
      j++;
    }
    if (cnt >= 3) k = i;
    i++;
  }
  long long int f = 1;
  long long int l = 0;
  while (l < n) {
    long long int c = 0;
    if (l != k) {
      for (long long int j = 0; j < 5; j++) {
        c = (arr[k][j] < arr[l][j]) ? c + 1 : c;
      }
      if (c < 3) f = 0;
    }
    l++;
  }
  if (f) {
    cout << k + 1 << endl;
  } else
    cout << -1 << endl;
}
int32_t main() {
  long long int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
