#!/usr/bin/env python


class SubBox(object):
  def __init__(self, top, left, bottom, right):
    self._top = top
    self._left = left
    self._bottom = bottom
    self._right = right

  def Touches(self, other):
    return (
        self._top >= other._bottom and
        self._bottom <= other._top and
        self._left <= other._right and
        self._right >= other._left)


class Box(object):
  def __init__(self, line):
    self._line = line
    coords = [map(int, coord.split(',')) for coord in line.split()]
    (self._top, self._left), (self._bottom, self._right) = coords
    assert -90 <= self._top <= 90, (self._top, str(self))
    assert -90 <= self._bottom <= 90, (self._bottom, str(self))
    assert -180 <= self._left <= 180, (self._left, str(self))
    assert -180 <= self._right <= 180, (self._right, str(self))
    self._left = (self._left + 180) % 360
    self._right = (self._right + 180) % 360
    assert self._top >= self._bottom, (self._top, self._bottom, str(self))

    self._sub_boxes = []
    if self._left > self._right:
      self._sub_boxes.append(SubBox(self._top, self._left, self._bottom, 360))
      self._sub_boxes.append(SubBox(self._top, 0, self._bottom, self._right))
    elif self._left == 0:
      self._sub_boxes.append(SubBox(self._top, 360, self._bottom, 360))
      self._sub_boxes.append(SubBox(self._top, 0, self._bottom, self._right))
    elif self._right == 0:
      self._sub_boxes.append(SubBox(self._top, self._left, self._bottom, 360))
      self._sub_boxes.append(SubBox(self._top, 0, self._bottom, 0))
    else:
      self._sub_boxes.append(SubBox(self._top, self._left, self._bottom, self._right))

  def Touches(self, other):
    for self_sb in self._sub_boxes:
      for other_sb in other._sub_boxes:
        if self_sb.Touches(other_sb):
          return True
    return False

  def __str__(self):
    return self._line


def main():
  for case_num in xrange(input()):
    if case_num:
      print

    data_boxes = []
    query_boxes = []
    for _ in xrange(input()):
      data_boxes.append(Box(raw_input().strip()))
    for _ in xrange(input()):
      query_boxes.append(Box(raw_input().strip()))

    numMatched=0
    for data_box in data_boxes:
      for query_box in query_boxes:
        if data_box.Touches(query_box):
          print data_box
          numMatched+=1
          break

    if  0 == numMatched:
        print "No data found."


if __name__ == '__main__':
  main()
