Hamed has recently found a string *t* and suddenly became quite fond of it. He spent several days trying to find all occurrences of *t* in other strings he had. Finally he became tired and started thinking about the following problem. Given a string *s* how many ways are there to extract *k* ≥ 1 non-overlapping substrings from it such that each of them contains string *t* as a substring? More formally, you need to calculate the number of ways to choose two sequences *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*k*</sub> and *b*<sub class="lower-index">1</sub>, *b*<sub class="lower-index">2</sub>, ..., *b*<sub class="lower-index">*k*</sub> satisfying the following requirements:
 -  *k* ≥ 1 -  <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/9787d50d9b7a3b6baffe4cb496df2248b003b17a.png" style="max-width: 100.0%;max-height: 100.0%;"/> -  <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/092ce460b67857d1ad157982f2234fb864faae89.png" style="max-width: 100.0%;max-height: 100.0%;"/> -  <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/c25caac60742ab6bf606b781e3f62be37a796eeb.png" style="max-width: 100.0%;max-height: 100.0%;"/> -  <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/99ce7829f1cda3a108cb995b136005e31e6f5582.png" style="max-width: 100.0%;max-height: 100.0%;"/>  *t* is a substring of string *s*<sub class="lower-index">*a*<sub class="lower-index">*i*</sub></sub>*s*<sub class="lower-index">*a*<sub class="lower-index">*i*</sub> + 1</sub>... *s*<sub class="lower-index">*b*<sub class="lower-index">*i*</sub></sub> (string *s* is considered as 1-indexed). 
As the number of ways can be rather large print it modulo 10<sup class="upper-index">9</sup> + 7.
Input consists of two lines containing strings *s* and *t* (1 ≤ |*s*|, |*t*| ≤ 10<sup class="upper-index">5</sup>). Each string consists of lowercase Latin letters.
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
 
#define CASES int t;cin>>t;while(t--)
#define REP(i, val, b) for (int i = val; i < b; ++i)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

struct Rectangle {
	int ax, ay;
	int bx, by;
};

int main() {
	fastio
	int n;
	cin >> n;
	int maxX = -1e9-5;
	int maxY = maxX;
	int minX = 1e9+5;
	int minY = minX;
	vector<Rectangle> R(n);
	int index1 = -1;
	int index2 = -1;
		REP(i,0,n) {
		cin >> R[i].ax >> R[i].ay >> R[i].bx >> R[i].by;
		if (R[i].ax > maxX || R[i].ay > maxY) {
			maxX = max(maxX, R[i].ax);
			maxY = max(maxY, R[i].ay);
			index1 = i;
		}
		if (R[i].ax < minX || R[i].ay < minY) {
			minX = min(minX, R[i].ax);
			minY = min(minY, R[i].ay);
			index2 = i;
		}
	}
	maxX = -1e9-5;
	maxY = maxX;
	// R.erase(R.begin() + index1);
	REP(i,0,n) {
		// cout << R[i].ax << ' ' << R[i].ay << ' ' << R[i].bx << ' ' << R[i].by << endl;
		if (i != index1) {
			maxX = max(maxX, R[i].ax);
			maxY = max(maxY, R[i].ay);
		}
	}
	int ansx = maxX;
	int ansy = maxY;
	maxX = -1e9-5;
	maxY = maxX;
	bool firstValid = true;
	REP(i,0,n) {
		if (i != index1) {
			if (ansx < R[i].ax || ansx > R[i].bx || ansy < R[i].ay || ansy > R[i].by)
				firstValid = false;
		}
		if (i != index2) {
			maxX = max(maxX, R[i].ax);
			maxY = max(maxY, R[i].ay);
		}
	}
	// cout << index1 << ' ' << index2 << endl;
	cout << (firstValid?ansx:maxX) << ' ' << (firstValid?ansy:maxY);
	return 0;
}