#pragma GCC target ("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include "bits/stdc++.h" using namespace std; #define rep(i,n) for(int i=0;i> n; rep(i, n) { double p, q, r; cin >> p >> q >> r; M[i].init(r, p, q); } int q; cin >> q; rep(j, q) { int s, t; double x, y; cin >> s >> t >> x >> y; double nx, ny; for (int i = s - 1; i < t; i++) { nx = M[i].dat[0][0] * x + M[i].dat[0][1] * y + M[i].dat[0][2]; ny = M[i].dat[1][0] * x + M[i].dat[1][1] * y + M[i].dat[1][2]; x = nx; y = ny; } printf("%.13lf %.13lf\n", x,y); } }