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.prituladima;
  
  import java.io.*;
  import java.util.Arrays;
  import java.util.Comparator;
  import java.util.InputMismatchException;
  
  /**
   * Provide prove of correctness before implementation. Implementation can cost a lot of time.
   * Anti test that prove that it's wrong.
   * <p>
   * Do not confuse i j k g indexes. Do extra methods.
   * <p>
   * Will program ever exceed limit?
   * Try all approaches with prove of correctness if task is not obvious.
   * Analytic solution/Hardcoded solution/Constructive/Greedy/DP/Math/Brute force/Symmetric data
   * Number theory
   * Game theory (optimal play) that consider local and global strategy.
   */
  public class B {
  
  
      private void solve_() {
          int n = reader.readInt();
          int[][] r = new int[n][];
          for (int i = 0; i < n; i++) {
              r[i] = new int[5];
              for (int j = 0; j < 5; j++) {
                  r[i][j] = reader.readInt();
              }
  //            r[i][5] = i;
          }
  
          int max = 0;
          for (int i = 1; i < n; i++) {
              int k = 0;
              for (int j = 0; j < 5; j++) {
                  if (r[max][j] > r[i][j]) {
                      k++;
                  }
              }
              if (k >= 3) {
                  max = i;
              }
          }
  
          for (int i = 0; i < n; i++) {
              if (max != i) {
                  int k = 0;
                  for (int j = 0; j < 5; j++) {
                      if (r[max][j] > r[i][j]) {
                          k++;
                      }
                  }
                  if (k >= 3) {
                      writer.writeln(-1);
                      return;
                  }
              }
          }
          writer.writeln(max + 1);
  
  
  //
  //        Comparator<int[]> comparator = comp();
  //        Arrays.sort(r, comparator);
  //        int b = r[0][5];
  //        for (int i = 0; i < n; i++) {
  //            if (0 != i) {
  //                int fw = 0;
  //                for (int j = 0; j < 5; j++) {
  //                    if (r[0][j] < r[i][j]) {
  //                        fw++;
  //                    }
  //                }
  //                if (fw < 3) {
  //                    writer.writeln(-1);
  //                    return;
  //                }
  //            }
  //        }
  //
  //        writer.writeln(r[0][5] + 1);
  
  
      }
  
  
      Comparator<int[]> comp() {
          return (arr1, arr2) -> {
              int fw = 0;
              int sw = 0;
              for (int i = 0; i < 5; i++) {
                  if (arr1[i] < arr2[i]) {
                      fw++;
                  }
  
                  if (arr1[i] > arr2[i]) {
                      sw++;
                  }
              }
              if (fw == sw) {
                  throw new RuntimeException("");
  //                return 0;
              }
              if (fw > sw) return -1;
              return 1;
          };
      }
  
  
      private void solve() {
          int t = reader.readInt();
          for (int i = 0; i < t; i++) {
              solve_();
          }
      }
  
      public static void main(String[] args) {
          new B().run();
      }
  
      private InputReader reader;
      private FastWriter writer;
  
      private void run() {
          reader = new InputReader(System.in);
          writer = new FastWriter(System.out);
          solve();
          writer.flush();
      }
  
      private static class FastWriter {
          private static final int BUF_SIZE = 8192;//1 << 13
          private final byte[] buf = new byte[BUF_SIZE];
          private final OutputStream out;
          private int ptr = 0;
  
          private FastWriter() {
              this(System.out);
          }
  
          public FastWriter(OutputStream os) {
              this.out = os;
          }
  
          public FastWriter(String path) {
              try {
                  this.out = new FileOutputStream(path);
              } catch (FileNotFoundException e) {
                  throw new RuntimeException("FastWriter");
              }
          }
  
          public FastWriter write(byte b) {
              buf[ptr++] = b;
              if (ptr == BUF_SIZE) innerflush();
              return this;
          }
  
          public FastWriter write(char c) {
              return write((byte) c);
          }
  
          public FastWriter write(char[] s) {
              for (char c : s) {
                  buf[ptr++] = (byte) c;
                  if (ptr == BUF_SIZE) innerflush();
              }
              return this;
          }
  
          public FastWriter write(String s) {
              s.chars().forEach(c -> {
                  buf[ptr++] = (byte) c;
                  if (ptr == BUF_SIZE) innerflush();
              });
              return this;
          }
  
          public FastWriter write0(char[] s) {
              if (ptr + s.length < BUF_SIZE) {
                  for (char c : s) {
                      buf[ptr++] = (byte) c;
                  }
              } else {
                  for (char c : s) {
                      buf[ptr++] = (byte) c;
                      if (ptr == BUF_SIZE) innerflush();
                  }
              }
              return this;
          }
  
          public FastWriter write0(String s) {
              if (ptr + s.length() < BUF_SIZE) {
                  for (int i = 0; i < s.length(); i++) {
                      buf[ptr++] = (byte) s.charAt(i);
                  }
              } else {
                  for (int i = 0; i < s.length(); i++) {
                      buf[ptr++] = (byte) s.charAt(i);
                      if (ptr == BUF_SIZE) innerflush();
                  }
              }
              return this;
          }
  
          private static int countDigits(int l) {
              if (l >= 1000000000) return 10;
              if (l >= 100000000) return 9;
              if (l >= 10000000) return 8;
              if (l >= 1000000) return 7;
              if (l >= 100000) return 6;
              if (l >= 10000) return 5;
              if (l >= 1000) return 4;
              if (l >= 100) return 3;
              if (l >= 10) return 2;
              return 1;
          }
  
          public FastWriter write(int x) {
              if (x == Integer.MIN_VALUE) {
                  return write((long) x);
              }
              if (ptr + 12 >= BUF_SIZE) innerflush();
              if (x < 0) {
                  write((byte) '-');
                  x = -x;
              }
              int d = countDigits(x);
              for (int i = ptr + d - 1; i >= ptr; i--) {
                  buf[i] = (byte) ('0' + x % 10);
                  x /= 10;
              }
              ptr += d;
              return this;
          }
  
          private static int countDigits(long l) {
              if (l >= 1000000000000000000L) return 19;
              if (l >= 100000000000000000L) return 18;
              if (l >= 10000000000000000L) return 17;
              if (l >= 1000000000000000L) return 16;
              if (l >= 100000000000000L) return 15;
              if (l >= 10000000000000L) return 14;
              if (l >= 1000000000000L) return 13;
              if (l >= 100000000000L) return 12;
              if (l >= 10000000000L) return 11;
              if (l >= 1000000000L) return 10;
              if (l >= 100000000L) return 9;
              if (l >= 10000000L) return 8;
              if (l >= 1000000L) return 7;
              if (l >= 100000L) return 6;
              if (l >= 10000L) return 5;
              if (l >= 1000L) return 4;
              if (l >= 100L) return 3;
              if (l >= 10L) return 2;
              return 1;
          }
  
          public FastWriter write(long x) {
              if (x == Long.MIN_VALUE) {
                  return write("" + x);
              }
              if (ptr + 21 >= BUF_SIZE) innerflush();
              if (x < 0) {
                  write((byte) '-');
                  x = -x;
              }
              int d = countDigits(x);
              for (int i = ptr + d - 1; i >= ptr; i--) {
                  buf[i] = (byte) ('0' + x % 10);
                  x /= 10;
              }
              ptr += d;
              return this;
          }
  
          public FastWriter write(double x, int precision) {
              if (x < 0) {
                  write('-');
                  x = -x;
              }
              x += Math.pow(10, -precision) / 2;
              //		if(x < 0){ x = 0; }
              write((long) x).write(".");
              x -= (long) x;
              for (int i = 0; i < precision; i++) {
                  x *= 10;
                  write((char) ('0' + (int) x));
                  x -= (int) x;
              }
              return this;
          }
  
          public FastWriter writeln(char c) {
              return write(c).writeln();
          }
  
          public FastWriter writeln(int x) {
              return write(x).writeln();
          }
  
          public FastWriter writeln(long x) {
              return write(x).writeln();
          }
  
          public FastWriter writeln(String x) {
              return write(x).writeln();
          }
  
          public FastWriter writeln(double x, int precision) {
              return write(x, precision).writeln();
          }
  
          public FastWriter writeln() {
              return write((byte) '\n');
          }
  
          private void innerflush() {
              try {
                  out.write(buf, 0, ptr);
                  ptr = 0;
              } catch (IOException e) {
                  throw new RuntimeException("innerflush");
              }
          }
  
          public void flush() {
              innerflush();
              try {
                  out.flush();
              } catch (IOException e) {
                  throw new RuntimeException("flush");
              }
          }
      }
  
      private static class InputReader {
          private boolean finished = false;
  
          private InputStream stream;
          private byte[] buf = new byte[1024];
          private int curChar;
          private int numChars;
          private SpaceCharFilter filter;
  
          public InputReader(InputStream stream) {
              this.stream = stream;
          }
  
          public double[] readDoubleArray(int size) {
              double[] array = new double[size];
              for (int i = 0; i < size; i++) {
                  array[i] = readDouble();
              }
              return array;
          }
  
          public String[] readStringArray(int size) {
              String[] array = new String[size];
              for (int i = 0; i < size; i++) {
                  array[i] = readString();
              }
              return array;
          }
  
          public char[] readCharArray(int size) {
              char[] array = new char[size];
              for (int i = 0; i < size; i++) {
                  array[i] = readCharacter();
              }
              return array;
          }
  
  //        public IntIntPair[] readIntPairArray(int size) {
  //            IntIntPair[] result = new IntIntPair[size];
  //            for (int i = 0; i < size; i++) {
  //                result[i] = readIntPair();
  //            }
  //            return result;
  //        }
  //
  //        public LongLongPair[] readLongPairArray(int size) {
  //            LongLongPair[] result = new LongLongPair[size];
  //            for (int i = 0; i < size; i++) {
  //                result[i] = readLongPair();
  //            }
  //            return result;
  //        }
  
          public void readIntArrays(int[]... arrays) {
              for (int i = 0; i < arrays[0].length; i++) {
                  for (int j = 0; j < arrays.length; j++) {
                      arrays[j][i] = readInt();
                  }
              }
          }
  
          public void readLongArrays(long[]... arrays) {
              for (int i = 0; i < arrays[0].length; i++) {
                  for (int j = 0; j < arrays.length; j++) {
                      arrays[j][i] = readLong();
                  }
              }
          }
  
          public void readDoubleArrays(double[]... arrays) {
              for (int i = 0; i < arrays[0].length; i++) {
                  for (int j = 0; j < arrays.length; j++) {
                      arrays[j][i] = readDouble();
                  }
              }
          }
  
          public char[][] readTable(int rowCount, int columnCount) {
              char[][] table = new char[rowCount][];
              for (int i = 0; i < rowCount; i++) {
                  table[i] = this.readCharArray(columnCount);
              }
              return table;
          }
  
          public int[][] readIntTable(int rowCount, int columnCount) {
              int[][] table = new int[rowCount][];
              for (int i = 0; i < rowCount; i++) {
                  table[i] = readIntArray(columnCount);
              }
              return table;
          }
  
          public double[][] readDoubleTable(int rowCount, int columnCount) {
              double[][] table = new double[rowCount][];
              for (int i = 0; i < rowCount; i++) {
                  table[i] = this.readDoubleArray(columnCount);
              }
              return table;
          }
  
          public long[][] readLongTable(int rowCount, int columnCount) {
              long[][] table = new long[rowCount][];
              for (int i = 0; i < rowCount; i++) {
                  table[i] = readLongArray(columnCount);
              }
              return table;
          }
  
          public String[][] readStringTable(int rowCount, int columnCount) {
              String[][] table = new String[rowCount][];
              for (int i = 0; i < rowCount; i++) {
                  table[i] = this.readStringArray(columnCount);
              }
              return table;
          }
  
          public String readText() {
              StringBuilder result = new StringBuilder();
              while (true) {
                  int character = read();
                  if (character == '\r') {
                      continue;
                  }
                  if (character == -1) {
                      break;
                  }
                  result.append((char) character);
              }
              return result.toString();
          }
  
          public void readStringArrays(String[]... arrays) {
              for (int i = 0; i < arrays[0].length; i++) {
                  for (int j = 0; j < arrays.length; j++) {
                      arrays[j][i] = readString();
                  }
              }
          }
  
          public long[] readLongArray(int size) {
              long[] array = new long[size];
              for (int i = 0; i < size; i++) {
                  array[i] = readLong();
              }
              return array;
          }
  
          public int[] readIntArray(int size) {
              int[] array = new int[size];
              for (int i = 0; i < size; i++) {
                  array[i] = readInt();
              }
              return array;
          }
  
  //        public LongLongPair readLongPair() {
  //            long first = readLong();
  //            long second = readLong();
  //            return new LongLongPair(first, second);
  //        }
  //
  //        public IntIntPair readIntPair() {
  //            int first = readInt();
  //            int second = readInt();
  //            return new IntIntPair(first, second);
  //        }
  
          public int read() {
              if (numChars == -1) {
                  throw new InputMismatchException();
              }
              if (curChar >= numChars) {
                  curChar = 0;
                  try {
                      numChars = stream.read(buf);
                  } catch (IOException e) {
                      throw new InputMismatchException();
                  }
                  if (numChars <= 0) {
                      return -1;
                  }
              }
              return buf[curChar++];
          }
  
          public int peek() {
              if (numChars == -1) {
                  return -1;
              }
              if (curChar >= numChars) {
                  curChar = 0;
                  try {
                      numChars = stream.read(buf);
                  } catch (IOException e) {
                      return -1;
                  }
                  if (numChars <= 0) {
                      return -1;
                  }
              }
              return buf[curChar];
          }
  
          public int peekNonWhitespace() {
              while (isWhitespace(peek())) {
                  read();
              }
              return peek();
          }
  
          public int readInt() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              int res = 0;
              do {
                  if (c < '0' || c > '9') {
                      throw new InputMismatchException();
                  }
                  res *= 10;
                  res += c - '0';
                  c = read();
              } while (!isSpaceChar(c));
              return res * sgn;
          }
  
          public long readLong() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              long res = 0;
              do {
                  if (c < '0' || c > '9') {
                      throw new InputMismatchException();
                  }
                  res *= 10;
                  res += c - '0';
                  c = read();
              } while (!isSpaceChar(c));
              return res * sgn;
          }
  
          public String readString() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              StringBuilder res = new StringBuilder();
              do {
                  if (Character.isValidCodePoint(c)) {
                      res.appendCodePoint(c);
                  }
                  c = read();
              } while (!isSpaceChar(c));
              return res.toString();
          }
  
          public boolean isSpaceChar(int c) {
              if (filter != null) {
                  return filter.isSpaceChar(c);
              }
              return isWhitespace(c);
          }
  
          public static boolean isWhitespace(int c) {
              return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
          }
  
          private String readLine0() {
              StringBuilder buf = new StringBuilder();
              int c = read();
              while (c != '\n' && c != -1) {
                  if (c != '\r') {
                      buf.appendCodePoint(c);
                  }
                  c = read();
              }
              return buf.toString();
          }
  
          public String readLine() {
              String s = readLine0();
              while (s.trim().length() == 0) {
                  s = readLine0();
              }
              return s;
          }
  
          public String readLine(boolean ignoreEmptyLines) {
              if (ignoreEmptyLines) {
                  return readLine();
              } else {
                  return readLine0();
              }
          }
  
          public char readCharacter() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              return (char) c;
          }
  
          public double readDouble() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              double res = 0;
              while (!isSpaceChar(c) && c != '.') {
                  if (c == 'e' || c == 'E') {
                      return res * Math.pow(10, readInt());
                  }
                  if (c < '0' || c > '9') {
                      throw new InputMismatchException();
                  }
                  res *= 10;
                  res += c - '0';
                  c = read();
              }
              if (c == '.') {
                  c = read();
                  double m = 1;
                  while (!isSpaceChar(c)) {
                      if (c == 'e' || c == 'E') {
                          return res * Math.pow(10, readInt());
                      }
                      if (c < '0' || c > '9') {
                          throw new InputMismatchException();
                      }
                      m /= 10;
                      res += (c - '0') * m;
                      c = read();
                  }
              }
              return res * sgn;
          }
  
          public boolean isExhausted() {
              int value;
              while (isSpaceChar(value = peek()) && value != -1) {
                  read();
              }
              return value == -1;
          }
  
          public String next() {
              return readString();
          }
  
          public SpaceCharFilter getFilter() {
              return filter;
          }
  
          public void setFilter(SpaceCharFilter filter) {
              this.filter = filter;
          }
  
          public interface SpaceCharFilter {
              public boolean isSpaceChar(int ch);
          }
      }
  
  }