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: //package com.company;
  
  
  
  import javax.naming.ldap.HasControls;
  import java.io.*;
  import java.util.*;
  
  public class Main implements Runnable {
      int size[];
      static int e9 = 1000000007;
      int max = Integer.MIN_VALUE;
      long max1 = Long.MIN_VALUE;
      long min1 = Long.MAX_VALUE;
      long fib[][];
      static class FastReader {
          BufferedReader br;
          StringTokenizer st;
  
          public FastReader() {
              br = new BufferedReader(new
                      InputStreamReader(System.in));
          }
  
          String next() {
              while (st == null || !st.hasMoreElements()) {
                  try {
                      st = new StringTokenizer(br.readLine());
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
              return st.nextToken();
          }
  
          int nextInt() {
              return Integer.parseInt(next());
          }
  
          long nextLong() {
              return Long.parseLong(next());
          }
  
          double nextDouble() {
              return Double.parseDouble(next());
          }
  
          String nextLine() {
              String str = "";
              try {
                  str = br.readLine();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return str;
          }
      }
      int parent[];
      int rank[];
      ArrayList<ArrayList<Integer>> arrayLists;
      long fib1[][];
      long r[];
      int n;
      int m;
      long co=0;
      long v[];
      int arr[][];
      int u=0;
      HashMap<Long,Long> hashMap=new HashMap<>();
      ArrayList<Long> arrayList;
      long ans=0;
      public static void main(String[] args) throws IOException {
          new Thread(null,new Main(),"Main",1<<28).start();
      }
  
      public void run() {
          FastReader scanner = new FastReader();
  //            Scanner scanner = new Scanner(System.in);
  //            BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(System.in));
          PrintWriter printWriter = new PrintWriter(System.out);
          long t=scanner.nextLong();
          high:while (t-- > 0) {
             int n=scanner.nextInt();
             int arr[][]=new int[n][5];
              for (int i = 0; i < n; i++) {
                  for (int j = 0; j < 5; j++) {
                      int a=scanner.nextInt();
                      arr[i][j]=a;
                  }
              }
              int u=1;
              int ans=0;
              while (u<n){
                  int r=0;
                  for (int i = 0; i < 5; i++) {
                      if(arr[ans][i]<arr[u][i]){
                          r++;
                      }
                  }
                  if(r<3){
                      ans=u;
                  }
                  u++;
              }
  //            System.out.println(ans+" "+"l");
              int e=0;
              for (int i = 0; i < n; i++) {
                  if(i!=ans){
                      int w=0;
                      for (int j = 0; j < 5; j++) {
                          if(arr[i][j]>arr[ans][j]){
                              w++;
                          }
                      }
                      if(w>=3){
                          e++;
                      }
                  }
              }
              if(e!=n-1){
                  printWriter.println(-1);
              }
              else
              printWriter.println(ans+1);
          }
          printWriter.flush();
      }
      static long mod=1_000_000_007;
      public long lcm(long a,long b){
          return (a*b)/gcd(a,b);
      }
      public long mul(long a, long b) {
  //        System.out.println(a+" "+b);
          return ((a)*(b));
      }
      public long fact(int x) {
          long ans=1;
          for (int i=2; i<=x; i++) ans=mul(ans, i);
          return ans;
      }
      public long fastPow(long base, long exp) {
          if (exp==0) return 1;
          long half=fastPow(base, exp/2);
          if (exp%2==0) return mul(half, half);
          return mul(half, mul(half, base));
      }
      public long modInv(long x) {
          return fastPow(x, mod-2);
      }
      public long nCk(int n, int k) {
          return mul(fact(n), mul(modInv(fact(k)), modInv(fact(n-k))));
      }
      public void parent(int n){
          parent=new int[n+1];
          size=new int[n+1];
          rank=new int[n+1];
          for (int i = 0; i <=n; i++) {
              parent[i]=i;
              rank[i]=0;
  //            size[i]=1;
          }
      }
      public void union(int i,int j){
          int root1=find(i);
          int root2=find(j);
  //            if(root1 != root2) {
  //                parent[root2] = root1;
  ////                sz[a] += sz[b];
  //            }
          if(root1==root2){
              return;
          }
          if(rank[root1]>rank[root2]){
              parent[root2]=root1;
              size[root1]+=size[root2];
          }
          else if(rank[root1]<rank[root2]){
              parent[root1]=root2;
              size[root2]+=size[root1];
          }
          else{
              parent[root2]=root1;
              rank[root1]+=1;
              size[root1]+=size[root2];
          }
      }
      public int find(int p){
          if(parent[p]!=p){
              if(parent[p]==-1){
                  return parent[p];
              }
              parent[p]=find(parent[p]);
          }
          return parent[p];
      }
      public double dist(double x1,double y1,double x2,double y2){
          double e=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
          double e1=Math.sqrt(e);
          return e1;
      }
      public void make(int p){
          parent[p]=p;
          rank[p]=1;
      }
      Random rand = new Random();
      public void sort(int[] a, int n) {
          for (int i = 0; i < n; i++) {
              int j = rand.nextInt(i + 1);
              int tmp = a[i];
              a[i] = a[j];
              a[j] = tmp;
          }
          Arrays.sort(a, 0, n);
      }
      public long gcd(long a,long b){
          if(b==0){
              return a;
          }
          return gcd(b,a%b);
      }
      //    public void dfs(ArrayList<Integer> arrayList){
  //        for (int i = 0; i < arrayList.size(); i++) {
  //            if(v1[arrayList.get(i)]==false){
  //                v1[arrayList.get(i)]=true;
  //                dfs(arrayLists.get(i));
  //            }
  //        }
  //    }
      public double fact(double h){
          double sum=1;
          while(h>=1){
              sum=(sum%e9)*(h%e9);
              h--;
          }
          return sum%e9;
      }
      public long primef(double r){
          long c=0;
          long ans=1;
          long g=0;
          while(r%2==0){
              c++;
              r=r/2;
          }
          if(c>0){
              ans*=2;
          }
          c=0;
  //            System.out.println(ans+" "+r);
          for (int i = 3; i <=Math.sqrt(r) ;i+=2) {
              g=0;
              while(r%i==0){
  //                    System.out.println(i);
                  c++;
                  g++;
                  r=r/i;
              }
              if(c>0){
                  ans*=i;
              }
              c=0;
          }
          if(r>2){
              ans*=r;
          }
          return ans;
      }
      public long divisor(double r){
          long c=0;
  //        if(n==3)
  //            System.out.println(r+" "+n+" "+k+" "+"l");
          for (int i =2; i <=Math.sqrt(r); i++) {
              if(r%i==0){
                  if(r/i==i){
                      c++;
                  }
                  else{
                      if(r/i<n){
                          c+=2;
                      }else{
                          c++;
                      }
                  }
              }
          }
          return c;
      }
  }
  class Pair {
      long x;
      long y;
      int z;
      public Pair(long x,long y) {
          this.x = x;
          this.y = y;
  //        this.z=z;
      }
  
  //     @Override
  //    public int hashCode() {
  //        int hash = 37;
  //        return this.x * hash + this.y;
  //    }
  //
  //    @Override
  //    public boolean equals(Object o1) {
  //        if (o1 == null || o1.getClass() != this.getClass()) {
  //            return false;
  //        }
  //        Pair o = (Pair) o1;
  //        if (o.x == this.x && o.y == this.y) {
  //            return true;
  //        }
  //        return false;
  //    }
  }
  class Sorting implements Comparator<Pair> {
      public int compare(Pair p1, Pair p2) {
          if(p1.x==p2.x){
              return Long.compare(p1.y,p2.y);
          }else {
              return Long.compare(p1.x, p2.x);
          }
      }
  }
  class Edge{
      int s=0;
      int d=0;
      int c=0;
      public Edge(int s,int d,int c){
          this.s=s;
          this.d=d;
          this.c=c;
      }
  }
  