text: '''
  Created on Jul 5, 2013
  
  @author: Yubin Bai
  
  All rights reserved.
  '''
  
  import time
  from multiprocessing.pool import Pool
  parallelSolve = False
  INF = 1 << 31
  
  
  def solve(par):
      P, neighbors = par
      minLen = INF
      minList = []
      for i, n in enumerate(neighbors):
          if len(n) < minLen:
              minLen = len(n)
              minList = [i]
          elif len(n) == minLen:
              minList.append(i)
      return ' '.join(str(e + 1) for e in minList)
  
  
  class Solver:
  
      def getInput(self):
          self.numOfTests = int(self.fIn.readline())
          self.input = []
          for i in range(self.numOfTests):
              P = int(self.fIn.readline())
              neighbors = []
              for j in range(P):
                  neighbors.append(map(int, self.fIn.readline().split()))
              self.fIn.readline()
              self.input.append((P, neighbors))
  
      def __init__(self):
          self.fIn = open('input.txt')
          self.fOut = open('output.txt', 'w')
          self.results = []
  
      def parallel(self):
          self.getInput()
          p = Pool(4)
          millis1 = int(round(time.time() * 1000))
          self.results = p.map(solve, self.input)
          millis2 = int(round(time.time() * 1000))
          print("Time in milliseconds: %d " % (millis2 - millis1))
          self.makeOutput()
  
      def sequential(self):
          self.getInput()
          millis1 = int(round(time.time() * 1000))
          for i in self.input:
              self.results.append(solve(i))
          millis2 = int(round(time.time() * 1000))
          print("Time in milliseconds: %d " % (millis2 - millis1))
          self.makeOutput()
  
      def makeOutput(self):
          for test in range(self.numOfTests):
              self.fOut.write("%s\n" % self.results[test])
          self.fIn.close()
          self.fOut.close()
  
  if __name__ == '__main__':
      solver = Solver()
      if parallelSolve:
          solver.parallel()
      else:
          solver.sequential()
  