using System;
using System.Linq;
class main
{
const long BILLION = 1000 * 1000 * 1000;
public class ComputeUnit
{
public long u, f, d, c, e;
}
public class QueryParams
{
public int N;
public double tau;
public long[] I;
public long[] O;
}
static long[] ReadLineInt()
{
string line = System.Console.ReadLine();
var tokens = line.Split(' ');
return tokens.Select(x => long.Parse(x)).ToArray();
}
static double[] ReadLineDouble()
{
string line = System.Console.ReadLine();
var tokens = line.Split(' ');
return tokens.Select(x => Double.Parse(x)).ToArray();
}
public static void Main(string[] args)
{
var lhf = ReadLineInt();
int l = (int)lhf[0];
int h = (int)lhf[1];
long F = lhf[2];
var abg = ReadLineDouble();
double alpha = abg[0];
double beta = abg[1];
double gamma = abg[2];
var nm = ReadLineInt();
int n = (int)nm[0];
int m = (int)nm[1];
var units = new ComputeUnit[n];
for (int i = 0; i < n; i++)
{
var line = ReadLineInt();
units[i] = new ComputeUnit
{
u = (int)line[0],
f = line[1] * BILLION,
d = line[2] * BILLION,
c = line[3] * BILLION,
e = line[4] * BILLION,
};
}
var queries = new QueryParams[m];
for (int j = 0; j < m; j++)
{
var tokens = System.Console.ReadLine().Split(' ');
int N = int.Parse(tokens[0]);
double tau = double.Parse(tokens[1]);
var I = ReadLineInt();
var O = ReadLineInt();
queries[j] = new QueryParams
{
N = N,
tau = tau,
I = I,
O = O,
};
}
for (int i = 0; i < n; i++)
{
System.Console.WriteLine("1 {0} 1", units[i].u);
}
int P = n;
for (int j = 0; j < m; j++)
{
var A = new int[P];
int pipeline_index = 0;
for (int r = 0; r < queries[j].N; r++)
{
System.Console.WriteLine("{0} {1}", pipeline_index + 1, A[pipeline_index] + 1);
A[pipeline_index]++;
pipeline_index = (pipeline_index + 1) % P;
}
}
}
}