class ComputeUnit:
def __init__(self, u, f, d, c, e):
self.u = u
self.f = f * 1e9
self.d = d * 1e9
self.c = c * 1e9
self.e = e * 1e9
class QueryParams:
def __init__(self, N, tau, I, O):
self.N = N
self.tau = tau
self.I = I
self.O = O
def main():
l, h, f = [int(x) for x in input().split()]
alpha, beta, gamma = [float(x) for x in input().split()]
n, m = [int(x) for x in input().split()]
units = []
for _ in range(n):
unit_data = [int(x) for x in input().split()]
units += [ComputeUnit(*unit_data)]
queries = []
for _ in range(m):
line = input().split()
N = int(line[0])
tau = float(line[1])
I = [int(x) for x in input().split()]
O = [int(x) for x in input().split()]
queries += [QueryParams(N, tau, I, O)]
for i in range(n):
print(1, units[i].u, 1)
P = n
for j in range(m):
A = [0]*P
pipeline_index = 0
for r in range(queries[j].N):
print(pipeline_index + 1, A[pipeline_index] + 1)
A[pipeline_index] += 1
pipeline_index = (pipeline_index + 1) % P
if __name__ == '__main__':
main()