description: The Olympic Games have just started and Federico is eager to watch the marathon race.
  
  There will be n athletes, numbered from 1 to n, competing in the marathon, and all of them have taken part in 5 important marathons, numbered from 1 to 5, in the past. For each 1≤ i≤ n and 1≤ j≤ 5, Federico remembers that athlete i ranked r_{i,j}-th in marathon j (e.g., r_{2,4}=3 means that athlete 2 was third in marathon 4).
  
  Federico considers athlete x superior to athlete y if athlete x ranked better than athlete y in at least 3 past marathons, i.e., r_{x,j}<r_{y,j} for at least 3 distinct values of j.
  
  Federico believes that an athlete is likely to get the gold medal at the Olympics if he is superior to all other athletes.
  
  Find any athlete who is likely to get the gold medal (that is, an athlete who is superior to all other athletes), or determine that there is no such athlete.
  
  Input
  
  The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow.
  
  The first line of each test case contains a single integer n (1≤ n≤ 50 000) — the number of athletes.
  
  Then n lines follow, each describing the ranking positions of one athlete.
  
  The i-th of these lines contains the 5 integers r_{i,1},\,r_{i,2},\,r_{i,3},\,r_{i,4},  r_{i,5} (1≤ r_{i,j}≤ 50 000) — the ranking positions of athlete i in the past 5 marathons. It is guaranteed that, in each of the 5 past marathons, the n athletes have distinct ranking positions, i.e., for each 1≤ j≤ 5, the n values r_{1,j},  r_{2, j},  ...,  r_{n, j} are distinct.
  
  It is guaranteed that the sum of n over all test cases does not exceed 50 000.
  
  Output
  
  For each test case, print a single integer — the number of an athlete who is likely to get the gold medal (that is, an athlete who is superior to all other athletes). If there are no such athletes, print -1. If there is more than such one athlete, print any of them.
  
  Example
  
  Input
  
  
  4
  1
  50000 1 50000 50000 50000
  3
  10 10 20 30 30
  20 20 30 10 10
  30 30 10 20 20
  3
  1 1 1 1 1
  2 2 2 2 2
  3 3 3 3 3
  6
  9 5 3 7 1
  7 4 1 6 8
  5 6 7 3 2
  6 7 8 8 6
  4 2 2 4 5
  8 3 6 9 4
  
  
  Output
  
  
  1
  -1
  1
  5
  
  Note
  
  Explanation of the first test case: There is only one athlete, therefore he is superior to everyone else (since there is no one else), and thus he is likely to get the gold medal.
  
  Explanation of the second test case: There are n=3 athletes. 
  
    * Athlete 1 is superior to athlete 2. Indeed athlete 1 ranks better than athlete 2 in the marathons 1, 2 and 3. 
    * Athlete 2 is superior to athlete 3. Indeed athlete 2 ranks better than athlete 3 in the marathons 1, 2, 4 and 5. 
    * Athlete 3 is superior to athlete 1. Indeed athlete 3 ranks better than athlete 1 in the marathons 3, 4 and 5. 
  
  
  
  Explanation of the third test case: There are n=3 athletes. 
  
    * Athlete 1 is superior to athletes 2 and 3. Since he is superior to all other athletes, he is likely to get the gold medal. 
    * Athlete 2 is superior to athlete 3. 
    * Athlete 3 is not superior to any other athlete. 
  
  
  
  Explanation of the fourth test case: There are n=6 athletes. 
  
    * Athlete 1 is superior to athletes 3, 4, 6. 
    * Athlete 2 is superior to athletes 1, 4, 6. 
    * Athlete 3 is superior to athletes 2, 4, 6. 
    * Athlete 4 is not superior to any other athlete. 
    * Athlete 5 is superior to athletes 1, 2, 3, 4, 6. Since he is superior to all other athletes, he is likely to get the gold medal. 
    * Athlete 6 is only superior to athlete 4. 
solution: """
  // Author : snape_here - Susanta Mukherjee
       
   """
  
  from __future__ import division, print_function
   
  import os,sys
  from io import BytesIO, IOBase
   
  if sys.version_info[0] < 3:
      from __builtin__ import xrange as range
      from future_builtins import ascii, filter, hex, map, oct, zip
   
  def ii(): return int(input())
  def fi(): return float(input())
  def si(): return input()
  def msi(): return map(str,input().split())
  def mi(): return map(int,input().split())
  def li(): return list(mi())
  def lsi(): return list(msi())
   
  def read():
      sys.stdin = open('input.txt', 'r')  
      sys.stdout = open('output.txt', 'w') 
   
  def gcd(x, y):
      while y:
          x, y = y, x % y
      return x
  
  def lcm(x, y):
      return (x*y)//(gcd(x,y))
  
  mod=1000000007
  
  def modInverse(b,m): 
      g = gcd(b, m)  
      if (g != 1):         
          return -1
      else:          
          return pow(b, m - 2, m) 
  
  def ceil2(x,y):
      if x%y==0:
          return x//y
      else:
          return x//y+1
  
  def modu(a,b,m): 
  
      a = a % m 
      inv = modInverse(b,m) 
      if(inv == -1): 
          return -999999999
      else: 
          return (inv*a)%m
  
  from math import log,factorial,cos,tan,sin,radians,floor,sqrt,ceil
  
  import bisect
  import random
  import string 
  
  from decimal import *
  
  getcontext().prec = 50
  
  abc="abcdefghijklmnopqrstuvwxyz"
  
  pi=3.141592653589793238
  
  def gcd1(a):
      if len(a) == 1:
          return a[0]
      ans = a[0]
      for i in range(1,len(a)):
          ans = gcd(ans,a[i])
      return ans
  
  def mykey(x):
      return len(x)
  
  def changeArr(input1):
   
      # Copy input array into newArray
      newArray = input1.copy()
       
      # Sort newArray[] in ascending order
      newArray.sort()
       
      # Dictionary to store the rank of
      # the array element
      ranks = {}
       
      rank = 0
       
      for index in range(len(newArray)):
          element = newArray[index];
       
          # Update rank of element
          if element not in ranks:
              ranks[element] = rank
              rank += 1
           
      # Assign ranks to elements
      for index in range(len(input1)):
          element = input1[index]
          input1[index] = ranks[input1[index]]
      return input1
  
  def main():
  
      for _ in range(ii()):
          n=ii()
          l = []
          for i in range(n):
              r = li()
              l.append(r)
          l1 = []
          for i in range(n):
              c = [0]*5 
              l1.append(c)
          check = []
          for i in range(5):
              ra = []
              for j in range(n):
                  ra.append(l[j][i])
              ran = changeArr(ra)
              # print(ra)
              # print(ran)
              for j in range(n):
                  l1[j][i] = ran[j]
          #print(l1)
          ans = 0
          for i in range(1,n):
              c = 0
              for j in range(5):
                  if l1[ans][j]>l1[i][j]:
                      c += 1
                  if c>=3:
                      ans = i 
  
          g = 0
          for i in range(n):
              c = 0
              for j in range(5):
                  if l1[ans][j]<=l1[i][j]:
                      c += 1
              if c>=3:
                  g += 1
          #print(g)
          if g!=n:
              ans = -2
          print(ans+1)
  
  
  # region fastio
   
  BUFSIZE = 8192
   
  
  class FastIO(IOBase):
      newlines = 0
   
      def __init__(self, file):
          self._fd = file.fileno()
          self.buffer = BytesIO()
          self.writable = "x" in file.mode or "r" not in file.mode
          self.write = self.buffer.write if self.writable else None
   
      def read(self):
          while True:
              b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
              if not b:
                  break
              ptr = self.buffer.tell()
              self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
          self.newlines = 0
          return self.buffer.read()
   
      def readline(self):
          while self.newlines == 0:
              b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
              self.newlines = b.count(b"\n") + (not b)
              ptr = self.buffer.tell()
              self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
          self.newlines -= 1
          return self.buffer.readline()
   
      def flush(self):
          if self.writable:
              os.write(self._fd, self.buffer.getvalue())
              self.buffer.truncate(0), self.buffer.seek(0)
   
   
  class IOWrapper(IOBase):
      def __init__(self, file):
          self.buffer = FastIO(file)
          self.flush = self.buffer.flush
          self.writable = self.buffer.writable
          self.write = lambda s: self.buffer.write(s.encode("ascii"))
          self.read = lambda: self.buffer.read().decode("ascii")
          self.readline = lambda: self.buffer.readline().decode("ascii")
   
   
  def print(*args, **kwargs):
      """Prints the values to a stream, or to sys.stdout by default."""
      sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
      at_start = True
      for x in args:
          if not at_start:
              file.write(sep)
          file.write(str(x))
          at_start = False
      file.write(kwargs.pop("end", "\n"))
      if kwargs.pop("flush", False):
          file.flush()
   
   
  if sys.version_info[0] < 3:
      sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
  else:
      sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
   
  input = lambda: sys.stdin.readline().rstrip("\r\n")
   
  # endregion
  
   
  if __name__ == "__main__":
      #read()
      main()