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: import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  import java.util.InputMismatchException;
  
  /**
   * @author ethan55
   */
  public class Solution {
    public static void main(String[] args) {
      TestRunner.run();
    }
  
    public static class TestCase {
      static final boolean MULTIPLE = true;
  
      public void solve(InputReader in, OutputWriter out) {
        int n = in.nextInt();
        int[][] nums = new int[n][5];
        for (int i = 0; i < n; i++) {
          for (int j = 0; j < 5; j++) {
            nums[i][j] = in.nextInt();
          }
        }
  
        int best = 0;
        for (int i = 1; i < nums.length; i++) {
          if (!isWinner(nums[best], nums[i])) {
            best = i;
          }
        }
  
        for (int i = 0; i < nums.length; i++) {
          if (best == i) {
            continue;
          }
          if (!isWinner(nums[best], nums[i])) {
            out.println(-1);
            return;
          }
        }
  
        out.println(best + 1);
      }
  
      boolean isWinner(int[] a, int[] b) {
        int aScore = 0;
        int bScore = 0;
        for (int i = 0; i < a.length; i++) {
          if (a[i] < b[i]) {
            aScore++;
          } else {
            bScore++;
          }
        }
        return aScore > bScore;
      }
    }
  
    public static class TestRunner {
  
      public static void run() {
        InputReader in = new InputReader(System.in);
        try (OutputWriter out = new OutputWriter(System.out)) {
          int testCases = TestCase.MULTIPLE ? in.nextInt() : 1;
          for (int i = 1; i <= testCases; i++) {
            new TestCase().solve(in, out);
          }
        }
      }
  
    }
  
    public static class InputReader {
      private final InputStream inputStream;
      private final byte[] inputBuffer = new byte[1024];
      private int bytesRead = 0;
      private int inputBufferIndex = 0;
  
      public InputReader(InputStream inputStream) {
        this.inputStream = inputStream;
      }
  
      private int readByte() {
        if (bytesRead == -1) {
          throw new InputMismatchException();
        }
        if (inputBufferIndex >= bytesRead) {
          inputBufferIndex = 0;
          try {
            bytesRead = inputStream.read(inputBuffer);
          } catch (IOException e) {
            throw new InputMismatchException();
          }
          if (bytesRead <= 0) {
            return -1;
          }
        }
        return inputBuffer[inputBufferIndex++];
      }
  
      public int nextInt() {
        return (int) nextLong();
      }
  
      public long nextLong() {
        long num = 0;
        int b;
        boolean minus = false;
        do {
          b = readByte();
        } while (b != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if (b == '-') {
          minus = true;
          b = readByte();
        }
  
        while (true) {
          if (b >= '0' && b <= '9') {
            num = num * 10 + (b - '0');
          } else {
            return minus ? -num : num;
          }
          b = readByte();
        }
      }
  
    }
  
    public static class OutputWriter implements AutoCloseable {
      private static final int BUFFER_SIZE = 1 << 13;
      private final byte[] outputBuffer = new byte[BUFFER_SIZE];
      private final OutputStream outputStream;
      private int outputBufferIndex = 0;
  
      public OutputWriter(OutputStream os) {
        this.outputStream = os;
      }
  
      public OutputWriter println(int x) {
        return writeln(x);
      }
  
      public void flush() {
        innerFlush();
        try {
          outputStream.flush();
        } catch (IOException e) {
          throw new IllegalStateException("Failed to flush");
        }
      }
  
      private OutputWriter write(byte b) {
        outputBuffer[outputBufferIndex++] = b;
        if (outputBufferIndex == BUFFER_SIZE) {
          innerFlush();
        }
        return this;
      }
  
      private OutputWriter write(String s) {
        s.chars()
            .forEach(
                c -> {
                  outputBuffer[outputBufferIndex++] = (byte) c;
                  if (outputBufferIndex == BUFFER_SIZE) {
                    innerFlush();
                  }
                });
        return this;
      }
  
      private OutputWriter write(int x) {
        if (x == Integer.MIN_VALUE) {
          return write((long) x);
        }
        if (outputBufferIndex + 12 >= BUFFER_SIZE) {
          innerFlush();
        }
        if (x < 0) {
          write((byte) '-');
          x = -x;
        }
        int d = countDigits(x);
        for (int i = outputBufferIndex + d - 1; i >= outputBufferIndex; i--) {
          outputBuffer[i] = (byte) ('0' + x % 10);
          x /= 10;
        }
        outputBufferIndex += 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;
      }
  
      private OutputWriter write(long x) {
        if (x == Long.MIN_VALUE) {
          return write("" + x);
        }
        if (outputBufferIndex + 21 >= BUFFER_SIZE) {
          innerFlush();
        }
        if (x < 0) {
          write((byte) '-');
          x = -x;
        }
        int d = countDigits(x);
        for (int i = outputBufferIndex + d - 1; i >= outputBufferIndex; i--) {
          outputBuffer[i] = (byte) ('0' + x % 10);
          x /= 10;
        }
        outputBufferIndex += d;
        return this;
      }
  
      private OutputWriter writeln(int x) {
        return write(x).writeln();
      }
  
      private OutputWriter writeln() {
        return write((byte) '\n');
      }
  
      private void innerFlush() {
        try {
          outputStream.write(outputBuffer, 0, outputBufferIndex);
          outputBufferIndex = 0;
        } catch (IOException e) {
          throw new IllegalStateException("Failed to inner flush");
        }
      }
  
      @Override
      public void close() {
        flush();
      }
    }
  }