Перепиши этот код так, чтобы улучшилась его читаемость #include <bits/stdc++.h>
// tiom4eg's precompiler options
// POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS
// IO settings
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0)
// Quick types
#define ll long long
#define ld long double
//#define ull unsigned long long
#define pii pair <int, int>
#define vi vector <int>
#define mi vector <vector <int>>
// Quick functions
#define endl "\n"
#define F first
#define S second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define pb push_back
#define mp make_pair
// Quick fors
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORS(i, a, b, c) for (int i = a; i < b; i += c)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)
#define EACH(e, a) for (auto& e : a)
// Pragmas
#ifndef TIOM4EG
#pragma GCC optimize("O3") // let the chaos begin!
#pragma GCC target("avx,tune=native")
#pragma GCC comment(linker, "/stack:200000000")
#endif
// PBDS
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pbds tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update>
using namespace __gnu_pbds;
// POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS
using namespace std;
mt19937 rng(chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count());
//#define int long long
const int INF = 1e9 + 7, MD = 998244353, MAX = 400007, LG = 20, R = 1 << LG, MOD = 1040015701, MOD2 = 1e9 + 9, B = 256;
const ll INFLL = 1e18 + 7;

vi suf, isuf, lcp;

void build_sufarr(string& s) {
	vi cnt(R), c(R), pn(R), cn(R);
	int n = s.size();
	FOR(i, 0, n) ++cnt[s[i]];
	FOR(i, 1, 256) cnt[i] += cnt[i - 1];
	FOR(i, 0, n) suf[--cnt[s[i]]] = i;
	c[suf[0]] = 0;
	int classes = 1;
	FOR(i, 1, n) {
		if (s[suf[i]] != s[suf[i - 1]]) ++classes;
		c[suf[i]] = classes - 1;
	}
	for (int h = 0; (1 << h) < n; ++h) {
		FOR(i, 0, n) {
			pn[i] = suf[i] - (1 << h);
			if (pn[i] < 0) pn[i] += n;
		}
		fill(all(cnt), 0);
		FOR(i, 0, n) ++cnt[c[pn[i]]];
		FOR(i, 1, classes) cnt[i] += cnt[i - 1];
		RFOR(i, n - 1, 0) suf[--cnt[c[pn[i]]]] = pn[i];
		cn[suf[0]] = 0, classes = 1;
		FOR(i, 1, n) {
			int mid1 = (suf[i] + (1 << h)) % n, mid2 = (suf[i - 1] + (1 << h)) % n;
			if (c[suf[i]] != c[suf[i - 1]] || c[mid1] != c[mid2]) ++classes;
			cn[suf[i]] = classes - 1;
		}
		c.swap(cn);
	}
	FOR(i, 0, n) isuf[suf[i]] = i;
	int curLCP = 0;
	FOR(i, 0, n) {
		int p = isuf[i];
		if (p == n - 1) {
			lcp[p] = curLCP = 0;
			continue;
		}
		int q = suf[p + 1];
		curLCP--;
		if (curLCP < 0) curLCP = 0;
		while (i + curLCP < n && q + curLCP < n && s[i + curLCP] == s[q + curLCP]) curLCP++;
		lcp[p] = curLCP;
	}
}

int Z;
int m[R][LG];
vi t[R];

void build_tree(int v, int l, int r) {
	if (l + 1 == r) {
		if (suf[l] >= Z) t[v].pb(suf[l] - Z);
	}
	else {
		int m = (l + r) / 2;
		build_tree(2 * v, l, m), build_tree(2 * v + 1, m, r);
		merge(all(t[2 * v]), all(t[2 * v + 1]), back_inserter(t[v]));
	}
}

int get(int v, int l, int r, int ql, int qr, int pl, int pr) {
	if (qr <= l || r <= ql) return 0;
	if (ql <= l && r <= qr) return lower_bound(all(t[v]), pr) - lower_bound(all(t[v]), pl);
    int m = (l + r) / 2;
    return get(2 * v, l, m, ql, qr, pl, pr) + get(2 * v + 1, m, r, ql, qr, pl, pr);
}

int get_qr(int p, int x) {
    RFOR(log, LG - 1, 0) if (m[p][log] >= x) p += 1 << log;
	return p + 1;
}
int get_ql(int p, int x) {
	RFOR(log, LG - 1, 0) if (p - (1 << log) >= 0 && m[p - (1 << log)][log] >= x) p -= 1 << log;
	return p;
}


signed main() {
    fastIO;
    string s, t; cin >> s >> t;
    string w = s + (char)(1) + t + (char)(0);
    Z = sz(s) + 1;
    suf.resize(sz(w)), isuf.resize(sz(w)), lcp.resize(sz(w));
	build_sufarr(w);
	FOR(log, 0, LG) FOR(i, 0, sz(w)) {
        if (!log) m[i][log] = lcp[i];
        else m[i][log] = min(m[i][log - 1], m[i + (1 << (log - 1))][log - 1]);
	}
	build_tree(1, 0, sz(w));
	int q; cin >> q;
	while (q--) {
		int l1, r1, l2, r2; cin >> l1 >> r1 >> l2 >> r2, --l1, --l2;
		int len = r1 - l1;
		if (r2 - (r1 - l1) >= l2) cout << get(1, 0, sz(w), get_ql(isuf[l1], r1 - l1), get_qr(isuf[l1], r1 - l1), l2, r2 - (r1 - l1) + 1) << endl;
		else cout << 0 << endl;
	}
}