#include <bits/stdc++.h>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 200005;
unsigned int a[32][200000 / 32 + 5];
unsigned int b[200000 / 32 + 5];

char s[N], r[N];

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int l1, l2;

int main(){
	freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	//ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	RS(s), RS(r);
	l1 = SL(s), l2 = SL(r);

	REP(j, 32) {
		for (int i = j; i + 32 <= l1; i += 32) {
			unsigned int bit = 1;
			int id = (i - j) / 32;
			REP(k, 32) {
				if (i + k >= l1) break;
				if (s[i + k] == '1') a[j][id] |= bit;
				bit <<= 1;
			}
		}
	}

	for (int i = 0, j = 0; i + 32 <= l2; i += 32, j++) {
		unsigned int bit = 1;
		REP(k, 32) {
			if (i + k >= l2) break;
			if (r[i + k] == '1') b[j] |= bit;
			bit <<= 1;
		}
	}

	int Q, p1, p2, len, ans;
	int bl, br, kk, bb;
	unsigned int ta, tb;
	Q = get();

	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		if (len <= 32) {
			for (int i = p1, j = p2, k = 0; k < len; i++, j++, k++) {
				ans += (s[i] != r[j]);
			}
			output(ans);
			continue;
		}
		bl = p2 / 32;
		br = (p2 + len - 1) / 32;

		int n1, n2;
		for (n2 = p2, n1 = p1; n2 < (bl + 1) * N; ++n1, ++n2) {
			ans += (s[n1] != r[n2]);
		}

		bb = n1 & 31;
		kk = n1 >> 5;

		REPP(i, bl + 1, br - 1) {
			ans += __builtin_popcount(a[bb][kk] ^ b[i]);
			kk++;
		}

		for (n2 = br * N, n1 = (kk << 5) + bb; n2 < p2 + len; ++n2, ++n1) {
			ans += (s[n1] != r[n2]);
		}

		// tb = b[bl] >> (p2 - bl * N);
		// bb = p1 % 32, kk = (p1 - bb) / 32;
		// ta = a[bb][kk] & ((1 << (p2 - bl * N + 1)) - 1);
		// ans += __builtin_popcount(ta ^ tb);

		// REPP(i, bl + 1, br - 1) {
		// 	kk++;
		// 	ans += __builtin_popcount(a[bb][kk] ^ b[i]);
		// }

		// tb = b[br] & ((1 << (p2 - br * N + len)) - 1);
		// ta = a[bb][kk]

		// ans += __builtin_popcount(ta ^ tb);
		output(ans);
	}

	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 200005;
uint a[32][200000 / 32 + 5];
uint b[200000 / 32 + 5];

char s[N], r[N];

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int l1, l2;

int main(){
	freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	//ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	RS(s), RS(r);
	l1 = SL(s), l2 = SL(r);

	REP(j, 32) {
		for (int i = j; i + 32 <= l1; i += 32) {
			uint bit = 1;
			int id = (i - j) / 32;
			REP(k, 32) {
				if (i + k >= l1) break;
				if (s[i + k] == '1') a[j][id] |= bit;
				bit <<= 1;
			}
		}
	}

	for (int i = 0, j = 0; i + 32 <= l2; i += 32, j++) {
		uint bit = 1;
		REP(k, 32) {
			if (i + k >= l2) break;
			if (r[i + k] == '1') b[j] |= bit;
			bit <<= 1;
		}
	}

	int Q, p1, p2, len, ans;
	int bl, br, kk, bb;
	uint ta, tb;
	Q = get();

	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		if (len <= 32) {
			for (int i = p1, j = p2, k = 0; k < len; i++, j++, k++) {
				ans += (s[i] != r[j]);
			}
			output(ans);
			continue;
		}
		bl = p2 / 32;
		br = (p2 + len - 1) / 32;

		int n1, n2;
		for (n2 = p2, n1 = p1; n2 < (bl + 1) * N; ++n1, ++n2) {
			ans += (s[n1] != r[n2]);
		}

		bb = n1 & 31;
		kk = n1 >> 5;

		REPP(i, bl + 1, br - 1) {
			ans += __builtin_popcount(a[bb][kk] ^ b[i]);
			kk++;
		}

		for (n2 = br * N, n1 = (kk << 5) + bb; n2 < p2 + len; ++n2, ++n1) {
			ans += (s[n1] != r[n2]);
		}

		// tb = b[bl] >> (p2 - bl * N);
		// bb = p1 % 32, kk = (p1 - bb) / 32;
		// ta = a[bb][kk] & ((1 << (p2 - bl * N + 1)) - 1);
		// ans += __builtin_popcount(ta ^ tb);

		// REPP(i, bl + 1, br - 1) {
		// 	kk++;
		// 	ans += __builtin_popcount(a[bb][kk] ^ b[i]);
		// }

		// tb = b[br] & ((1 << (p2 - br * N + len)) - 1);
		// ta = a[bb][kk]

		// ans += __builtin_popcount(ta ^ tb);
		output(ans);
	}

	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 200005;
unsigned int a[32][N / 32 + 5];
unsigned int b[32][N / 32 + 5];

char s[N], r[N];

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int l1, l2;

int main(){
	// freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	//ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	RS(s), RS(r);
	l1 = SL(s), l2 = SL(r);

	REP(j, 32) {
		for (int i = j, t = 0; i + 32 <= l1; i += 32, t++) {
			unsigned int bit = 1;
			REP(k, 32) {
				if (i + k >= l1) break;
				if (s[i + k] == '1') a[j][t] |= bit;
				bit <<= 1;
			}
		}
	}

	REP(j, 32) {
		for (int i = j, t = 0; i + 32 <= l2; i += 32, t++) {
			unsigned int bit = 1;
			REP(k, 32) {
				if (i + k >= l2) break;
				if (r[i + k] == '1') b[j][t] |= bit;
				bit <<= 1;
			}
		}
	}

	int Q, p1, p2, len, ans;
	int bl, br, kk, bb, pp, qq, n1, n2, left;
	unsigned ta, tb;

	Q = get();

	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		if (len <= 32) {
			for (int i = p1, j = p2, k = 0; k < len; i++, j++, k++) {
				ans += (s[i] != r[j]);
			}
			output(ans);
			continue;
		}

		bl = p2 >> 5;
		br = (p2 + len - 1) >> 5;

		bb = p1 & 31;
		kk = p1 >> 5;
		pp = p2 & 31;
		qq = p2 >> 5;

		for (int i = qq, j = kk, k = bl; k < br; ++i, ++j, ++k){
			ans += __builtin_popcount(a[bb][j] ^ b[pp][i]);
		}

		left = p2 + len - (br << 5);
		ta = a[bb][kk + br - bl] & ((1U << left) - 1);
		tb = b[pp][qq + br - bl] & ((1U << left) - 1);
		ans += __builtin_popcount(ta ^ tb);

		output(ans);
	}

	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 200005;
unsigned int a[32][N / 32 + 5];
unsigned int b[32][N / 32 + 5];

char s[N], r[N];

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int l1, l2;

int main(){
	// freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	//ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	RS(s), RS(r);
	l1 = SL(s), l2 = SL(r);

	REP(j, 32) {
		for (int i = j, t = 0; i + 32 <= l1; i += 32, t++) {
			unsigned int bit = 1;
			REP(k, 32) {
				if (i + k >= l1) break;
				if (s[i + k] == '1') a[j][t] |= bit;
				bit <<= 1;
			}
		}
	}

	REP(j, 32) {
		for (int i = j, t = 0; i + 32 <= l2; i += 32, t++) {
			unsigned int bit = 1;
			REP(k, 32) {
				if (i + k >= l2) break;
				if (r[i + k] == '1') b[j][t] |= bit;
				bit <<= 1;
			}
		}
	}

	int Q, p1, p2, len, ans;
	int bl, br, kk, bb, n1, n2;
	unsigned ta, tb;

	Q = get();

	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		if (len <= 32) {
			for (int i = p1, j = p2, k = 0; k < len; i++, j++, k++) {
				ans += (s[i] != r[j]);
			}
			output(ans);
			continue;
		}

		bl = p2 >> 5;
		br = (p2 + len - 1) >> 5;

		bb = p1 & 31;
		kk = p1 >> 5;
		pp = p2 & 31;
		qq = p2 >> 5;

		for (int i = qq, j = kk, k = bl; k < br; ++i, ++j, ++k){
			ans += __builtin_popcount(a[bb][j] ^ b[pp][i])
		}

		int left = p2 + len - (br << 5);
		ta = a[bb][kk + br - bl] & ((1 << left) - 1);
		tb = b[pp][qq + br - bl] & ((1 << left) - 1);
		ans += __builtin_popcount(ta ^ tb);

		output(ans);
	}

	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 200005;
unsigned int a[32][200000 / 32 + 5];
unsigned int b[200000 / 32 + 5];

char s[N], r[N];

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int l1, l2;

int main(){
	// freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	//ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	RS(s), RS(r);
	l1 = SL(s), l2 = SL(r);

	REP(j, 32) {
		for (int i = j; i + 32 <= l1; i += 32) {
			unsigned int bit = 1;
			int id = (i - j) / 32;
			REP(k, 32) {
				if (i + k >= l1) break;
				if (s[i + k] == '1') a[j][id] |= bit;
				bit <<= 1;
			}
		}
	}

	for (int i = 0, j = 0; i + 32 <= l2; i += 32, j++) {
		unsigned int bit = 1;
		REP(k, 32) {
			if (i + k >= l2) break;
			if (r[i + k] == '1') b[j] |= bit;
			bit <<= 1;
		}
	}

	int Q, p1, p2, len, ans;
	int bl, br, kk, bb;

	Q = get();

	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		if (len <= 32) {
			for (int i = p1, j = p2, k = 0; k < len; i++, j++, k++) {
				ans += (s[i] != r[j]);
			}
			output(ans);
			continue;
		}
		bl = p2 >> 5;
		br = (p2 + len - 1) >> 5;

		int n1, n2;
		for (n2 = p2, n1 = p1; n2 < (bl + 1) * N; ++n1, ++n2) {
			ans += (s[n1] != r[n2]);
		}

		bb = n1 & 31;
		kk = n1 >> 5;

		// REPP(i, bl + 1, br - 1) {
		// 	ans += __builtin_popcount(a[bb][kk] ^ b[i]);
		// 	kk++;
		// }

		for (n2 = br * N, n1 = (kk << 5) + bb; n2 < p2 + len; ++n2, ++n1) {
			ans += (s[n1] != r[n2]);
		}

		output(ans);
	}

	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 200005;
unsigned int a[32][200000 / 32 + 5];
unsigned int b[200000 / 32 + 5];

char s[N], r[N];

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int l1, l2;

int main(){
	// freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	//ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	RS(s), RS(r);
	l1 = SL(s), l2 = SL(r);

	REP(j, 32) {
		for (int i = j; i + 32 <= l1; i += 32) {
			unsigned int bit = 1;
			int id = (i - j) / 32;
			REP(k, 32) {
				if (i + k >= l1) break;
				if (s[i + k] == '1') a[j][id] |= bit;
				bit <<= 1;
			}
		}
	}

	for (int i = 0, j = 0; i + 32 <= l2; i += 32, j++) {
		unsigned int bit = 1;
		REP(k, 32) {
			if (i + k >= l2) break;
			if (r[i + k] == '1') b[j] |= bit;
			bit <<= 1;
		}
	}

	int Q, p1, p2, len, ans;
	int bl, br, kk, bb;

	Q = get();

	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		if (len <= 32) {
			for (int i = p1, j = p2, k = 0; k < len; i++, j++, k++) {
				ans += (s[i] != r[j]);
			}
			output(ans);
			continue;
		}
		// bl = p2 >> 5;
		// br = (p2 + len - 1) >> 5;

		int n1, n2;
		for (n2 = p2, n1 = p1; n2 < (bl + 1) * N; ++n1, ++n2) {
			ans += (s[n1] != r[n2]);
		}

		bb = n1 & 31;
		kk = n1 >> 5;

		// REPP(i, bl + 1, br - 1) {
		// 	ans += __builtin_popcount(a[bb][kk] ^ b[i]);
		// 	kk++;
		// }

		for (n2 = br * N, n1 = (kk << 5) + bb; n2 < p2 + len; ++n2, ++n1) {
			ans += (s[n1] != r[n2]);
		}

		output(ans);
	}

	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 200005;
unsigned int a[32][200000 / 32 + 5];
unsigned int b[200000 / 32 + 5];

char s[N], r[N];

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int l1, l2;

int main(){
	// freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	//ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	RS(s), RS(r);
	l1 = SL(s), l2 = SL(r);

	REP(j, 32) {
		for (int i = j; i + 32 <= l1; i += 32) {
			unsigned int bit = 1;
			int id = (i - j) / 32;
			REP(k, 32) {
				if (i + k >= l1) break;
				if (s[i + k] == '1') a[j][id] |= bit;
				bit <<= 1;
			}
		}
	}

	for (int i = 0, j = 0; i + 32 <= l2; i += 32, j++) {
		unsigned int bit = 1;
		REP(k, 32) {
			if (i + k >= l2) break;
			if (r[i + k] == '1') b[j] |= bit;
			bit <<= 1;
		}
	}

	int Q, p1, p2, len, ans;
	int bl, br, kk, bb;

	Q = get();

	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		if (len <= 32) {
			for (int i = p1, j = p2, k = 0; k < len; i++, j++, k++) {
				ans += (s[i] != r[j]);
			}
			output(ans);
			continue;
		}
		// bl = p2 >> 5;
		// br = (p2 + len - 1) >> 5;

		// int n1, n2;
		// for (n2 = p2, n1 = p1; n2 < (bl + 1) * N; ++n1, ++n2) {
		// 	ans += (s[n1] != r[n2]);
		// }

		// bb = n1 & 31;
		// kk = n1 >> 5;

		// REPP(i, bl + 1, br - 1) {
		// 	ans += __builtin_popcount(a[bb][kk] ^ b[i]);
		// 	kk++;
		// }

		// for (n2 = br * N, n1 = (kk << 5) + bb; n2 < p2 + len; ++n2, ++n1) {
		// 	ans += (s[n1] != r[n2]);
		// }

		output(ans);
	}

	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 200005;
unsigned int a[32][N / 32 + 5];
unsigned int b[32][N / 32 + 5];

char s[N], r[N];

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int l1, l2;
int bit[1 << 16];

int count(unsigned int x) {
	return bit[x & ((1 << 16) - 1)] + bit[x >> 16];
}

int main(){
	// freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	//ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	RS(s), RS(r);
	l1 = SL(s), l2 = SL(r);
	REP(i, (1 << 16)) bit[i] = __builtin_popcount(i);

	REP(j, 32) {
		for (int i = j, t = 0; i + 32 <= l1; i += 32, t++) {
			unsigned int bit = 1;
			REP(k, 32) {
				if (i + k >= l1) break;
				if (s[i + k] == '1') a[j][t] |= bit;
				bit <<= 1;
			}
		}
	}

	REP(j, 32) {
		for (int i = j, t = 0; i + 32 <= l2; i += 32, t++) {
			unsigned int bit = 1;
			REP(k, 32) {
				if (i + k >= l2) break;
				if (r[i + k] == '1') b[j][t] |= bit;
				bit <<= 1;
			}
		}
	}

	int Q, p1, p2, len, ans;
	int bl, br, kk, bb, pp, qq, left;
	unsigned ta, tb;

	Q = get();

	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		if (len <= 32) {
			for (int i = p1, j = p2, k = 0; k < len; i++, j++, k++) {
				ans += (s[i] != r[j]);
			}
			output(ans);
			continue;
		}

		bl = p2 >> 5;
		br = len >> 5;

		bb = p1 & 31;
		kk = p1 >> 5;
		pp = p2 & 31;
		qq = p2 >> 5;

		for (int i = qq, j = kk, k = 0; k < br; ++i, ++j, ++k){
			ans += count(a[bb][j] ^ b[pp][i]);
		}

		// left = p2 + len - (br << 5);
		// ta = a[bb][kk + br - bl] & ((1U << left) - 1);
		// tb = b[pp][qq + br - bl] & ((1U << left) - 1);
		// ans += __builtin_popcount(ta ^ tb);

		for (int i = ((qq + br) << 5) + pp, j = ((kk + br) << 5) + bb; i < p2 + len; ++i, ++j) {
			ans += (s[j] != r[i]);
		}

		output(ans);
	}

	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 200005;
unsigned int a[32][N / 32 + 5];
unsigned int b[32][N / 32 + 5];

char s[N], r[N];

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int l1, l2;

int main(){
	// freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	//ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	RS(s), RS(r);
	l1 = SL(s), l2 = SL(r);

	REP(j, 32) {
		for (int i = j, t = 0; i + 32 <= l1; i += 32, t++) {
			unsigned int bit = 1;
			REP(k, 32) {
				if (i + k >= l1) break;
				if (s[i + k] == '1') a[j][t] |= bit;
				bit <<= 1;
			}
		}
	}

	REP(j, 32) {
		for (int i = j, t = 0; i + 32 <= l2; i += 32, t++) {
			unsigned int bit = 1;
			REP(k, 32) {
				if (i + k >= l2) break;
				if (r[i + k] == '1') b[j][t] |= bit;
				bit <<= 1;
			}
		}
	}

	int Q, p1, p2, len, ans;
	int bl, br, kk, bb, pp, qq, left;
	unsigned ta, tb;

	Q = get();

	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		if (len <= 32) {
			for (int i = p1, j = p2, k = 0; k < len; i++, j++, k++) {
				ans += (s[i] != r[j]);
			}
			output(ans);
			continue;
		}

		bl = p2 >> 5;
		br = len >> 5;

		bb = p1 & 31;
		kk = p1 >> 5;
		pp = p2 & 31;
		qq = p2 >> 5;

		for (int i = qq, j = kk, k = 0; k < br; ++i, ++j, ++k){
			ans += __builtin_popcount(a[bb][j] ^ b[pp][i]);
		}

		// left = p2 + len - (br << 5);
		// ta = a[bb][kk + br - bl] & ((1U << left) - 1);
		// tb = b[pp][qq + br - bl] & ((1U << left) - 1);
		// ans += __builtin_popcount(ta ^ tb);

		for (int i = ((qq + br) << 5) + pp, j = ((kk + br) << 5) + bb; i < p2 + len; ++i, ++j) {
			ans += (s[j] != r[i]);
		}

		output(ans);
	}

	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 200005;
unsigned int a[32][N / 32 + 5];
unsigned int b[N / 32 + 5];

char s[N], r[N];

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int l1, l2;

int main(){
	// freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	//ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	RS(s), RS(r);
	l1 = SL(s), l2 = SL(r);

	REP(j, 32) {
		for (int i = j, t = 0; i + 32 <= l1; i += 32, t++) {
			unsigned int bit = 1;
			REP(k, 32) {
				if (i + k >= l1) break;
				if (s[i + k] == '1') a[j][t] |= bit;
				bit <<= 1;
			}
		}
	}

	for (int i = 0, j = 0; i + 32 <= l2; i += 32, j++) {
		unsigned int bit = 1;
		REP(k, 32) {
			if (i + k >= l2) break;
			if (r[i + k] == '1') b[j] |= bit;
			bit <<= 1;
		}
	}

	int Q, p1, p2, len, ans;
	int bl, br, kk, bb, n1, n2;

	Q = get();

	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		if (len <= 32) {
			for (int i = p1, j = p2, k = 0; k < len; i++, j++, k++) {
				ans += (s[i] != r[j]);
			}
			output(ans);
			continue;
		}
		bl = p2 >> 5;
		br = (p2 + len - 1) >> 5;

		for (n2 = p2, n1 = p1; n2 < ((bl + 1) << 5); ++n1, ++n2) {
			ans += (s[n1] != r[n2]);
		}

		bb = n1 & 31;
		kk = n1 >> 5;

		REPP(i, bl + 1, br - 1) {
			ans += __builtin_popcount(a[bb][kk] ^ b[i]);
			kk++;
		}

		for (n2 = (br << 5), n1 = (kk << 5) + bb; n2 < p2 + len; ++n2, ++n1) {
			ans += (s[n1] != r[n2]);
		}

		output(ans);
	}

	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 200005;
unsigned int a[32][N / 32 + 5];
unsigned int b[N / 32 + 5];

char s[N], r[N];

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int l1, l2;

int main(){
	// freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	//ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	RS(s), RS(r);
	l1 = SL(s), l2 = SL(r);

	REP(j, 32) {
		for (int i = j, t = 0; i + 32 <= l1; i += 32, t++) {
			unsigned int bit = 1;
			REP(k, 32) {
				if (i + k >= l1) break;
				if (s[i + k] == '1') a[j][t] |= bit;
				bit <<= 1;
			}
		}
	}

	for (int i = 0, j = 0; i + 32 <= l2; i += 32, j++) {
		unsigned int bit = 1;
		REP(k, 32) {
			if (i + k >= l2) break;
			if (r[i + k] == '1') b[j] |= bit;
			bit <<= 1;
		}
	}

	int Q, p1, p2, len, ans;
	int bl, br, kk, bb;

	Q = get();

	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		if (len <= 32) {
			for (int i = p1, j = p2, k = 0; k < len; i++, j++, k++) {
				ans += (s[i] != r[j]);
			}
			output(ans);
			continue;
		}
		bl = p2 >> 5;
		br = (p2 + len - 1) >> 5;

		int n1, n2;
		for (n2 = p2, n1 = p1; n2 < ((bl + 1) << 5); ++n1, ++n2) {
			ans += (s[n1] != r[n2]);
		}

		bb = n1 & 31;
		kk = n1 >> 5;

		REPP(i, bl + 1, br - 1) {
			kk++;
			ans += __builtin_popcount(a[bb][kk] ^ b[i]);
		}

		for (n2 = br * N, n1 = (kk << 5) + bb; n2 < p2 + len; ++n2, ++n1) {
			ans += (s[n1] != r[n2]);
		}

		output(ans);
	}

	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 200005;
unsigned int a[32][200000 / 32 + 5];
unsigned int b[200000 / 32 + 5];

char s[N], r[N];

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int l1, l2;

int main(){
	// freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	//ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	RS(s), RS(r);
	l1 = SL(s), l2 = SL(r);

	REP(j, 32) {
		for (int i = j; i + 32 <= l1; i += 32) {
			unsigned int bit = 1;
			int id = (i - j) / 32;
			REP(k, 32) {
				if (i + k >= l1) break;
				if (s[i + k] == '1') a[j][id] |= bit;
				bit <<= 1;
			}
		}
	}

	for (int i = 0, j = 0; i + 32 <= l2; i += 32, j++) {
		unsigned int bit = 1;
		REP(k, 32) {
			if (i + k >= l2) break;
			if (r[i + k] == '1') b[j] |= bit;
			bit <<= 1;
		}
	}

	int Q, p1, p2, len, ans;
	int bl, br, kk, bb;

	Q = get();

	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		if (len <= 32) {
			for (int i = p1, j = p2, k = 0; k < len; i++, j++, k++) {
				ans += (s[i] != r[j]);
			}
			output(ans);
			continue;
		}
		// bl = p2 >> 5;
		// br = (p2 + len - 1) >> 5;

		int n1, n2;
		// for (n2 = p2, n1 = p1; n2 < (bl + 1) * N; ++n1, ++n2) {
		// 	ans += (s[n1] != r[n2]);
		// }

		// bb = n1 & 31;
		// kk = n1 >> 5;

		// REPP(i, bl + 1, br - 1) {
		// 	ans += __builtin_popcount(a[bb][kk] ^ b[i]);
		// 	kk++;
		// }

		for (n2 = br * N, n1 = (kk << 5) + bb; n2 < p2 + len; ++n2, ++n1) {
			ans += (s[n1] != r[n2]);
		}

		output(ans);
	}

	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 200005;
unsigned int a[32][200000 / 32 + 5];
unsigned int b[200000 / 32 + 5];

char s[N], r[N];

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int l1, l2;

int main(){
	// freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	//ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	RS(s), RS(r);
	l1 = SL(s), l2 = SL(r);

	REP(j, 32) {
		for (int i = j; i + 32 <= l1; i += 32) {
			unsigned int bit = 1;
			int id = (i - j) / 32;
			REP(k, 32) {
				if (i + k >= l1) break;
				if (s[i + k] == '1') a[j][id] |= bit;
				bit <<= 1;
			}
		}
	}

	for (int i = 0, j = 0; i + 32 <= l2; i += 32, j++) {
		unsigned int bit = 1;
		REP(k, 32) {
			if (i + k >= l2) break;
			if (r[i + k] == '1') b[j] |= bit;
			bit <<= 1;
		}
	}

	int Q, p1, p2, len, ans;
	int bl, br, kk, bb;
	unsigned int ta, tb;
	Q = get();

	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		if (len <= 32) {
			for (int i = p1, j = p2, k = 0; k < len; i++, j++, k++) {
				ans += (s[i] != r[j]);
			}
			output(ans);
			continue;
		}
		bl = p2 / 32;
		br = (p2 + len - 1) / 32;

		int n1, n2;
		for (n2 = p2, n1 = p1; n2 < (bl + 1) * N; ++n1, ++n2) {
			ans += (s[n1] != r[n2]);
		}

		bb = n1 & 31;
		kk = n1 >> 5;

		REPP(i, bl + 1, br - 1) {
			ans += __builtin_popcount(a[bb][kk] ^ b[i]);
			kk++;
		}

		for (n2 = br * N, n1 = (kk << 5) + bb; n2 < p2 + len; ++n2, ++n1) {
			ans += (s[n1] != r[n2]);
		}

		// tb = b[bl] >> (p2 - bl * N);
		// bb = p1 % 32, kk = (p1 - bb) / 32;
		// ta = a[bb][kk] & ((1 << (p2 - bl * N + 1)) - 1);
		// ans += __builtin_popcount(ta ^ tb);

		// REPP(i, bl + 1, br - 1) {
		// 	kk++;
		// 	ans += __builtin_popcount(a[bb][kk] ^ b[i]);
		// }

		// tb = b[br] & ((1 << (p2 - br * N + len)) - 1);
		// ta = a[bb][kk]

		// ans += __builtin_popcount(ta ^ tb);
		output(ans);
	}

	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 200005;
unsigned int a[32][N / 32 + 5];
unsigned int b[32][N / 32 + 5];

char s[N], r[N];

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int l1, l2;

int main(){
	// freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	//ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	RS(s), RS(r);
	l1 = SL(s), l2 = SL(r);

	REP(j, 32) {
		for (int i = j, t = 0; i + 32 <= l1; i += 32, t++) {
			unsigned int bit = 1;
			REP(k, 32) {
				if (i + k >= l1) break;
				if (s[i + k] == '1') a[j][t] |= bit;
				bit <<= 1;
			}
		}
	}

	REP(j, 32) {
		for (int i = j, t = 0; i + 32 <= l2; i += 32, t++) {
			unsigned int bit = 1;
			REP(k, 32) {
				if (i + k >= l2) break;
				if (r[i + k] == '1') b[j][t] |= bit;
				bit <<= 1;
			}
		}
	}

	int Q, p1, p2, len, ans;
	int bl, br, kk, bb, pp, qq, left;
	unsigned ta, tb;

	Q = get();

	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		if (len <= 32) {
			for (int i = p1, j = p2, k = 0; k < len; i++, j++, k++) {
				ans += (s[i] != r[j]);
			}
			output(ans);
			continue;
		}

		bl = p2 >> 5;
		br = (p2 + len - 1) >> 5;

		bb = p1 & 31;
		kk = p1 >> 5;
		pp = p2 & 31;
		qq = p2 >> 5;

		for (int i = qq, j = kk, k = bl; k < br; ++i, ++j, ++k){
			ans += __builtin_popcount(a[bb][j] ^ b[pp][i]);
		}

		// left = p2 + len - (br << 5);
		// ta = a[bb][kk + br - bl] & ((1U << left) - 1);
		// tb = b[pp][qq + br - bl] & ((1U << left) - 1);
		// ans += __builtin_popcount(ta ^ tb);

		for (int i = ((qq + br - bl) << 5) + pp, j = ((kk + br - bl) << 5) + bb; i < p2 + len; ++i, ++j) {
			ans += (s[j] != r[i]);
		}

		output(ans);
	}

	return 0;
}


#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <bitset>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 600;
bitset<N> b[200000 / N + 5];
vector<bitset<N> > a[N];
VI mp[N][N];
int cnt[N];
string s, r;

int l1, l2;

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int main(){
	// freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	// ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	cin >> s >> r;
	l1 = SZ(s), l2 = SZ(r);
	if (l1 % N) l1 = (l1 / N + 1) * N;
	if (l2 % N) l2 = (l2 / N + 1) * N;
	int cnt1 = l1 / N;
	int cnt2 = l2 / N;
	s.resize(l1, '0');
	r.resize(l2, '0');

	// cout << s << endl;
	// cout << r << endl;

	REP(i, N) {
		for (int k = i; k + N <= l1; k += N){
			cnt[i]++;
			a[i].push_back(bitset<N> (s.substr(k, N)));
		}
	}

	// cout << cnt[0] << endl;

	for (int i = 0, j = 0; i + N <= l2; i += N, j++) {
		b[j] = bitset<N> (r.substr(i, N));
	}

	REP(i, N) {
		REP(j, cnt[i]) {
			REP(k, cnt2) {
				mp[i][k].push_back((a[i][j] ^ b[k]).count());
			}
		}
	}

	int Q;
	Q = get();
	int p1, p2, len;
	int st, kk, bb;
	int bl, br;
	int ans;
	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		// cout << p1 << ' ' << p2 << endl;
		// cout << s << endl << r << endl;
		if (len <= N) {
			for(int i = p1; i < p1 + len; i++) {
				if (s[i] != r[p2 + i - p1]) ans++;
			}
			output(ans);
		}
		else {
			bl = p2 / N;
			br = (p2 + len - 1) / N;
			for(int i = p2, j = p1; i < (bl + 1) * N; i++, j++) {
				if (s[j] != r[i]) ans++;
			}
			for (int i = br * N, j = br * N + p1 - p2; i < p2 + len; i++, j++) {
				if (s[j] != r[i]) ans++;
			}

			st = p1 - p2 + (bl + 1) * N;
			bb = st % N, kk = (st - bb) / N;
			for(int i = bl + 1, j = kk; i <= br - 1; ++i, j++) {
				ans += mp[bb][i][j];
			}
			output(ans);
		}
	}

	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 200005;
unsigned int a[32][N / 32 + 5];
unsigned int b[N / 32 + 5];

char s[N], r[N];

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int l1, l2;

int main(){
	// freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	//ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	RS(s), RS(r);
	l1 = SL(s), l2 = SL(r);

	REP(j, 32) {
		for (int i = j; i + 32 <= l1; i += 32) {
			unsigned int bit = 1;
			int id = (i - j) / 32;
			REP(k, 32) {
				if (i + k >= l1) break;
				if (s[i + k] == '1') a[j][id] |= bit;
				bit <<= 1;
			}
		}
	}

	for (int i = 0, j = 0; i + 32 <= l2; i += 32, j++) {
		unsigned int bit = 1;
		REP(k, 32) {
			if (i + k >= l2) break;
			if (r[i + k] == '1') b[j] |= bit;
			bit <<= 1;
		}
	}

	int Q, p1, p2, len, ans;
	int bl, br, kk, bb;

	Q = get();

	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		if (len <= 32) {
			for (int i = p1, j = p2, k = 0; k < len; i++, j++, k++) {
				ans += (s[i] != r[j]);
			}
			output(ans);
			continue;
		}
		bl = p2 >> 5;
		br = (p2 + len - 1) >> 5;

		int n1, n2;
		for (n2 = p2, n1 = p1; n2 < (bl + 1) * N; ++n1, ++n2) {
			ans += (s[n1] != r[n2]);
		}

		bb = n1 & 31;
		kk = n1 >> 5;

		// REPP(i, bl + 1, br - 1) {
		// 	ans += __builtin_popcount(a[bb][kk] ^ b[i]);
		// 	kk++;
		// }

		// for (n2 = br * N, n1 = (kk << 5) + bb; n2 < p2 + len; ++n2, ++n1) {
		// 	ans += (s[n1] != r[n2]);
		// }

		output(ans);
	}

	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 200005;
unsigned int a[32][N / 32 + 5];
unsigned int b[32][N / 32 + 5];

char s[N], r[N];

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int l1, l2;

int main(){
	// freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	//ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	RS(s), RS(r);
	l1 = SL(s), l2 = SL(r);

	REP(j, 32) {
		for (int i = j, t = 0; i + 32 <= l1; i += 32, t++) {
			unsigned int bit = 1;
			REP(k, 32) {
				if (i + k >= l1) break;
				if (s[i + k] == '1') a[j][t] |= bit;
				bit <<= 1;
			}
		}
	}

	REP(j, 32) {
		for (int i = j, t = 0; i + 32 <= l2; i += 32, t++) {
			unsigned int bit = 1;
			REP(k, 32) {
				if (i + k >= l2) break;
				if (r[i + k] == '1') b[j][t] |= bit;
				bit <<= 1;
			}
		}
	}

	int Q, p1, p2, len, ans;
	int bl, br, kk, bb, pp, qq, n1, n2;
	unsigned ta, tb;

	Q = get();

	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		if (len <= 32) {
			for (int i = p1, j = p2, k = 0; k < len; i++, j++, k++) {
				ans += (s[i] != r[j]);
			}
			output(ans);
			continue;
		}

		bl = p2 >> 5;
		br = (p2 + len - 1) >> 5;

		bb = p1 & 31;
		kk = p1 >> 5;
		pp = p2 & 31;
		qq = p2 >> 5;

		for (int i = qq, j = kk, k = bl; k < br; ++i, ++j, ++k){
			ans += __builtin_popcount(a[bb][j] ^ b[pp][i]);
		}

		int left = p2 + len - (br << 5);
		ta = a[bb][kk + br - bl] & ((1 << left) - 1);
		tb = b[pp][qq + br - bl] & ((1 << left) - 1);
		ans += __builtin_popcount(ta ^ tb);

		output(ans);
	}

	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 200005;
unsigned int a[32][N / 32 + 5];
unsigned int b[N / 32 + 5];

char s[N], r[N];

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int l1, l2;

int main(){
	// freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	//ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	RS(s), RS(r);
	l1 = SL(s), l2 = SL(r);

	REP(j, 32) {
		for (int i = j; i + 32 <= l1; i += 32) {
			unsigned int bit = 1;
			int id = (i - j) / 32;
			REP(k, 32) {
				if (i + k >= l1) break;
				if (s[i + k] == '1') a[j][id] |= bit;
				bit <<= 1;
			}
		}
	}

	for (int i = 0, j = 0; i + 32 <= l2; i += 32, j++) {
		unsigned int bit = 1;
		REP(k, 32) {
			if (i + k >= l2) break;
			if (r[i + k] == '1') b[j] |= bit;
			bit <<= 1;
		}
	}

	int Q, p1, p2, len, ans;
	int bl, br, kk, bb;

	Q = get();

	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		if (len <= 32) {
			for (int i = p1, j = p2, k = 0; k < len; i++, j++, k++) {
				ans += (s[i] != r[j]);
			}
			output(ans);
			continue;
		}
		bl = p2 >> 5;
		br = (p2 + len - 1) >> 5;

		int n1, n2;
		for (n2 = p2, n1 = p1; n2 < ((bl + 1) << 5); ++n1, ++n2) {
			ans += (s[n1] != r[n2]);
		}

		bb = n1 & 31;
		kk = n1 >> 5;

		REPP(i, bl + 1, br - 1) {
			ans += __builtin_popcount(a[bb][kk] ^ b[i]);
			kk++;
		}

		for (n2 = br * N, n1 = (kk << 5) + bb; n2 < p2 + len; ++n2, ++n1) {
			ans += (s[n1] != r[n2]);
		}

		output(ans);
	}

	return 0;
}


#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <bitset>

#define LL long long
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define VP vector<PII>
#define VS vector<string>
#define PII pair<int, int>
#define SZ(a) ((int) a.size())
#define ALL(a) a.begin(), a.end()
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))

#define SL(a) strlen(a)
#define RS(s) scanf("%s", (s))
#define PI(r) printf("%d\n", (r))
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))

#define DBG(x, s) cout << (x) << ' ' << (s) << endl
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
#define RED(i, n) for (int i = (int) (n - 1); i >= 0; --i)
#define REDD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)

#define L (x << 1)
#define R ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LC L, l, MID
#define RC R, MID + 1, r
#define LB(x) ((x) & (-(x)))

#define EPS 1e-7
#define INF 0x3f3f3f3f
#define LIM (1ll << 60)

using namespace std;

int n, m;

const int N = 831;
bitset<N> b[200000 / N + 5];
vector<bitset<N> > a[N];
VI mp[N][N];
int cnt[N];
string s, r;

int l1, l2;

int get() {
	char c;
	while (c = getchar(), (c < '0' || c > '9') && (c != '-'));
	bool flag = (c == '-');
	if (flag) c = getchar();
	int x = 0;
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	return flag ? -x : x;
}

void output(int x) { //int
	if (x < 0) putchar('-'), x = -x;
	int len = 0, bit[10]; // LL  -> bit[20]
	while (x) {
		bit[len++] = x % 10;
		x /= 10;
	}
	if (!len) bit[len++] = 0;
	while (len--) putchar(bit[len] + 48);
	putchar('\n');
}

int main(){
	// freopen("cf.in", "r", stdin);
	//freopen("1.ans", "w", stdout);
	// ios :: sync_with_stdio(0);

	int t, x, y, z, ca = 1;

	cin >> s >> r;
	l1 = SZ(s), l2 = SZ(r);
	if (l1 % N) l1 = (l1 / N + 1) * N;
	if (l2 % N) l2 = (l2 / N + 1) * N;
	int cnt1 = l1 / N;
	int cnt2 = l2 / N;
	s.resize(l1, '0');
	r.resize(l2, '0');

	// cout << s << endl;
	// cout << r << endl;

	REP(i, N) {
		for (int k = i; k + N <= l1; k += N){
			cnt[i]++;
			a[i].push_back(bitset<N> (s.substr(k, N)));
		}
	}

	// cout << cnt[0] << endl;

	for (int i = 0, j = 0; i + N <= l2; i += N, j++) {
		b[j] = bitset<N> (r.substr(i, N));
	}

	REP(i, N) {
		REP(j, cnt[i]) {
			REP(k, cnt2) {
				mp[i][k].push_back((a[i][j] ^ b[k]).count());
			}
		}
	}

	int Q;
	Q = get();
	int p1, p2, len;
	int st, kk, bb;
	int bl, br;
	int ans;
	while (Q--) {
		ans = 0;
		p1 = get();
		p2 = get();
		len = get();

		// cout << p1 << ' ' << p2 << endl;
		// cout << s << endl << r << endl;
		if (len <= N) {
			for(int i = p1; i < p1 + len; i++) {
				if (s[i] != r[p2 + i - p1]) ans++;
			}
			output(ans);
		}
		else {
			bl = p2 / N;
			br = (p2 + len - 1) / N;
			for(int i = p2, j = p1; i < (bl + 1) * N; i++, j++) {
				if (s[j] != r[i]) ans++;
			}
			for (int i = br * N, j = br * N + p1 - p2; i < p2 + len; i++, j++) {
				if (s[j] != r[i]) ans++;
			}

			st = p1 - p2 + (bl + 1) * N;
			bb = st % N, kk = (st - bb) / N;
			for(int i = bl + 1, j = kk; i <= br - 1; ++i, j++) {
				ans += mp[bb][i][j];
			}
			output(ans);
		}
	}

	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#define maxn 530010
#define pi M_PI
using namespace std;
struct cpx{
	double r, i;
	cpx(){}
	cpx(double _r, double _i){r = _r; i = _i;}
	cpx operator + (const cpx &b){return cpx(r + b.r, i + b.i);}
	cpx operator - (const cpx &b){return cpx(r - b.r, i - b.i);}
	cpx operator * (const cpx &b){return cpx(r * b.r - i * b.i, r * b.i + i * b.r);}
}A[maxn], B[maxn];
int c[maxn][300];
void fft(cpx *a, int n, int on)
{
	for (int i = 0, j = 0; i < n; ++ i){
		if (i > j) swap(a[i], a[j]);
		for (int l = (n >> 1); (j ^= l) < l; l >>= 1);
	}
	cpx u, t, wm, w;
	for (int m = 2; m <= n; m <<= 1){
		wm = cpx(cos(2 * pi * on / m), sin(2 * pi * on / m));
		for (int j = 0; j < n; j += m){
			w = cpx(1, 0);
			for (int k = j; k < j + m / 2; ++ k){
				u = a[k]; t = a[k + m / 2] * w;
				a[k] = u + t; a[k + m / 2] = u - t;
				w = w * wm;
			}
		}
	}
	if (on == -1) for (int i = 0; i < n; ++ i) a[i].r /= (double)n;
}
void gn(int &x)
{
	x = 0; char ch = getchar();
	while (ch < '0' || ch > '9') ch = getchar();
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
char s[maxn];
int a[maxn], b[maxn], n, m, q, blo, ans, pos;
int asq[maxn], bsq[maxn];
int main()
{
	scanf("%s", s + 1); n = strlen(s + 1);
	for (int i = 1; i <= n; ++ i){
		asq[i] = a[i] = s[i] - '0';
		asq[i] += asq[i - 1];
	}
	memset(s, 0, sizeof(s));
	scanf("%s", s + 1); m = strlen(s + 1);
	for (int i = 1; i <= m; ++ i){
		bsq[i] = b[i] = s[i] - '0';
		bsq[i] += bsq[i - 1];
	}
	gn(q); int bx, by, x, y, len;
	blo = int(1.5 * ceil(sqrt(1.0 * n * log2(1.0 * n))));
	int cnt = (n - 1) / blo + 1;
	len = 1; for ( ; len <= (m + blo + 2); len <<= 1);
	for (int i = 1; i <= m; ++ i) B[i].r = b[m - i + 1];
	fft(B, len, 1);
	for (int ci = 1; ci < cnt; ++ ci){
		memset(A, 0, sizeof(A));
		for (int j = 1; j <= blo; ++ j) A[j].r = a[j + blo * (ci - 1)];
		fft(A, len, 1);
		for (int i = 0; i < len; ++ i) A[i] = A[i] * B[i];
		fft(A, len, -1);
		for (int i = blo * (ci - 1); i <= n + m; ++ i) c[i][ci] = int(round(A[i - blo * (ci - 1)].r));
	}
	for (int i = 1; i <= q; ++ i){
		gn(x); gn(y); gn(len);
		++ x; ++ y; ans = 0;
		pos = m + 1 + x - y;
		ans += asq[x + len - 1] - asq[x - 1];
		ans += bsq[y + len - 1] - bsq[y - 1];
		bx = (x - 1) / blo; by = (x + len - 1) / blo;
		if (bx == by){
			for (int j = 0; j < len; ++ j)
				ans -= 2 * a[x + j] * b[y + j];
		}else{
			for (int j = bx + 1; j <= by; ++ j) ans -= 2 * c[pos][j];
			for (int j = max(x + 1 - y, bx * blo + 1); j < x; ++ j) ans += 2 * a[j] * b[j - x + y];
			for (int j = max(x + 1 - y, by * blo + 1); j < x + len; ++ j) ans -= 2 * a[j] * b[j - x + y];
		}
		printf("%d\n", ans);
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define maxn 530010
#define pi M_PI
using namespace std;
struct cpx{
	double r, i;
	cpx(){}
	cpx(double _r, double _i){r = _r; i = _i;}
	cpx operator + (const cpx &b){return cpx(r + b.r, i + b.i);}
	cpx operator - (const cpx &b){return cpx(r - b.r, i - b.i);}
	cpx operator * (const cpx &b){return cpx(r * b.r - i * b.i, r * b.i + i * b.r);}
}A[maxn], B[maxn];
void fft(cpx *a, int n, int on)
{
	for (int i = 0, j = 0; i < n; ++ i){
		if (i > j) swap(a[i], a[j]);
		for (int l = (n >> 1); (j ^= l) < l; l >>= 1);
	}
	cpx u, t, wm, w;
	for (int m = 2; m <= n; m <<= 1){
		wm = cpx(cos(2 * pi * on / m), sin(2 * pi * on / m));
		for (int j = 0; j < n; j += m){
			w = cpx(1, 0);
			for (int k = j; k < j + m / 2; ++ k){
				u = a[k]; t = a[k + m / 2] * w;
				a[k] = u + t; a[k + m / 2] = u - t;
				w = w * wm;
			}
		}
	}
	if (on == -1) for (int i = 0; i < n; ++ i) a[i].r /= (double)n;
}
void gn(int &x)
{
	x = 0; char ch = getchar();
	while (ch < '0' || ch > '9') ch = getchar();
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
char s[maxn];
int a[maxn], b[maxn], n, m, q, blo, ans[maxn], pos[maxn];
int asq[maxn], bsq[maxn];
int g[maxn], ei;
struct edge{
	int id, nxt;
}e[maxn * 4];
void ae(int a, int b)
{
	e[++ ei].id = b; e[ei].nxt = g[a]; g[a] = ei;
}
int main()
{
	scanf("%s", s + 1); n = strlen(s + 1);
	for (int i = 1; i <= n; ++ i){
		asq[i] = a[i] = s[i] - '0';
		asq[i] += asq[i - 1];
	}
	memset(s, 0, sizeof(s));
	scanf("%s", s + 1); m = strlen(s + 1);
	for (int i = 1; i <= m; ++ i){
		bsq[i] = b[i] = s[i] - '0';
		bsq[i] += bsq[i - 1];
	}
	gn(q); int bx, by, x, y, len;
	blo = int(ceil(1.0 * n * sqrt(1.0 * log2(1.0 * n) / (double)(2.0 * q))));
	//blo = int(ceil(sqrt(1.0 * n * log2(1.0 * n))));
	int cnt = (n - 1) / blo + 1;
	for (int i = 1; i <= q; ++ i){
		gn(x); gn(y); gn(len);
		++ x; ++ y;
		pos[i] = m + 1 + x - y;
		ans[i] += asq[x + len - 1] - asq[x - 1];
		ans[i] += bsq[y + len - 1] - bsq[y - 1];
		bx = (x - 1) / blo; by = (x + len - 1) / blo;
		if (bx == by){
			for (int j = 0; j < len; ++ j)
				ans[i] -= 2 * a[x + j] * b[y + j];
		}else{
			ae(bx, 2 * i); ae(by, 2 * i + 1);
			for (int j = bx * blo + 1; j < x; ++ j)
				if (j - x + y >= 1 && j - x + y <= m) ans[i] += 2 * a[j] * b[j - x + y];
			for (int j = by * blo + 1; j < x + len; ++ j)
				if (j - x + y >= 1 && j - x + y <= m) ans[i] -= 2 * a[j] * b[j - x + y];
		}
	}
	len = 1; for ( ; len <= (m + n + 2); len <<= 1);
	for (int i = 1; i <= m; ++ i) B[i].r = b[m - i + 1];
	fft(B, len, 1);
	for (int ci = 1; ci <= cnt; ++ ci){
		memset(A, 0, sizeof(A));
		for (int j = 1; j <= blo * ci; ++ j) A[j].r = a[j];
		fft(A, len, 1);
		for (int i = 0; i < len; ++ i) A[i] = A[i] * B[i];
		fft(A, len, -1);
		for (int i = g[ci]; i; i = e[i].nxt)
			if (e[i].id & 1)
				ans[e[i].id / 2] -= 2 * int(round(A[pos[e[i].id / 2]].r));
			else
				ans[e[i].id / 2] += 2 * int(round(A[pos[e[i].id / 2]].r));
	}
	for (int i = 1; i <= q; ++ i) printf("%d\n", ans[i]);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#define maxn 530010
#define pi M_PI
using namespace std;
struct cpx{
	double r, i;
	cpx(){}
	cpx(double _r, double _i){r = _r; i = _i;}
	cpx operator + (const cpx &b){return cpx(r + b.r, i + b.i);}
	cpx operator - (const cpx &b){return cpx(r - b.r, i - b.i);}
	cpx operator * (const cpx &b){return cpx(r * b.r - i * b.i, r * b.i + i * b.r);}
}A[maxn], B[maxn];
int c[maxn][110];
void fft(cpx *a, int n, int on)
{
	for (int i = 0, j = 0; i < n; ++ i){
		if (i > j) swap(a[i], a[j]);
		for (int l = (n >> 1); (j ^= l) < l; l >>= 1);
	}
	cpx u, t, wm, w;
	for (int m = 2; m <= n; m <<= 1){
		wm = cpx(cos(2 * pi * on / m), sin(2 * pi * on / m));
		for (int j = 0; j < n; j += m){
			w = cpx(1, 0);
			for (int k = j; k < j + m / 2; ++ k){
				u = a[k]; t = a[k + m / 2] * w;
				a[k] = u + t; a[k + m / 2] = u - t;
				w = w * wm;
			}
		}
	}
	if (on == -1) for (int i = 0; i < n; ++ i) a[i].r /= (double)n;
}
void gn(int &x)
{
	x = 0; char ch = getchar();
	while (ch < '0' || ch > '9') ch = getchar();
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
char s[maxn];
int a[maxn], b[maxn], n, m, q, blo, ans, pos;
int asq[maxn], bsq[maxn];
int main()
{
	scanf("%s", s + 1); n = strlen(s + 1);
	for (int i = 1; i <= n; ++ i){
		asq[i] = a[i] = s[i] - '0';
		asq[i] += asq[i - 1];
	}
	memset(s, 0, sizeof(s));
	scanf("%s", s + 1); m = strlen(s + 1);
	for (int i = 1; i <= m; ++ i){
		bsq[i] = b[i] = s[i] - '0';
		bsq[i] += bsq[i - 1];
	}
	gn(q); int bx, by, x, y, len;
	blo = int(1.5 * ceil(sqrt(1.0 * n * log2(1.0 * n))));
	int cnt = (n - 1) / blo + 1;
	len = 1; for ( ; len <= (m + blo + 2); len <<= 1);
	for (int i = 1; i <= m; ++ i) B[i].r = b[m - i + 1];
	fft(B, len, 1);
	for (int ci = 1; ci < cnt; ++ ci){
		memset(A, 0, sizeof(A));
		for (int j = 1; j <= blo; ++ j) A[j].r = a[j + blo * (ci - 1)];
		fft(A, len, 1);
		for (int i = 0; i < len; ++ i) A[i] = A[i] * B[i];
		fft(A, len, -1);
		for (int i = blo * (ci - 1); i <= n + m; ++ i) c[i][ci] = int(round(A[i - blo * (ci - 1)].r));
	}
	for (int i = 1; i <= q; ++ i){
		gn(x); gn(y); gn(len);
		++ x; ++ y; ans = 0;
		pos = m + 1 + x - y;
		ans += asq[x + len - 1] - asq[x - 1];
		ans += bsq[y + len - 1] - bsq[y - 1];
		bx = (x - 1) / blo; by = (x + len - 1) / blo;
		if (bx == by){
			for (int j = 0; j < len; ++ j)
				ans -= 2 * a[x + j] * b[y + j];
		}else{
			for (int j = bx + 1; j <= by; ++ j) ans -= 2 * c[pos][j];
			for (int j = max(x + 1 - y, bx * blo + 1); j < x; ++ j) ans += 2 * a[j] * b[j - x + y];
			for (int j = max(x + 1 - y, by * blo + 1); j < x + len; ++ j) ans -= 2 * a[j] * b[j - x + y];
		}
		printf("%d\n", ans);
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define maxn 530010
#define pi M_PI
using namespace std;
struct cpx{
	double r, i;
	cpx(){}
	cpx(double _r, double _i){r = _r; i = _i;}
	cpx operator + (const cpx &b){return cpx(r + b.r, i + b.i);}
	cpx operator - (const cpx &b){return cpx(r - b.r, i - b.i);}
	cpx operator * (const cpx &b){return cpx(r * b.r - i * b.i, r * b.i + i * b.r);}
}A[maxn], B[maxn];
void fft(cpx *a, int n, int on)
{
	for (int i = 0, j = 0; i < n; ++ i){
		if (i > j) swap(a[i], a[j]);
		for (int l = (n >> 1); (j ^= l) < l; l >>= 1);
	}
	cpx u, t, wm, w;
	for (int m = 2; m <= n; m <<= 1){
		wm = cpx(cos(2 * pi * on / m), sin(2 * pi * on / m));
		for (int j = 0; j < n; j += m){
			w = cpx(1, 0);
			for (int k = j; k < j + m / 2; ++ k){
				u = a[k]; t = a[k + m / 2] * w;
				a[k] = u + t; a[k + m / 2] = u - t;
				w = w * wm;
			}
		}
	}
	if (on == -1) for (int i = 0; i < n; ++ i) a[i].r /= (double)n;
}
void gn(int &x)
{
	x = 0; char ch = getchar();
	while (ch < '0' || ch > '9') ch = getchar();
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
char s[maxn];
int a[maxn], b[maxn], n, m, q, blo, ans[maxn], pos[maxn];
int asq[maxn], bsq[maxn];
int g[maxn], ei;
struct edge{
	int id, nxt;
}e[maxn * 2];
void ae(int a, int b)
{
	e[++ ei].id = b; e[ei].nxt = g[a]; g[a] = ei;
}
int main()
{
	scanf("%s", s + 1); n = strlen(s + 1);
	for (int i = 1; i <= n; ++ i){
		asq[i] = a[i] = s[i] - '0';
		asq[i] += asq[i - 1];
	}
	scanf("%s", s + 1); m = strlen(s + 1);
	for (int i = 1; i <= m; ++ i){
		bsq[i] = b[i] = s[i] - '0';
		bsq[i] += bsq[i - 1];
	}
	gn(q); int bx, by, x, y, len;
	blo = int(ceil(1.0 * n * sqrt(1.0 * log2(1.0 * n) / (double)(2.0 * q))));
	int cnt = (n - 1) / blo + 1;
	for (int i = 1; i <= q; ++ i){
		gn(x); gn(y); gn(len);
		++ x; ++ y;
		pos[i] = m + 1 + x - y;
		ans[i] += asq[x + len - 1] - asq[x - 1];
		ans[i] += bsq[y + len - 1] - bsq[y - 1];
		bx = (x - 1) / blo; by = (x + len - 1) / blo;
		if (bx == by){
			for (int j = 0; j < len; ++ j)
				ans[i] -= 2 * a[x + j] * b[y + j];
		}else{
			ae(bx, 2 * i); ae(by, 2 * i + 1);
			for (int j = bx * blo + 1; j < x; ++ j)
				ans[i] += 2 * a[j] * b[j - x + y];
			for (int j = by * blo + 1; j < x + len; ++ j)
				ans[i] -= 2 * a[j] * b[j - x + y];
		}
	}
	len = 1; for ( ; len <= (m + n + 2); len <<= 1);
	for (int i = 1; i <= m; ++ i) B[i].r = b[m - i + 1];
	fft(B, len, 1);
	for (int ci = 1; ci <= cnt; ++ ci){
		memset(A, 0, sizeof(A));
		for (int j = 1; j <= blo * ci; ++ j) A[j].r = a[j];
		fft(A, len, 1);
		for (int i = 0; i < len; ++ i) A[i] = A[i] * B[i];
		fft(A, len, -1);
		for (int i = g[ci]; i; i = e[i].nxt)
			if (e[i].id & 1)
				ans[e[i].id / 2] -= 2 * int(round(A[pos[e[i].id / 2]].r));
			else
				ans[e[i].id / 2] += 2 * int(round(A[pos[e[i].id / 2]].r));
	}
	for (int i = 1; i <= q; ++ i) printf("%d\n", ans[i]);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#define maxn 530010
#define pi M_PI
using namespace std;
struct cpx{
	double r, i;
	cpx(){}
	cpx(double _r, double _i){r = _r; i = _i;}
	cpx operator + (const cpx &b){return cpx(r + b.r, i + b.i);}
	cpx operator - (const cpx &b){return cpx(r - b.r, i - b.i);}
	cpx operator * (const cpx &b){return cpx(r * b.r - i * b.i, r * b.i + i * b.r);}
}A[maxn], B[maxn];
int c[maxn][110];
void fft(cpx *a, int n, int on)
{
	for (int i = 0, j = 0; i < n; ++ i){
		if (i > j) swap(a[i], a[j]);
		for (int l = (n >> 1); (j ^= l) < l; l >>= 1);
	}
	cpx u, t, wm, w;
	for (int m = 2; m <= n; m <<= 1){
		wm = cpx(cos(2 * pi * on / m), sin(2 * pi * on / m));
		for (int j = 0; j < n; j += m){
			w = cpx(1, 0);
			for (int k = j; k < j + m / 2; ++ k){
				u = a[k]; t = a[k + m / 2] * w;
				a[k] = u + t; a[k + m / 2] = u - t;
				w = w * wm;
			}
		}
	}
	if (on == -1) for (int i = 0; i < n; ++ i) a[i].r /= (double)n;
}
void gn(int &x)
{
	x = 0; char ch = getchar();
	while (ch < '0' || ch > '9') ch = getchar();
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
char s[maxn];
int a[maxn], b[maxn], n, m, q, blo, ans, pos;
int asq[maxn], bsq[maxn];
int main()
{
	scanf("%s", s + 1); n = strlen(s + 1);
	for (int i = 1; i <= n; ++ i){
		asq[i] = a[i] = s[i] - '0';
		asq[i] += asq[i - 1];
	}
	memset(s, 0, sizeof(s));
	scanf("%s", s + 1); m = strlen(s + 1);
	for (int i = 1; i <= m; ++ i){
		bsq[i] = b[i] = s[i] - '0';
		bsq[i] += bsq[i - 1];
	}
	gn(q); int bx, by, x, y, len;
	blo = int(1.5 * ceil(sqrt(1.0 * n * log2(1.0 * n))));
	int cnt = (n - 1) / blo + 1;
	cerr << blo << " " << cnt << endl;
	len = 1; for ( ; len <= (m + blo + 2); len <<= 1);
	for (int i = 1; i <= m; ++ i) B[i].r = b[m - i + 1];
	fft(B, len, 1);
	for (int ci = 1; ci <= cnt; ++ ci){
		memset(A, 0, sizeof(A));
		for (int j = 1; j <= blo; ++ j) A[j].r = a[j + blo * (ci - 1)];
		fft(A, len, 1);
		for (int i = 0; i < len; ++ i) A[i] = A[i] * B[i];
		fft(A, len, -1);
		for (int i = blo * (ci - 1); i <= n + m; ++ i) c[i][ci] = int(round(A[i - blo * (ci - 1)].r));
	}
	for (int i = 1; i <= q; ++ i){
		gn(x); gn(y); gn(len);
		++ x; ++ y; ans = 0;
		pos = m + 1 + x - y;
		ans += asq[x + len - 1] - asq[x - 1];
		ans += bsq[y + len - 1] - bsq[y - 1];
		bx = (x - 1) / blo; by = (x + len - 1) / blo;
		if (bx == by){
			for (int j = 0; j < len; ++ j)
				ans -= 2 * a[x + j] * b[y + j];
		}else{
			for (int j = bx + 1; j <= by; ++ j) ans -= 2 * c[pos][j];
			int tmp = 0;
			for (int j = bx + 1; j <= by; ++ j) tmp += 2 * c[pos][j];
			for (int j = max(x + 1 - y, bx * blo + 1); j < x; ++ j) ans += 2 * a[j] * b[j - x + y];
			for (int j = max(x + 1 - y, by * blo + 1); j < x + len; ++ j) ans -= 2 * a[j] * b[j - x + y];
		}
		printf("%d\n", ans);
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define maxn 530010
#define pi M_PI
using namespace std;
struct cpx{
	double r, i;
	cpx(){}
	cpx(double _r, double _i){r = _r; i = _i;}
	cpx operator + (const cpx &b){return cpx(r + b.r, i + b.i);}
	cpx operator - (const cpx &b){return cpx(r - b.r, i - b.i);}
	cpx operator * (const cpx &b){return cpx(r * b.r - i * b.i, r * b.i + i * b.r);}
}A[maxn], B[maxn];
void fft(cpx *a, int n, int on)
{
	for (int i = 0, j = 0; i < n; ++ i){
		if (i > j) swap(a[i], a[j]);
		for (int l = (n >> 1); (j ^= l) < l; l >>= 1);
	}
	cpx u, t, wm, w;
	for (int m = 2; m <= n; m <<= 1){
		wm = cpx(cos(2 * pi * on / m), sin(2 * pi * on / m));
		for (int j = 0; j < n; j += m){
			w = cpx(1, 0);
			for (int k = j; k < j + m / 2; ++ k){
				u = a[k]; t = a[k + m / 2] * w;
				a[k] = u + t; a[k + m / 2] = u - t;
				w = w * wm;
			}
		}
	}
	if (on == -1) for (int i = 0; i < n; ++ i) a[i].r /= (double)n;
}
void gn(int &x)
{
	x = 0; char ch = getchar();
	while (ch < '0' || ch > '9') ch = getchar();
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
char s[maxn];
int a[maxn], b[maxn], n, m, q, blo, ans[maxn], pos[maxn];
int asq[maxn], bsq[maxn];
int g[maxn], ei;
struct edge{
	int id, nxt;
}e[maxn * 2];
void ae(int a, int b)
{
	e[++ ei].id = b; e[ei].nxt = g[a]; g[a] = ei;
}
int main()
{
	scanf("%s", s + 1); n = strlen(s + 1);
	for (int i = 1; i <= n; ++ i){
		asq[i] = a[i] = s[i] - '0';
		asq[i] += asq[i - 1];
	}
	memset(s, 0, sizeof(s));
	scanf("%s", s + 1); m = strlen(s + 1);
	for (int i = 1; i <= m; ++ i){
		bsq[i] = b[i] = s[i] - '0';
		bsq[i] += bsq[i - 1];
	}
	gn(q); int bx, by, x, y, len;
	blo = int(ceil(1.0 * n * sqrt(1.0 * log2(1.0 * n) / (double)(2.0 * q))));
	int cnt = (n - 1) / blo + 1;
	for (int i = 1; i <= q; ++ i){
		gn(x); gn(y); gn(len);
		++ x; ++ y;
		pos[i] = m + 1 + x - y;
		ans[i] += asq[x + len - 1] - asq[x - 1];
		ans[i] += bsq[y + len - 1] - bsq[y - 1];
		bx = (x - 1) / blo; by = (x + len - 1) / blo;
		if (bx == by){
			for (int j = 0; j < len; ++ j)
				ans[i] -= 2 * a[x + j] * b[y + j];
		}else{
			ae(bx, 2 * i); ae(by, 2 * i + 1);
			for (int j = bx * blo + 1; j < x; ++ j)
				if (j - x + y >= 1 && j - x + y <= m) ans[i] += 2 * a[j] * b[j - x + y];
			for (int j = by * blo + 1; j < x + len; ++ j)
				if (j - x + y >= 1 && j - x + y <= m) ans[i] -= 2 * a[j] * b[j - x + y];
		}
	}
	len = 1; for ( ; len <= (m + n + 2); len <<= 1);
	for (int i = 1; i <= m; ++ i) B[i].r = b[m - i + 1];
	fft(B, len, 1);
	for (int ci = 1; ci <= cnt; ++ ci){
		memset(A, 0, sizeof(A));
		for (int j = 1; j <= blo * ci; ++ j) A[j].r = a[j];
		fft(A, len, 1);
		for (int i = 0; i < len; ++ i) A[i] = A[i] * B[i];
		fft(A, len, -1);
		for (int i = g[ci]; i; i = e[i].nxt)
			if (e[i].id & 1)
				ans[e[i].id / 2] -= 2 * int(round(A[pos[e[i].id / 2]].r));
			else
				ans[e[i].id / 2] += 2 * int(round(A[pos[e[i].id / 2]].r));
	}
	for (int i = 1; i <= q; ++ i) printf("%d\n", ans[i]);
	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-14
#define lson   l, m, rt<<1
#define rson   m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pf(x) ((x)*(x))
#define pb push_back
#define pi acos(-1.0)
#define in freopen("solve_in.txt", "r", stdin);
#define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
using namespace std;
typedef long long LL;
typedef map<LL, int> MPS;
typedef pair<int, int> PII;
typedef MPS::iterator IT;
const int maxn = 200000 + 10;

bitset<maxn> b[2];

struct Complex {
    double x, y;
    Complex() {}
    Complex(double x, double y):x(x), y(y) {}
};
inline Complex operator + (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x+b.x;
    c.y = a.y+b.y;
    return c;
}
inline Complex operator - (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x-b.x;
    c.y = a.y-b.y;
    return c;
}
inline Complex operator * (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x*b.x-a.y*b.y;
    c.y = a.x*b.y+a.y*b.x;
    return c;
}
inline void FFT(vector<Complex> &a, bool inverse) {
    int n = a.size();
    for(int i = 0, j = 0; i < n; i++) {
        if(j > i)
            swap(a[i], a[j]);
        int k = n;
        while(j & (k>>=1)) j &= ~k;
        j |= k;
    }
    double PI = inverse ? -pi : pi;
    for(int step = 2; step <= n; step <<= 1) {
        double alpha = 2*PI/step;
        Complex wn = Complex(cos(alpha), sin(alpha));
        for(int k = 0; k < n; k += step) {
            Complex w(1, 0);
            for(int Ek = k; Ek < k+step/2; Ek++) {
                int Ok = Ek + step/2;
                Complex u = a[Ek];
                Complex t = w*a[Ok];
                a[Ek] = u+t;
                a[Ok] = u-t;
                w = wn*w;
            }

        }
    }
    if(inverse)
        for(int i = 0; i < n; i++)
            a[i].x = a[i].x/n+esp;
}
short xx[500][maxn];

void solve(int len1, int len2, short res[]) {
    int S1 = len1, S2 = len2;
    int S = 2;
    while(S < S1+S2) S <<= 1;
    vector<Complex> sa(S, Complex(0.0, 0.0)), sb(S, Complex(0.0, 0.0));
    for(int i = 0; i < S1; i++)
        sa[i].x = b[0][i] ? 1 : -1;
    for(int i = 0; i < S2; i++)
        sb[i].x = b[1][S2-1-i] ? 1 : -1;
    FFT(sa, false);
    FFT(sb, false);
    for(int i = 0; i < S; i++)
        sa[i] = sa[i] * sb[i];
    FFT(sa, true);
    for(int i = 0; i <= S1-S2; i++) {
        res[i] = round(sa[i+S2-1].x);
        res[i] = (S2+res[i])/2;
        res[i] = S2-res[i];
    }
}
char sa[maxn], sb[maxn];

int main() {

    scanf("%s%s", sa, sb);
    int n = strlen(sa);
    int m = strlen(sb);
    int L = (int)sqrt(1.0*m) + 1;
    int nn = m/L;
    for(int i = 0; i < n; i++)
        b[0][i] = sa[i] - '0';
    for(int i = 0; i < m; i += L) {
        int len = 0;
        for(int j = 0; j < L && i+j < m; j++, len++)
            b[1][j] = sb[i+j] - '0';
        solve(n, len, xx[i/L]);
    }

    int q;
    for(int t = scanf("%d", &q); t <= q; t++) {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        int st = y, ed = y+z-1;
        int ans = 0;
        if(n < 10000) {
            if(y/L == (y+z-1)/L) {
                for(int i = 0; i < z; i++)
                    if(sa[i+x] != sb[i+y])
                        ans++;
            } else {
                int base = x+(st%L != 0 ? L-st%L : 0);
                for(int i = st/L+(st%L != 0); i <= ed/L-((ed+1)%L != 0); i++, base += L) {
                    ans += xx[i][base];
                }
                if(st%L)
                    for(int i = 0; i < L-st%L; i++)
                        if(sa[x+i] != sb[y+i])
                            ans++;
                if((ed+1)%L)
                    for(int i = 0; i < ed%L+1; i++)
                        if(sa[x+z-1-i] != sb[y+z-1-i])
                            ans++;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-14
#define lson   l, m, rt<<1
#define rson   m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pf(x) ((x)*(x))
#define pb push_back
#define pi acos(-1.0)
#define in freopen("solve_in.txt", "r", stdin);
#define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
using namespace std;
typedef long long LL;
typedef map<LL, int> MPS;
typedef pair<int, int> PII;
typedef MPS::iterator IT;
const int maxn = 200000 + 10;

bitset<maxn> b[2];

struct Complex {
    double x, y;
    Complex() {}
    Complex(double x, double y):x(x), y(y) {}
};
inline Complex operator + (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x+b.x;
    c.y = a.y+b.y;
    return c;
}
inline Complex operator - (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x-b.x;
    c.y = a.y-b.y;
    return c;
}
inline Complex operator * (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x*b.x-a.y*b.y;
    c.y = a.x*b.y+a.y*b.x;
    return c;
}
inline void FFT(vector<Complex> &a, bool inverse) {
    int n = a.size();
    for(int i = 0, j = 0; i < n; i++) {
        if(j > i)
            swap(a[i], a[j]);
        int k = n;
        while(j & (k>>=1)) j &= ~k;
        j |= k;
    }
    double PI = inverse ? -pi : pi;
    for(int step = 2; step <= n; step <<= 1) {
        double alpha = 2*PI/step;
        Complex wn = Complex(cos(alpha), sin(alpha));
        for(int k = 0; k < n; k += step) {
            Complex w(1, 0);
            for(int Ek = k; Ek < k+step/2; Ek++) {
                int Ok = Ek + step/2;
                Complex u = a[Ek];
                Complex t = w*a[Ok];
                a[Ek] = u+t;
                a[Ok] = u-t;
                w = wn*w;
            }

        }
    }
    if(inverse)
        for(int i = 0; i < n; i++)
            a[i].x = a[i].x/n+esp;
}
short xx[500][maxn];

void solve(int len1, int len2, short res[]) {
    int S1 = len1, S2 = len2;
    int S = 2;
    while(S < S1+S2) S <<= 1;
    vector<Complex> sa(S, Complex(0.0, 0.0)), sb(S, Complex(0.0, 0.0));
    for(int i = 0; i < S1; i++)
        sa[i].x = b[0][i] ? 1 : -1;
    for(int i = 0; i < S2; i++)
        sb[i].x = b[1][S2-1-i] ? 1 : -1;
    FFT(sa, false);
    FFT(sb, false);
    for(int i = 0; i < S; i++)
        sa[i] = sa[i] * sb[i];
    FFT(sa, true);
    for(int i = 0; i <= S1-S2; i++) {
        res[i] = round(sa[i+S2-1].x);
        res[i] = (S2+res[i])/2;
        res[i] = S2-res[i];
    }
}
char sa[maxn], sb[maxn];

int main() {

    scanf("%s%s", sa, sb);
    int n = strlen(sa);
    int m = strlen(sb);
    int L = (int)sqrt(m) + 1;
    int nn = m/L;
    for(int i = 0; i < n; i++)
        b[0][i] = sa[i] == '1';
    for(int i = 0; i < m; i += L) {
        int len = 0;
        for(int j = 0; j < L && i+j < m; j++, len++)
            b[1][j] = sb[i+j] == '1';
        solve(n, len, xx[i/L]);
    }
    int q;
    for(int t = scanf("%d", &q); t <= q; t++) {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        int st = y, ed = y+z-1;
        int ans = 0;
        if(y/L == (y+z-1)/L) {
            for(int i = 0; i < z; i++)
                if(sa[i+x] != sb[i+y])
                    ans++;
        } else {
            int base = x+(st%L != 0 ? L-st%L : 0);
            for(int i = st/L+(st%L != 0); i <= ed/L-((ed+1)%L != 0); i++, base += L) {
                ans += xx[i][base];
            }
            if(st%L)
                for(int i = 0; i < L-st%L; i++)
                    if(sa[x+i] != sb[y+i])
                        ans++;
            if((ed+1)%L)
                for(int i = 0; i < ed%L+1; i++)
                    if(sa[x+z-1-i] != sb[y+z-1-i])
                        ans++;
        }
        printf("%d\n", ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-14
#define lson   l, m, rt<<1
#define rson   m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pf(x) ((x)*(x))
#define pb push_back
#define pi 3.1415926
#define in freopen("solve_in.txt", "r", stdin);
#define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
using namespace std;
typedef long long LL;
typedef map<LL, int> MPS;
typedef pair<int, int> PII;
typedef MPS::iterator IT;
const int maxn = 200000 + 10;

bitset<maxn> b[2];

struct Complex {
    double x, y;
    Complex() {}
    Complex(double x, double y):x(x), y(y) {}
};
inline Complex operator + (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x+b.x;
    c.y = a.y+b.y;
    return c;
}
inline Complex operator - (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x-b.x;
    c.y = a.y-b.y;
    return c;
}
inline Complex operator * (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x*b.x-a.y*b.y;
    c.y = a.x*b.y+a.y*b.x;
    return c;
}
inline void FFT(vector<Complex> &a, bool inverse, int n) {
//    int n = a.size();
//    bug(n)
    for(int i = 0, j = 0; i < n; i++) {
        if(j > i)
            swap(a[i], a[j]);
        int k = n;
        while(j & (k>>=1)) j &= ~k;
        j |= k;
    }
    double PI = inverse ? -pi : pi;
    for(int step = 2; step <= n; step <<= 1) {
        double alpha = 2*PI/step;
        Complex wn = Complex(cos(alpha), sin(alpha));
        for(int k = 0; k < n; k += step) {
            Complex w(1, 0);
            for(int Ek = k; Ek < k+step/2; Ek++) {
                int Ok = Ek + step/2;
                Complex u = a[Ek];
                Complex t = w*a[Ok];
                a[Ek] = u+t;
                a[Ok] = u-t;
                w = wn*w;
            }

        }
    }
    if(inverse)
        for(int i = 0; i < n; i++)
            a[i].x = a[i].x/n+esp;
}
short xx[500][maxn];

void solve(int len1, int len2, short res[]) {
    int S1 = len1, S2 = len2;
    int S = 2;
    while(S < S1+S2) S <<= 1;
//
    vector<Complex> sa(S, Complex(0.0, 0.0)), sb(S, Complex(0.0, 0.0));
//    for(int i = 0; i < S; i++)
//        ssa[i] = ssb[i] = Complex(0.0, 0.0);
    for(int i = 0; i < S1; i++)
        sa[i].x = b[0][i] ? 1 : -1;
    for(int i = 0; i < S2; i++)
        sb[i].x = b[1][S2-1-i] ? 1 : -1;
    FFT(sa, false, S);
//    bug(1\)
    FFT(sb, false, S);
    for(int i = 0; i < S; i++)
        sa[i] = sa[i] * sb[i];
    FFT(sa, true, S);
    for(int i = 0; i <= S1-S2; i++) {
        res[i] = int(sa[i+S2-1].x+.5);
        res[i] = (S2+res[i])/2;
        res[i] = S2-res[i];
    }
}
char sa[maxn], sb[maxn];
inline int read(){
    char ch;
    static int res;
    while((ch = getchar()) < '0' || ch > '9')
        ;
    res = ch-'0';
    while((ch = getchar()) >= '0' && ch <= '9')
        res = res*10 + ch-'0';
    return res;
}
int main() {
//in
    scanf("%s%s", sa, sb);
    int n = strlen(sa);
    int m = strlen(sb);
    int L = min(n, 4000);
    for(int i = 0; i < m; i++)
        b[0][i] = sb[i] - '0';
    for(int i = 0; i < n; i += L) {
        int len = 0;
        for(int j = 0; j < L && i+j < n; j++, len++)
            b[1][j] = sa[i+j] - '0';
        solve(m, len, xx[i/L]);
//        bug(1)
    }
//    bug(1)
    int q;
    for(int t = scanf("%d", &q); t <= q; t++) {
        int x, y, z;
        x = read(), y = read(), z = read();
        int st = x, ed = x+z-1;
        int ans = 0;
        if(x/L == (x+z-1)/L) {
            for(int i = 0; i < z; i++)
                if(sa[i+x] != sb[i+y])
                    ans++;
        } else {
            int base = y+(st%L != 0 ? L-st%L : 0);
            int tmp = ed/L-((ed+1)%L != 0);
            for(int i = st/L+(st%L != 0); i <= tmp; i++, base += L) {
                ans += xx[i][base];
            }
            if(st%L)
                for(int i = 0; i < L-st%L; i++)
                    if(sa[x+i] != sb[y+i])
                        ans++;
            if((ed+1)%L)
                for(int i = 0; i < ed%L+1; i++)
                    if(sa[x+z-1-i] != sb[y+z-1-i])
                        ans++;
        }
        printf("%d\n", ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-14
#define lson   l, m, rt<<1
#define rson   m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pf(x) ((x)*(x))
#define pb push_back
#define pi acos(-1.0)
#define in freopen("solve_in.txt", "r", stdin);
#define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
using namespace std;
typedef long long LL;
typedef map<LL, int> MPS;
typedef pair<int, int> PII;
typedef MPS::iterator IT;
const int maxn = 200000 + 10;

bitset<maxn> b[2];

struct Complex {
    double x, y;
    Complex() {}
    Complex(double x, double y):x(x), y(y) {}
};
inline Complex operator + (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x+b.x;
    c.y = a.y+b.y;
    return c;
}
inline Complex operator - (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x-b.x;
    c.y = a.y-b.y;
    return c;
}
inline Complex operator * (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x*b.x-a.y*b.y;
    c.y = a.x*b.y+a.y*b.x;
    return c;
}
inline void FFT(vector<Complex> &a, bool inverse) {
    int n = a.size();
    for(int i = 0, j = 0; i < n; i++) {
        if(j > i)
            swap(a[i], a[j]);
        int k = n;
        while(j & (k>>=1)) j &= ~k;
        j |= k;
    }
    double PI = inverse ? -pi : pi;
    for(int step = 2; step <= n; step <<= 1) {
        double alpha = 2*PI/step;
        Complex wn = Complex(cos(alpha), sin(alpha));
        for(int k = 0; k < n; k += step) {
            Complex w(1, 0);
            for(int Ek = k; Ek < k+step/2; Ek++) {
                int Ok = Ek + step/2;
                Complex u = a[Ek];
                Complex t = w*a[Ok];
                a[Ek] = u+t;
                a[Ok] = u-t;
                w = wn*w;
            }

        }
    }
    if(inverse)
        for(int i = 0; i < n; i++)
            a[i].x = a[i].x/n+esp;
}
short xx[500][maxn];

void solve(int len1, int len2, short res[]) {
    int S1 = len1, S2 = len2;
    int S = 2;
    while(S < S1+S2) S <<= 1;
    vector<Complex> sa(S, Complex(0.0, 0.0)), sb(S, Complex(0.0, 0.0));
    for(int i = 0; i < S1; i++)
        sa[i].x = b[0][i] ? 1 : -1;
    for(int i = 0; i < S2; i++)
        sb[i].x = b[1][S2-1-i] ? 1 : -1;
    FFT(sa, false);
    FFT(sb, false);
    for(int i = 0; i < S; i++)
        sa[i] = sa[i] * sb[i];
    FFT(sa, true);
    for(int i = 0; i <= S1-S2; i++) {
        res[i] = round(sa[i+S2-1].x);
        res[i] = (S2+res[i])/2;
        res[i] = S2-res[i];
    }
}
char sa[maxn], sb[maxn];

int main() {

    scanf("%s%s", sa, sb);
    int n = strlen(sa);
    int m = strlen(sb);
    int L = min(m, 3000);
    int nn = m/L;
    for(int i = 0; i < n; i++)
        b[0][i] = sa[i] - '0';
    for(int i = 0; i < m; i += L) {
        int len = 0;
        for(int j = 0; j < L && i+j < m; j++, len++)
            b[1][j] = sb[i+j] - '0';
        solve(n, len, xx[i/L]);
    }

    int q;
    for(int t = scanf("%d", &q); t <= q; t++) {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        int st = y, ed = y+z-1;
        int ans = 0;
        if(y/L == (y+z-1)/L) {
            for(int i = 0; i < z; i++)
                if(sa[i+x] != sb[i+y])
                    ans++;
        } else {
            int base = x+(st%L != 0 ? L-st%L : 0);
            for(int i = st/L+(st%L != 0); i <= ed/L-((ed+1)%L != 0); i++, base += L) {
                ans += xx[i][base];
            }
            if(st%L)
                for(int i = 0; i < L-st%L; i++)
                    if(sa[x+i] != sb[y+i])
                        ans++;
            if((ed+1)%L)
                for(int i = 0; i < ed%L+1; i++)
                    if(sa[x+z-1-i] != sb[y+z-1-i])
                        ans++;
        }
        printf("%d\n", ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-14
#define lson   l, m, rt<<1
#define rson   m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pf(x) ((x)*(x))
#define pb push_back
#define pi acos(-1.0)
#define in freopen("solve_in.txt", "r", stdin);
#define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
using namespace std;
typedef long long LL;
typedef map<LL, int> MPS;
typedef pair<int, int> PII;
typedef MPS::iterator IT;
const int maxn = 200000 + 10;

bitset<maxn> b[2];

struct Complex {
    double x, y;
    Complex() {}
    Complex(double x, double y):x(x), y(y) {}
};
inline Complex operator + (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x+b.x;
    c.y = a.y+b.y;
    return c;
}
inline Complex operator - (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x-b.x;
    c.y = a.y-b.y;
    return c;
}
inline Complex operator * (const Complex &a, const Complex &b) {
    Complex c;
    c.x = a.x*b.x-a.y*b.y;
    c.y = a.x*b.y+a.y*b.x;
    return c;
}
inline void FFT(vector<Complex> &a, bool inverse) {
    int n = a.size();
    for(int i = 0, j = 0; i < n; i++) {
        if(j > i)
            swap(a[i], a[j]);
        int k = n;
        while(j & (k>>=1)) j &= ~k;
        j |= k;
    }
    double PI = inverse ? -pi : pi;
    for(int step = 2; step <= n; step <<= 1) {
        double alpha = 2*PI/step;
        Complex wn = Complex(cos(alpha), sin(alpha));
        for(int k = 0; k < n; k += step) {
            Complex w(1, 0);
            for(int Ek = k; Ek < k+step/2; Ek++) {
                int Ok = Ek + step/2;
                Complex u = a[Ek];
                Complex t = w*a[Ok];
                a[Ek] = u+t;
                a[Ok] = u-t;
                w = wn*w;
            }

        }
    }
    if(inverse)
        for(int i = 0; i < n; i++)
            a[i].x = a[i].x/n+esp;
}
short xx[500][maxn];

void solve(int len1, int len2, short res[]) {
    int S1 = len1, S2 = len2;
    int S = 2;
    while(S < S1+S2) S <<= 1;
    vector<Complex> sa(S, Complex(0.0, 0.0)), sb(S, Complex(0.0, 0.0));
    for(int i = 0; i < S1; i++)
        sa[i].x = b[0][i] ? 1 : -1;
    for(int i = 0; i < S2; i++)
        sb[i].x = b[1][S2-1-i] ? 1 : -1;
    FFT(sa, false);
    FFT(sb, false);
    for(int i = 0; i < S; i++)
        sa[i] = sa[i] * sb[i];
    FFT(sa, true);
    for(int i = 0; i <= S1-S2; i++) {
        res[i] = int(sa[i+S2-1].x+.5);
        res[i] = (S2+res[i])/2;
        res[i] = S2-res[i];
    }
}
char sa[maxn], sb[maxn];
int read(){
    char ch;
    static int res;
    while((ch = getchar()) < '0' || ch > '9')
        ;
    res = ch-'0';
    while((ch = getchar()) >= '0' && ch <= '9')
        res = res*10 + ch-'0';
    return res;
}
int main() {

    scanf("%s%s", sa, sb);
    int n = strlen(sa);
    int m = strlen(sb);
    int L = min(n, 3000);
    for(int i = 0; i < m; i++)
        b[0][i] = sb[i] - '0';
    for(int i = 0; i < n; i += L) {
        int len = 0;
        for(int j = 0; j < L && i+j < n; j++, len++)
            b[1][j] = sa[i+j] - '0';
        solve(m, len, xx[i/L]);
    }

    int q;
    for(int t = scanf("%d", &q); t <= q; t++) {
        int x, y, z;
        x = read(), y = read(), z = read();
        int st = x, ed = x+z-1;
        int ans = 0;
        if(x/L == (x+z-1)/L) {
            for(int i = 0; i < z; i++)
                if(sa[i+x] != sb[i+y])
                    ans++;
        } else {
            int base = y+(st%L != 0 ? L-st%L : 0);
            int tmp = ed/L-((ed+1)%L != 0);
            for(int i = st/L+(st%L != 0); i <= tmp; i++, base += L) {
                ans += xx[i][base];
            }
            if(st%L)
                for(int i = 0; i < L-st%L; i++)
                    if(sa[x+i] != sb[y+i])
                        ans++;
            if((ed+1)%L)
                for(int i = 0; i < ed%L+1; i++)
                    if(sa[x+z-1-i] != sb[y+z-1-i])
                        ans++;
        }
        printf("%d\n", ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-14
#define lson   l, m, rt<<1
#define rson   m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pf(x) ((x)*(x))
#define pb push_back
#define pi acos(-1.0)
#define in freopen("solve_in.txt", "r", stdin);
#define bug(x) printf("Line : %u >>>>>>\n", (x));
#define TL cerr << "Time elapsed: " << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms" << endl;
#define inf 0x0f0f0f0f
using namespace std;
typedef long long LL;
typedef map<LL, int> MPS;
typedef pair<int, int> PII;
typedef MPS::iterator IT;
const int maxn = 200000 + 10;
int bi[1<<16];
unsigned a[32][maxn/32 + 10], b[32][maxn/32 + 10];
char sa[maxn], sb[maxn];
//int getBit(unsigned x) {
//    return bi[x>>16] + bi[x&((1<<16)-1)];
//}
static __inline int getBit(unsigned n)
{

    int ret;
#ifdef __GNUC__
    __asm__("popcnt %0, %1" : "=r"(ret) : "r"(n));
#else
    __asm { clz ret, n; }
#endif
//bug(1)
    return ret;
}
int getAns(int p, int q, int len) {
    int x = p>>5, y = q>>5;
    int u = p&31, v = q&31;
    int ans = 0, i =0;

    while(i+32 <= len) {
        ans += getBit(a[u][x]^b[v][y]);
        x++, y++;
        i+=32;
    }
    len-=i;
    return ans += getBit((a[u][x]^b[v][y])&((1<<len)-1));

}
int main() {
//    in
    for(int i = 1; i < (1<<16); i++)
        bi[i] = bi[i>>1] + (i&1);
//    cout << bi[31] << endl;
    scanf("%s%s", sa, sb);
    int n = strlen(sa);
    int m = strlen(sb);
    for(int i = 0; i < 32; i++) {
        for(int j = 0; j+i < n; j++)
            if(sa[i+j] == '1')
            a[i][j>>5] |= (1LL<<(j&31));
    }
    for(int i = 0; i < 32; i++) {
        for(int j = 0; j+i < m; j++)
            if(sb[i+j] == '1')
            b[i][j>>5] |= (1LL<<(j&31));
    }
    int qq, p, q, len;
    scanf("%d", &qq);
    while(qq--) {
        scanf("%d%d%d", &p, &q, &len);
        printf("%d\n", getAns(p, q, len));
    }
    TL;
    return 0;
}