#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

const int N=1<<18;
const int M=2000;
const double PI=acos(-1.0);

struct Complex {
	double x,y;
	Complex(double xx=0,double yy=0):x(xx),y(yy) {}
	friend Complex operator + (const Complex &a,const Complex &b) {
		return Complex(a.x+b.x,a.y+b.y);
	}
	friend Complex operator - (const Complex &a,const Complex &b) {
		return Complex(a.x-b.x,a.y-b.y);
	}
	friend Complex operator * (const Complex &a,const Complex &b) {
		return Complex(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x);
	}
};

char s1[N],s2[N];
int ls1,ls2;
int res[101][N];
Complex a[N],b[N];
bool flag=false;

void FFT(Complex a[],int n,int oper) {
	if (flag) printf("%d\n",n);
	for (int i=1,j=0;i<n;i++) {
		for (int s=n;j^=s>>=1,~j&s;);
		if (i<j) swap(a[i],a[j]);
	}
	if (flag) printf("aaa\n");
	for (int m=1;m<n;m<<=1) {
		if (flag) printf("--%d\n",m);
		if (flag&&m>256) return;
		double p=PI/m*oper;
		Complex w=Complex(cos(p),sin(p));
		int tmp=0;
		if (!flag)
		for (int i=0;i<n;i+=m<<1) {
			Complex unit=1;
			for (int j=0;j<m;j++) {
				Complex &x=a[i+j+m],&y=a[i+j],t=unit*x;
				x=y-t;
				y=y+t;
				unit=unit*w;
				tmp++;
			}
		}
		if (flag) printf("ccc %d\n",tmp);
	}
	if (flag) printf("aaa\n");
	if (oper==-1)
		for (int i=0;i<n;i++) a[i].x/=n;
	if (flag) printf("aaa\n");
}

void init() {
	for (int i=0;i<ls2;i++)
		if (s2[i]=='1') b[ls2-i-1]=1;
		else if (s2[i]=='0') b[ls2-i-1]=-1;
	FFT(b,N,1);
	for (int i=0;i<ls1;i+=M) {
		if (ls1>100) {
			printf("%d\n",i);
			if (i/M>37) return;
		}
		for (int j=0;j<M;j++)
			if (s2[i+j]=='1') a[j]=1;
			else if (s2[i+j]=='0') a[j]=-1;
		FFT(a,N,1);
		for (int j=0;j<N;j++) a[j]=a[j]*b[j];
		if (i/M==37) flag=true;
		FFT(a,N,-1);
		if (flag) printf("bbb %d\n",i);
		int *aa=res[i/M];
		for (int j=0;j<N;j++) aa[j]=a[j].x+0.5;
	}
}
int solve(int p1,int p2,int len) {
	int ans=0,i;
	for (i=0;i<len&&(p1+i)%M!=0;i++)
		if (s1[p1+i]!=s2[p2+i]) ans++;
	for (;i+M<len;i+=M)
		ans+=(M-res[(p1+i)/M][ls2-p2-i+1])/2;
	for (;i<len;i++)
		if (s1[p1+i]!=s2[p2+i]) ans++;
	return ans;
}
int main() {
	int q,p1,p2,len;
	scanf("%s%s",s1,s2);
	ls1=strlen(s1);
	ls2=strlen(s2);
	if (ls1>100)
		printf("%d %d\n",ls1,ls2);
	init();
	//if (ls1>100)
		//printf("aaa\n");
	scanf("%d",&q);
	while (q--) {
		scanf("%d%d%d",&p1,&p2,&len);
		if (ls1<100)
			printf("%d\n",solve(p1,p2,len));
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <complex>
#include <algorithm>

using namespace std;

const int N=1<<18;
const int M=1000;
const double PI=acos(-1.0);

char s1[N],s2[N];
int ls1,ls2;
int res[201][N];
complex<double> a[N],b[N];

void FFT(complex<double> a[],int n,int oper) {
	for (int i=1,j=0;i<n;i++) {
		for (int s=n;j^=s>>=1,~j&s;);
		if (i<j) swap(a[i],a[j]);
	}
	for (int m=1;m<n;m<<=1) {
		int m2=m<<1;
		double p=PI/m*oper;
		complex<double> w=complex<double>(cos(p),sin(p));
		for (int i=0;i<n;i+=m2) {
			complex<double> unit=1;
			for (int j=0;j<m;j++) {
				complex<double> &x=a[i+j+m],&y=a[i+j];
				complex<double> t=unit*x;
				x=y-t;
				y=y+t;
				unit*=w;
			}
		}
	}
	if (oper==-1)
		for (int i=0;i<n;i++) a[i]/=n;
}

void init() {
	for (int i=0;i<ls2;i++)
		if (s2[i]=='1') b[ls2-i-1]=1;
		else if (s2[i]=='0') b[ls2-i-1]=-1;
	FFT(b,N,1);
	for (int i=0;i<ls1;i+=M) {
		for (int j=0;j<M;j++)
			if (s2[i+j]=='1') a[j]=1;
			else if (s2[i+j]=='0') a[j]=-1;
		FFT(a,N,1);
		for (int j=0;j<N;j++) a[j]*=b[j];
		FFT(a,N,-1);
		int *aa=res[i/M];
		for (int j=0;j<N;j++) aa[j]=a[j].real()+0.5;
	}
}
int solve(int p1,int p2,int len) {
	int ans=0,i;
	for (i=0;i<len&&(p1+i)%M!=0;i++)
		if (s1[p1+i]!=s2[p2+i]) ans++;
	for (;i+M<len;i+=M)
		ans+=(M-res[(p1+i)/M][ls2-p2-i+1])/2;
	for (;i<len;i++)
		if (s1[p1+i]!=s2[p2+i]) ans++;
	return ans;
}
int main() {
	printf("%d\n",N);
	int q,p1,p2,len;
	scanf("%s%s",s1,s2);
	ls1=strlen(s1);
	ls2=strlen(s2);
	init();
	scanf("%d",&q);
	while (q--) {
		scanf("%d%d%d",&p1,&p2,&len);
		printf("%d\n",solve(p1,p2,len));
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

const int N=1<<18;
const int M=2000;
const double PI=acos(-1.0);

struct Complex {
	double x,y;
	Complex(double xx=0,double yy=0):x(xx),y(yy) {}
	friend Complex operator + (const Complex &a,const Complex &b) {
		return Complex(a.x+b.x,a.y+b.y);
	}
	friend Complex operator - (const Complex &a,const Complex &b) {
		return Complex(a.x-b.x,a.y-b.y);
	}
	friend Complex operator * (const Complex &a,const Complex &b) {
		return Complex(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x);
	}
};

char s1[N],s2[N];
int ls1,ls2;
int res[101][N];
Complex a[N],b[N];

void FFT(Complex a[],int n,int oper) {
	for (int i=1,j=0;i<n;i++) {
		for (int s=n;j^=s>>=1,~j&s;);
		if (i<j) swap(a[i],a[j]);
	}
	for (int m=1;m<n;m<<=1) {
		int m2=m<<1;
		double p=PI/m*oper;
		Complex w=Complex(cos(p),sin(p));
		for (int i=0;i<n;i+=m2) {
			Complex unit=1;
			for (int j=0;j<m;j++) {
				Complex &x=a[i+j+m],&y=a[i+j];
				Complex t=unit*x;
				x=y-t;
				y=y+t;
				unit=unit*w;
			}
		}
	}
	if (oper==-1)
		for (int i=0;i<n;i++) a[i].x/=n;
}

void init() {
	for (int i=0;i<ls2;i++)
		if (s2[i]=='1') b[ls2-i-1]=1;
		else if (s2[i]=='0') b[ls2-i-1]=-1;
	FFT(b,N,1);
	for (int i=0;i<ls1;i+=M) {
		//if (ls1>100) {
			//printf("%d\n",i);
			//if (i/M>20) return;
		//}
		for (int j=0;j<M;j++)
			if (s2[i+j]=='1') a[j]=1;
			else if (s2[i+j]=='0') a[j]=-1;
		FFT(a,N,1);
		for (int j=0;j<N;j++) a[j]=a[j]*b[j];
		FFT(a,N,-1);
		int *aa=res[i/M];
		for (int j=0;j<N;j++) aa[j]=a[j].x+0.5;
	}
}
int solve(int p1,int p2,int len) {
	int ans=0,i;
	for (i=0;i<len&&(p1+i)%M!=0;i++)
		if (s1[p1+i]!=s2[p2+i]) ans++;
	for (;i+M<len;i+=M)
		ans+=(M-res[(p1+i)/M][ls2-p2-i+1])/2;
	for (;i<len;i++)
		if (s1[p1+i]!=s2[p2+i]) ans++;
	return ans;
}
int main() {
	int q,p1,p2,len;
	scanf("%s%s",s1,s2);
	ls1=strlen(s1);
	ls2=strlen(s2);
	//if (ls1>100)
		//printf("%d %d\n",ls1,ls2);
	init();
	//if (ls1>100)
		//printf("aaa\n");
	scanf("%d",&q);
	while (q--) {
		scanf("%d%d%d",&p1,&p2,&len);
		if (ls1<100)
			printf("%d\n",solve(p1,p2,len));
	}
	return 0;
}


#pragma comment(linker, "/STACK:100000000")
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <complex>
#include <string>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef complex < double > cd;

const bool db = false;

#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sd second
#define fs first

#define inf 1000000007
#define nmax 300010
#define mmax 100010
#define eps 1e-9

unsigned a[32][nmax], b[32][nmax];
char aa[nmax], bb[nmax];
int n, m, h[1 << 16];
int l, r, q, len;

inline int H(const unsigned & x) {
	return h[x >> 16] + h[x & ((1 << 16) - 1)];
}

int main() {
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	//freopen("a.in", "r", stdin); freopen("a.out", "w", stdout);
	gets(aa); gets(bb);
	n = strlen(aa); m = strlen(bb);
	for(int i = 0; i < 32; ++i)
		for(int j = 0; i + j < n; ++j)
			if(aa[i + j] == '1')
				a[i][j >> 5] |= (1U << (j & 31));
	for(int i = 0; i < 32; ++i)
		for(int j = 0; i + j < m; ++j)
			if(bb[i + j] == '1')
				b[i][j >> 5] |= (1U << (j & 31));
	for(int i = 1; i < 1 << 16; ++i)
		h[i] = h[i >> 1] + (i & 1);
	scanf("%d", &q);
	while(q --> 0) {
		scanf("%d%d%d", &l, &r, &len);
		int ld = l & 31, rd = r & 31, ans = 0;
		l >>= 5; r >>= 5;
		while(len >= 32) {
			ans += H(a[ld][l++] ^ b[rd][r++]);
			len -= 32;
		}
		//cout << ld << " " << a[ld][l] << " " << rd << " " << b[rd][r] << " " << len << endl;
		ans += H((a[ld][l] ^ b[rd][r]) & ((1U << len) - 1));
		printf("%d\n", ans);
	}
	cin.get(); cin.get();
	return 0;
}


#pragma comment(linker, "/STACK:100000000")
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <complex>
#include <string>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef complex < double > cd;

const bool db = false;

#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sd second
#define fs first

#define inf 1000000007
#define nmax 210010
#define mmax 100010
#define eps 1e-9

unsigned a[32][nmax / 32], b[32][nmax / 32];
char aa[nmax], bb[nmax];
int n, m, h[1 << 16];
int l, r, q, len;

inline int H(const unsigned & x) {
	return h[x >> 16] + h[x & ((1 << 16) - 1)];
}

int main() {
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	//freopen("a.in", "r", stdin); freopen("a.out", "w", stdout);
	gets(aa); gets(bb);
	n = strlen(aa); m = strlen(bb);
	for(int i = 0; i < 32; ++i)
		for(int j = 0; i + j < n; ++j)
			if(aa[i + j] == '1')
				a[i][j >> 5] |= (1U << (j & 31));
	for(int i = 0; i < 32; ++i)
		for(int j = 0; i + j < m; ++j)
			if(bb[i + j] == '1')
				b[i][j >> 5] |= (1U << (j & 31));
	for(int i = 1; i < 1 << 16; ++i)
		h[i] = h[i >> 1] + (i & 1);
	scanf("%d", &q);
	while(q --> 0) {
		scanf("%d%d%d", &l, &r, &len);
		int ans = 0;
		unsigned * lb = a[l & 31], * rb = b[r & 31];
		lb += l >> 5; rb += r >> 5;
		while(len >= 32) {
			ans += H(*lb++ ^ *rb++);
			len -= 32;
		}
		//cout << ld << " " << a[ld][l] << " " << rd << " " << b[rd][r] << " " << len << endl;
		ans += H((*lb ^ *rb) & ((1U << len) - 1));
		printf("%d\n", ans);
	}
	cin.get(); cin.get();
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define if if (
#define then )
#define do )
#define for for (
#define while while (
#define begin {
#define end }

#define MAXN 200005

#define u32 unsigned int

char ch;
inline void read(int &x)
begin
	x=0;ch=getchar();
	while ch<=32 do ch=getchar();
	while ch>32 do begin
		x=x*10+ch-48;ch=getchar();
	end;
end;

int cnt_table[1<<16];

inline void pre()
begin
	int i;
	for i=1;i<(1<<16);i++ do begin
		cnt_table[i]=cnt_table[i>>1]+(i&1);
	end;
end;

char a[MAXN],b[MAXN];
int n,m,q;

inline void main1()
begin
	read(q);
	while q-- do begin
		int p1,p2,len;
		read(p1);read(p2);read(len);
		int ans=0;
		char *A=a+p1,*B=b+p2;
		while len-- do begin
			ans+=(*A++)^(*B++);
		end;
		printf("%d\n",ans);
	end;
end;

u32 aa[32][MAXN/32+3],bb[32][MAXN/32+3];

inline void build(char *a,u32 *A,int n)
begin
	int i;
	for i=0;i<n;i++ do begin
		A[i>>5]|=a[i]<<(i&31);
	end;
end;

inline void init()
begin
	int i;
	for i=0;i<32;i++ do begin
		build(a+i,aa[i],n-i);
	end;
	for i=0;i<32;i++ do begin
		build(b+i,bb[i],m-i);
	end;
end;

inline int getcnt(u32 x)
begin
	return cnt_table[x>>16]+cnt_table[x&65535];
end;

inline int calc(u32 *A,u32 *B,int len)
begin
	int ret=0;
	int l=len>>5;
	while l-- do begin
		ret+=getcnt((*A++)^(*B++));
	end;
	return ret+getcnt(((1u<<(len&31))-1u)&(*A^*B));
end;

int main()
begin
	scanf("%s%s",a,b);
	n=strlen(a);m=strlen(b);
	int i;
	for i=0;i<n;i++ do a[i]-=48;
	for i=0;i<m;i++ do b[i]-=48;
	pre();
	if n<=35 || m<=35 then begin
		main1();
		return 0;
	end;
	init();
	read(q);
	while q-- do begin
		int p1,p2,len;
		read(p1);read(p2);read(len);
		u32 *A,*B;
		A=aa[p1&31]+(p1>>5);
		B=bb[p2&31]+(p2>>5);
		printf("%d\n",calc(A,B,len));
	end;
end


#include <iostream>
#include <string>

using namespace std;

const int MAXN = 200 * 1000 + 5, K = 32;
unsigned int pc[1 << (K / 2)], a[K][(MAXN + K - 1) / K], b[K][(MAXN + K - 1) / K];
string sa, sb;

int popcount(unsigned int x) {
    return pc[x >> (K / 2)] + pc[x & ((1u << (K / 2)) - 1)];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    for(int i = 0; i < (1 << (K / 2)); i++)
        pc[i] = __builtin_popcount(i);
    cin >> sa >> sb;
    int n = sa.length(), m = sb.length();
    for(int i = 0; i < K; i++)
        for(int j = i; j < n; j++)
            if(sa[j] == '1')
                a[i][(j - i) / K] |= (1u << ((j - i) % K));
    for(int i = 0; i < K; i++)
        for(int j = i; j < m; j++)
            if(sb[j] == '1')
                b[i][(j - i) / K] |= (1u << ((j - i) % K));
    int q;
    cin >> q;
    for(int i = 0; i < q; i++) {
        int p0, p1, len;
        cin >> p0 >> p1 >> len;
        int r0 = p0 % K, r1 = p1 % K, l0 = p0 / K, l1 = p1 / K,
            d = len / K, ans = 0;
        for(int i = 0; i < d; i++)
            ans += popcount(a[r0][l0++] ^ b[r1][l1++]);
        ans += popcount((a[r0][l0] ^ b[r1][l1]) & ((1u << (len % K)) - 1));
        cout << ans << '\n';
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 10000;
const int BIT = 32;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
vector <unsigned int> A[BIT], B[BIT];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int force(int l1, int r1, int l2, int r2)
{
	if (l1>r1 || l2>r2) return 0;
	int res = 0;
	int index1 = (l1-(l1%BIT))/BIT;
	int index2 = (l2-(l2%BIT))/BIT;
	int x1 = l1%BIT;
	int x2 = l2%BIT;
	for ( ; l1+BIT<=r1; l1 += BIT, l2+=BIT){
		res += __builtin_popcount(A[x1][index1]^B[x2][index2]);
		index1++; index2++;
	}
	unsigned int q = BIT-r1+l1-1;
	res += __builtin_popcount((A[x1][index1]>>q)^(B[x2][index2]>>q));
	return res;
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int x = 0; x<BIT; x++){
		for (int i = x; i<lena; i+=BIT){
			unsigned int tmp = 0;
			for (int k = i; k<i+BIT && k<lena; k++){
				tmp |= (unsigned int)(a[k]-'0')<<(i+BIT-1-k);
			}
			A[x].push_back(tmp);
		}
	}
	for (int x = 0; x<BIT; x++){
		for (int i = x; i<lenb; i+=BIT){
			unsigned int tmp = 0;
			for (int k = i; k<i+BIT && k<lenb; k++){
				tmp |= (unsigned int)(b[k]-'0')<<(i+BIT-1-k);
			}
			B[x].push_back(tmp);
		}
	}
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK)	work(i-BLOCK+1, i);
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		int t1 = ((p1-1)/BLOCK+1)*BLOCK;
		int l = t1-p1;
		if (t1<=e1){
			ans += force(p1,p1+l-1,p2,p2+l-1);
			p1 += l; p2 += l;
		}
		else {
			ans += force(p1,e1,p2,e2);
			p1 = e1+1; p2 = e2+1;
		}
		int t2 = (e1+1)/BLOCK*BLOCK-1;
		l = e1-t2;
		if (t2>=p1){
			ans += force(t2+1,t2+l,e2-l+1,e2);
			e1 -= l; e2 -= l;
		}
		else{
			ans += force(p1,e1,p2,e2);
			e1 = p1-1; e2 = p2-1;
		}
		/*
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		*/
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 3000;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK){
		work(i-BLOCK+1, i);
	}
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		//cout<<"left : "<<endl;
		//cout<<p1<<" "<<p2<<" "<<ans<<endl;
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		//cout<<"right : "<<endl;
		//cout<<e1<<" "<<e2<<" "<<ans<<endl;
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
				cout<<k<<"-"<<p2+(k-index)*BLOCK<<"-"<<cnt[k][p2+(k-index)*BLOCK]<<endl;
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 8000;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK){
		work(i-BLOCK+1, i);
	}
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		//cout<<"left : "<<endl;
		//cout<<p1<<" "<<p2<<" "<<ans<<endl;
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		//cout<<"right : "<<endl;
		//cout<<e1<<" "<<e2<<" "<<ans<<endl;
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
				cout<<k<<"-"<<p2+(k-index)*BLOCK<<"-"<<cnt[k][p2+(k-index)*BLOCK]<<endl;
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 6000;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK)	work(i-BLOCK+1, i);
	assert(1+1!=2);
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 5000;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK){
		work(i-BLOCK+1, i);
		assert(i<100000);
	}
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		//cout<<"left : "<<endl;
		//cout<<p1<<" "<<p2<<" "<<ans<<endl;
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		//cout<<"right : "<<endl;
		//cout<<e1<<" "<<e2<<" "<<ans<<endl;
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
				cout<<k<<"-"<<p2+(k-index)*BLOCK<<"-"<<cnt[k][p2+(k-index)*BLOCK]<<endl;
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 10000;
const int BIT = 64;
typedef unsigned long long bitType;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
vector <bitType> A[BIT], B[BIT];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int force(int l1, int r1, int l2, int r2)
{
	if (l1>r1 || l2>r2) return 0;
	int res = 0;
	int index1 = (l1-(l1%BIT))/BIT;
	int index2 = (l2-(l2%BIT))/BIT;
	int x1 = l1%BIT;
	int x2 = l2%BIT;
	for ( ; l1+BIT<=r1; l1 += BIT, l2+=BIT){
		res += __builtin_popcountll(A[x1][index1]^B[x2][index2]);
		index1++; index2++;
	}
	bitType q = BIT-r1+l1-1;
	res += __builtin_popcountll((A[x1][index1]>>q)^(B[x2][index2]>>q));
	return res;
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int x = 0; x<BIT; x++){
		for (int i = x; i<lena; i+=BIT){
			bitType tmp = 0;
			for (int k = i; k<i+BIT && k<lena; k++){
				tmp |= (bitType)(a[k]-'0')<<(i+BIT-1-k);
			}
			A[x].push_back(tmp);
		}
	}
	for (int x = 0; x<BIT; x++){
		for (int i = x; i<lenb; i+=BIT){
			bitType tmp = 0;
			for (int k = i; k<i+BIT && k<lenb; k++){
				tmp |= (bitType)(b[k]-'0')<<(i+BIT-1-k);
			}
			B[x].push_back(tmp);
		}
	}
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK)	work(i-BLOCK+1, i);
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		int t1 = ((p1-1)/BLOCK+1)*BLOCK;
		int l = t1-p1;
		if (t1<=e1){
			ans += force(p1,p1+l-1,p2,p2+l-1);
			p1 += l; p2 += l;
		}
		else {
			ans += force(p1,e1,p2,e2);
			p1 = e1+1; p2 = e2+1;
		}
		int t2 = (e1+1)/BLOCK*BLOCK-1;
		l = e1-t2;
		if (t2>=p1){
			ans += force(t2+1,t2+l,e2-l+1,e2);
			e1 -= l; e2 -= l;
		}
		else{
			ans += force(p1,e1,p2,e2);
			e1 = p1-1; e2 = p2-1;
		}
		/*
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		*/
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 1100;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK){
		assert(i<10000);
		work(i-BLOCK+1, i);
	}
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		//cout<<"left : "<<endl;
		//cout<<p1<<" "<<p2<<" "<<ans<<endl;
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		//cout<<"right : "<<endl;
		//cout<<e1<<" "<<e2<<" "<<ans<<endl;
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
				cout<<k<<"-"<<p2+(k-index)*BLOCK<<"-"<<cnt[k][p2+(k-index)*BLOCK]<<endl;
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 1000000;
const int BIT = 64;
typedef unsigned long long bitType;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
vector <bitType> A[BIT], B[BIT];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int force(int l1, int r1, int l2, int r2)
{
	if (l1>r1 || l2>r2) return 0;
	int res = 0;
	int index1 = (l1-(l1%BIT))/BIT;
	int index2 = (l2-(l2%BIT))/BIT;
	int x1 = l1%BIT;
	int x2 = l2%BIT;
	for ( ; l1+BIT<=r1; l1 += BIT, l2+=BIT){
		res += __builtin_popcountll(A[x1][index1]^B[x2][index2]);
		index1++; index2++;
	}
	bitType q = BIT-r1+l1-1;
	res += __builtin_popcountll((A[x1][index1]>>q)^(B[x2][index2]>>q));
	return res;
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int x = 0; x<BIT; x++){
		for (int i = x; i<lena; i+=BIT){
			bitType tmp = 0;
			for (int k = i; k<i+BIT && k<lena; k++){
				tmp |= (bitType)(a[k]-'0')<<(i+BIT-1-k);
			}
			A[x].push_back(tmp);
		}
	}
	for (int x = 0; x<BIT; x++){
		for (int i = x; i<lenb; i+=BIT){
			bitType tmp = 0;
			for (int k = i; k<i+BIT && k<lenb; k++){
				tmp |= (bitType)(b[k]-'0')<<(i+BIT-1-k);
			}
			B[x].push_back(tmp);
		}
	}
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	//for (int i = BLOCK-1; i<lena; i+=BLOCK)	work(i-BLOCK+1, i);
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		int t1 = ((p1-1)/BLOCK+1)*BLOCK;
		int l = t1-p1;
		if (t1<=e1){
			ans += force(p1,p1+l-1,p2,p2+l-1);
			p1 += l; p2 += l;
		}
		else {
			ans += force(p1,e1,p2,e2);
			p1 = e1+1; p2 = e2+1;
		}
		int t2 = (e1+1)/BLOCK*BLOCK-1;
		l = e1-t2;
		if (t2>=p1){
			ans += force(t2+1,t2+l,e2-l+1,e2);
			e1 -= l; e2 -= l;
		}
		else{
			ans += force(p1,e1,p2,e2);
			e1 = p1-1; e2 = p2-1;
		}
		/*
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		*/
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 8000;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK)	work(i-BLOCK+1, i);
	assert(1+1!=2);
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 1100;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK){
		assert(i<100000);
		work(i-BLOCK+1, i);
	}
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		//cout<<"left : "<<endl;
		//cout<<p1<<" "<<p2<<" "<<ans<<endl;
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		//cout<<"right : "<<endl;
		//cout<<e1<<" "<<e2<<" "<<ans<<endl;
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
				cout<<k<<"-"<<p2+(k-index)*BLOCK<<"-"<<cnt[k][p2+(k-index)*BLOCK]<<endl;
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 1100;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

void work(int l, int r)
{
	vector <double> X, Y, Z;
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	int flag = 0;
	if (lenb<200){
		flag = 1;
	}
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK){
		assert(i<10000);
		work(i-BLOCK+1, i);
	}
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		//cout<<"left : "<<endl;
		//cout<<p1<<" "<<p2<<" "<<ans<<endl;
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		//cout<<"right : "<<endl;
		//cout<<e1<<" "<<e2<<" "<<ans<<endl;
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
				cout<<k<<"-"<<p2+(k-index)*BLOCK<<"-"<<cnt[k][p2+(k-index)*BLOCK]<<endl;
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 6500;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK){
		work(i-BLOCK+1, i);
	}
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		//cout<<"left : "<<endl;
		//cout<<p1<<" "<<p2<<" "<<ans<<endl;
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		//cout<<"right : "<<endl;
		//cout<<e1<<" "<<e2<<" "<<ans<<endl;
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
				cout<<k<<"-"<<p2+(k-index)*BLOCK<<"-"<<cnt[k][p2+(k-index)*BLOCK]<<endl;
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 10000;
const int BIT = 64;
typedef unsigned long long bitType;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
    	CD omegak = exp(CD(0,0));
    	CD omega = exp(CD(0, alpha));
        for(int k = 0; k < step; k++) {
	     	if (k!=0) omegak *= omega;
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
vector <bitType> A[BIT], B[BIT];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int force(int l1, int r1, int l2, int r2)
{
	if (l1>r1 || l2>r2) return 0;
	int res = 0;
	int index1 = (l1-(l1%BIT))/BIT;
	int index2 = (l2-(l2%BIT))/BIT;
	int x1 = l1%BIT;
	int x2 = l2%BIT;
	for ( ; l1+BIT<=r1; l1 += BIT, l2+=BIT){
		res += __builtin_popcountll(A[x1][index1]^B[x2][index2]);
		index1++; index2++;
	}
	bitType q = BIT-r1+l1-1;
	res += __builtin_popcountll((A[x1][index1]>>q)^(B[x2][index2]>>q));
	return res;
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int x = 0; x<BIT; x++){
		for (int i = x; i<lena; i+=BIT){
			bitType tmp = 0;
			for (int k = i; k<i+BIT && k<lena; k++){
				tmp |= (bitType)(a[k]-'0')<<(i+BIT-1-k);
			}
			A[x].push_back(tmp);
		}
	}
	for (int x = 0; x<BIT; x++){
		for (int i = x; i<lenb; i+=BIT){
			bitType tmp = 0;
			for (int k = i; k<i+BIT && k<lenb; k++){
				tmp |= (bitType)(b[k]-'0')<<(i+BIT-1-k);
			}
			B[x].push_back(tmp);
		}
	}
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK)	work(i-BLOCK+1, i);
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		int t1 = ((p1-1)/BLOCK+1)*BLOCK;
		int l = t1-p1;
		if (t1<=e1){
			ans += force(p1,p1+l-1,p2,p2+l-1);
			p1 += l; p2 += l;
		}
		else {
			ans += force(p1,e1,p2,e2);
			p1 = e1+1; p2 = e2+1;
		}
		int t2 = (e1+1)/BLOCK*BLOCK-1;
		l = e1-t2;
		if (t2>=p1){
			ans += force(t2+1,t2+l,e2-l+1,e2);
			e1 -= l; e2 -= l;
		}
		else{
			ans += force(p1,e1,p2,e2);
			e1 = p1-1; e2 = p2-1;
		}
		/*
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		*/
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 6000;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK){
		work(i-BLOCK+1, i);
	}
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		//cout<<"left : "<<endl;
		//cout<<p1<<" "<<p2<<" "<<ans<<endl;
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		//cout<<"right : "<<endl;
		//cout<<e1<<" "<<e2<<" "<<ans<<endl;
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
				//cout<<k<<"-"<<p2+(k-index)*BLOCK<<"-"<<cnt[k][p2+(k-index)*BLOCK]<<endl;
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 8000;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK)	work(i-BLOCK+1, i);
	if (q>1000) assert(1+1!=2);
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 1100;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

void work(int l, int r)
{
	vector <double> X, Y, Z;
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
		//if (index<7) cout<<index<<" "<<lenb-(i+1)<<" "<<cnt[index][lenb-(i+1)]<<endl;
	}
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	int flag = 0;
	if (lenb<200){
		flag = 1;
	}
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK){
		work(i-BLOCK+1, i);
	}
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		//cout<<"left : "<<endl;
		//cout<<p1<<" "<<p2<<" "<<ans<<endl;
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		//cout<<"right : "<<endl;
		//cout<<e1<<" "<<e2<<" "<<ans<<endl;
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
				cout<<k<<"-"<<p2+(k-index)*BLOCK<<"-"<<cnt[k][p2+(k-index)*BLOCK]<<endl;
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 7000;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK){
		work(i-BLOCK+1, i);
	}
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		//cout<<"left : "<<endl;
		//cout<<p1<<" "<<p2<<" "<<ans<<endl;
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		//cout<<"right : "<<endl;
		//cout<<e1<<" "<<e2<<" "<<ans<<endl;
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
				cout<<k<<"-"<<p2+(k-index)*BLOCK<<"-"<<cnt[k][p2+(k-index)*BLOCK]<<endl;
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 7000;
const int BIT = 32;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
vector <unsigned int> A[BIT], B[BIT];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int force(int l1, int r1, int l2, int r2)
{
	if (l1>r1 || l2>r2) return 0;
	int res = 0;
	int index1 = (l1-(l1%BIT))/BIT;
	int index2 = (l2-(l2%BIT))/BIT;
	int x1 = l1%BIT;
	int x2 = l2%BIT;
	for ( ; l1+BIT<=r1; l1 += BIT, l2+=BIT){
		res += __builtin_popcount(A[x1][index1]^B[x2][index2]);
		index1++; index2++;
	}
	unsigned int q = BIT-r1+l1-1;
	res += __builtin_popcount((A[x1][index1]>>q)^(B[x2][index2]>>q));
	return res;
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int x = 0; x<BIT; x++){
		for (int i = x; i<lena; i+=BIT){
			unsigned int tmp = 0;
			for (int k = i; k<i+BIT && k<lena; k++){
				tmp |= (unsigned int)(a[k]-'0')<<(i+BIT-1-k);
			}
			A[x].push_back(tmp);
		}
	}
	for (int x = 0; x<BIT; x++){
		for (int i = x; i<lenb; i+=BIT){
			unsigned int tmp = 0;
			for (int k = i; k<i+BIT && k<lenb; k++){
				tmp |= (unsigned int)(b[k]-'0')<<(i+BIT-1-k);
			}
			B[x].push_back(tmp);
		}
	}
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK)	work(i-BLOCK+1, i);
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		int t1 = ((p1-1)/BLOCK+1)*BLOCK;
		int l = t1-p1;
		if (t1<=e1){
			ans += force(p1,p1+l-1,p2,p2+l-1);
			p1 += l; p2 += l;
		}
		else {
			ans += force(p1,e1,p2,e2);
			p1 = e1+1; p2 = e2+1;
		}
		int t2 = (e1+1)/BLOCK*BLOCK-1;
		l = e1-t2;
		if (t2>=p1){
			ans += force(t2+1,t2+l,e2-l+1,e2);
			e1 -= l; e2 -= l;
		}
		else{
			ans += force(p1,e1,p2,e2);
			e1 = p1-1; e2 = p2-1;
		}
		/*
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		*/
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 2000;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK){
		work(i-BLOCK+1, i);
	}
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		//cout<<"left : "<<endl;
		//cout<<p1<<" "<<p2<<" "<<ans<<endl;
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		//cout<<"right : "<<endl;
		//cout<<e1<<" "<<e2<<" "<<ans<<endl;
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
				//cout<<k<<"-"<<p2+(k-index)*BLOCK<<"-"<<cnt[k][p2+(k-index)*BLOCK]<<endl;
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 6000;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK)	work(i-BLOCK+1, i);
	if (q>1000) assert(1+1!=2);
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 6000;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK){
		work(i-BLOCK+1, i);
	}
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		//cout<<"left : "<<endl;
		//cout<<p1<<" "<<p2<<" "<<ans<<endl;
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		//cout<<"right : "<<endl;
		//cout<<e1<<" "<<e2<<" "<<ans<<endl;
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
				cout<<k<<"-"<<p2+(k-index)*BLOCK<<"-"<<cnt[k][p2+(k-index)*BLOCK]<<endl;
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 10000;
const int BIT = 32;
typedef unsigned int bitType;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
vector <bitType> A[BIT], B[BIT];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

bitType popcount (bitType u)
{
    u = (u & 0x55555555) + ((u >> 1) & 0x55555555);
    u = (u & 0x33333333) + ((u >> 2) & 0x33333333);
    u = (u & 0x0F0F0F0F) + ((u >> 4) & 0x0F0F0F0F);
    u = (u & 0x00FF00FF) + ((u >> 8) & 0x00FF00FF);
    u = (u & 0x0000FFFF) + ((u >> 16) & 0x0000FFFF);
    return u;
}

int force(int l1, int r1, int l2, int r2)
{
	if (l1>r1 || l2>r2) return 0;
	int res = 0;
	int index1 = (l1-(l1%BIT))/BIT;
	int index2 = (l2-(l2%BIT))/BIT;
	int x1 = l1%BIT;
	int x2 = l2%BIT;
	for ( ; l1+BIT<=r1; l1 += BIT, l2+=BIT){
		res += popcount(A[x1][index1]^B[x2][index2]);
		index1++; index2++;
	}
	bitType q = BIT-r1+l1-1;
	res += popcount((A[x1][index1]>>q)^(B[x2][index2]>>q));
	return res;
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int x = 0; x<BIT; x++){
		for (int i = x; i<lena; i+=BIT){
			bitType tmp = 0;
			for (int k = i; k<i+BIT && k<lena; k++){
				tmp |= (bitType)(a[k]-'0')<<(i+BIT-1-k);
			}
			A[x].push_back(tmp);
		}
	}
	for (int x = 0; x<BIT; x++){
		for (int i = x; i<lenb; i+=BIT){
			bitType tmp = 0;
			for (int k = i; k<i+BIT && k<lenb; k++){
				tmp |= (bitType)(b[k]-'0')<<(i+BIT-1-k);
			}
			B[x].push_back(tmp);
		}
	}
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK)	work(i-BLOCK+1, i);
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		int t1 = ((p1-1)/BLOCK+1)*BLOCK;
		int l = t1-p1;
		if (t1<=e1){
			ans += force(p1,p1+l-1,p2,p2+l-1);
			p1 += l; p2 += l;
		}
		else {
			ans += force(p1,e1,p2,e2);
			p1 = e1+1; p2 = e2+1;
		}
		int t2 = (e1+1)/BLOCK*BLOCK-1;
		l = e1-t2;
		if (t2>=p1){
			ans += force(t2+1,t2+l,e2-l+1,e2);
			e1 -= l; e2 -= l;
		}
		else{
			ans += force(p1,e1,p2,e2);
			e1 = p1-1; e2 = p2-1;
		}
		/*
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		*/
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 5000;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK){
		work(i-BLOCK+1, i);
	}
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		//cout<<"left : "<<endl;
		//cout<<p1<<" "<<p2<<" "<<ans<<endl;
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		//cout<<"right : "<<endl;
		//cout<<e1<<" "<<e2<<" "<<ans<<endl;
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
				cout<<k<<"-"<<p2+(k-index)*BLOCK<<"-"<<cnt[k][p2+(k-index)*BLOCK]<<endl;
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 7000;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK){
		work(i-BLOCK+1, i);
	}
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		//cout<<"left : "<<endl;
		//cout<<p1<<" "<<p2<<" "<<ans<<endl;
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		//cout<<"right : "<<endl;
		//cout<<e1<<" "<<e2<<" "<<ans<<endl;
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
				//cout<<k<<"-"<<p2+(k-index)*BLOCK<<"-"<<cnt[k][p2+(k-index)*BLOCK]<<endl;
			}
		}
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250000;
const int BLOCK = 8000;
const int BIT = 32;

const long double PI = acos(0.0) * 2.0;

typedef complex<double> CD;

inline void FFT(vector<CD> &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 = 1; step < n; step <<= 1) {
    	double alpha = pi / step;
        for(int k = 0; k < step; k++) {
	     	CD omegak = exp(CD(0, alpha*k));
	      	for(int Ek = k; Ek < n; Ek += step << 1) {
		        int Ok = Ek + step;
	        	CD t = omegak * a[Ok];
	        	a[Ok] = a[Ek] - t;
	        	a[Ek] += t;
      		}
    	}
  	}
  	if(inverse) for(int i = 0; i < n; i++) a[i] /= n;
}

inline vector<double> operator * (const vector<double>& v1, const vector<double>& v2) {
  	int s1 = v1.size(), s2 = v2.size(), S = 2;
  	while(S < s1 + s2) S <<= 1;
  	vector<CD> a(S,0), b(S,0);
  	for(int i = 0; i < s1; i++) a[i] = v1[i];
  	FFT(a, false);
  	for(int i = 0; i < s2; i++) b[i] = v2[i];
  	FFT(b, false);
  	for(int i = 0; i < S; i++) a[i] *= b[i];
  	FFT(a, true);
  	vector<double> res(s1 + s2 - 1);
  	for(int i = 0; i < s1 + s2 - 1; i++) res[i] = a[i].real(); // 虚部均为0
  	return res;
}

char a[MAXN], b[MAXN];
vector <unsigned int> A[BIT], B[BIT];
int cnt[200][MAXN];
int lena, lenb;

double trans(int x)
{
	if (x==0) return -1;
	else return 1;
}

vector <double> X, Y, Z;

void work(int l, int r)
{
	X.clear();
	for (int i = l; i<=r; i++) X.push_back(trans(a[i]-'0'));
	Z = X*Y;
	int index = l/BLOCK;
	for (int i = BLOCK-1; i<lenb; i++){
		cnt[index][lenb-(i+1)] = (BLOCK-round(Z[i]))/2;
	}
}

int force(int l1, int r1, int l2, int r2)
{
	if (l1>r1 || l2>r2) return 0;
	int res = 0;
	int index1 = (l1-(l1%BIT))/BIT;
	int index2 = (l2-(l2%BIT))/BIT;
	int x1 = l1%BIT;
	int x2 = l2%BIT;
	for ( ; l1+BIT<=r1; l1 += BIT, l2+=BIT){
		res += __builtin_popcount(A[x1][index1]^B[x2][index2]);
		index1++; index2++;
	}
	unsigned int q = BIT-r1+l1-1;
	res += __builtin_popcount((A[x1][index1]>>q)^(B[x2][index2]>>q));
	return res;
}

int main()
{
	scanf("%s", a);
	scanf("%s", b);
	lena = strlen(a);
	lenb = strlen(b);
	for (int x = 0; x<BIT; x++){
		for (int i = x; i<lena; i+=BIT){
			unsigned int tmp = 0;
			for (int k = i; k<i+BIT && k<lena; k++){
				tmp |= (unsigned int)(a[k]-'0')<<(i+BIT-1-k);
			}
			A[x].push_back(tmp);
		}
	}
	for (int x = 0; x<BIT; x++){
		for (int i = x; i<lenb; i+=BIT){
			unsigned int tmp = 0;
			for (int k = i; k<i+BIT && k<lenb; k++){
				tmp |= (unsigned int)(b[k]-'0')<<(i+BIT-1-k);
			}
			B[x].push_back(tmp);
		}
	}
	for (int i = lenb-1; i>=0; i--) Y.push_back(trans(b[i]-'0'));
	int q, p1, p2, len;
	scanf("%d", &q);
	for (int i = BLOCK-1; i<lena; i+=BLOCK)	work(i-BLOCK+1, i);
	for (int i = 1; i<=q; i++){
		scanf("%d%d%d", &p1, &p2, &len);
		int e1 = p1+len-1;
		int e2 = p2+len-1;
		int ans = 0;
		int t1 = ((p1-1)/BLOCK+1)*BLOCK;
		int l = t1-p1;
		if (t1<=e1){
			ans += force(p1,p1+l-1,p2,p2+l-1);
			p1 += l; p2 += l;
		}
		else {
			ans += force(p1,e1,p2,e2);
			p1 = e1+1; p2 = e2+1;
		}
		int t2 = (e1+1)/BLOCK*BLOCK-1;
		l = e1-t2;
		if (t2>=p1){
			ans += force(t2+1,t2+l,e2-l+1,e2);
			e1 -= l; e2 -= l;
		}
		else{
			ans += force(p1,e1,p2,e2);
			e1 = p1-1; e2 = p2-1;
		}
		/*
		while (p1<=e1 && p1%BLOCK!=0){
			if (a[p1]!=b[p2]) ans++;
			p1++; p2++;
		}
		while (e1>=p1 && (e1+1)%BLOCK!=0){
			if (a[e1]!=b[e2]) ans++;
			e1--; e2--;
		}
		*/
		if (e1>p1){
			int index = p1/BLOCK;
			int t = (e1+1-p1)/BLOCK;
			for (int k = index; k<index+t; k++){
				ans += cnt[k][p2+(k-index)*BLOCK];
			}
		}
		cout<<ans<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define READER_BUF_SIZE 1048576
#define WRITER_BUF_SIZE 1048576
int reader_pt=READER_BUF_SIZE,reader_last;char reader_buf[READER_BUF_SIZE];
int writer_pt=0;char writer_buf[WRITER_BUF_SIZE];
#define mygc(c) {if(reader_pt==READER_BUF_SIZE)reader_pt=0,reader_last=fread(reader_buf,sizeof(char),READER_BUF_SIZE,stdin);(c)=reader_buf[reader_pt++];}
#define mypc(c) {if(writer_pt==WRITER_BUF_SIZE)writer_pt=0,fwrite(writer_buf,sizeof(char),WRITER_BUF_SIZE,stdout);writer_buf[writer_pt++]=(c);}
#define myed {fwrite(writer_buf,sizeof(char),writer_pt,stdout);writer_pt=0;}

#define ll long long
#define ull unsigned ll

void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(int *x, int *y){reader(x);reader(y);}
void reader(int *x, int *y, int *z){reader(x);reader(y);reader(z);}
void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}return s;}

void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}

template<class T> int bitCountSlow(T n){int r=0;while(n)r+=n%2,n/=2;return r;}
template<class T> int bitCount(T n){int i,r=0;static int t=0,b[65536];if(t==0){t=1;rep(i,65536)b[i]=bitCountSlow(i);}while(n)r+=b[n%65536],n/=65536;return r;}

unsigned A[32][8000], B[32][8000];
int As, Bs, Len;
int Q;

char Araw[500000], Braw[500000];

int val = 300, skip = 3000;
int memo[32][32][400];

int main(){
  int i, j, k, l;
  int x, xx, y, yy, z;
  int res;

  k = reader(Araw);
  //k = 200000; rep(i,k) Araw[i] = '0'+rand()%2;
  rep(i,k) if(Araw[i]=='1') A[0][i/32] |= (1ULL<<(i%32));
  k = reader(Braw);
  //k = 200000; rep(i,k) Braw[i] = '0'+rand()%2;
  rep(i,k) if(Braw[i]=='1') B[0][i/32] |= (1ULL<<(i%32));

  REP(i,1,32) rep(j,7900){
    A[i][j] = (A[i-1][j] >> 1) + ((A[i-1][j+1] % 2) << 31);
    B[i][j] = (B[i-1][j] >> 1) + ((B[i-1][j+1] % 2) << 31);
  }

  rep(i,32) rep(j,32) rep(k,300){
    memo[i][j][k] = 0;
    rep(l, skip) memo[i][j][k] += __builtin_popcount(A[i][val+l]^B[j][k+l]);
  }

  reader(&Q);
  //Q = 400000;
  while(Q--){
    reader(&As,&Bs,&Len);
    //As = rand()%5000; Bs = rand()%5000; Len = rand()%5000 + 189000;
    res = 0;
    while(Len%32){
      if(Araw[As] != Braw[Bs]) res++;
      As++; Bs++; Len--;
    }
    x = As/32; xx = As%32;
    y = Bs/32; yy = Bs%32;
    z = Len / 32;
    rep(i,z){
      if(x+i==300 && i+skip < z){
        res += memo[xx][yy][y+i];
        i += skip;
      }
      res += __builtin_popcount(A[xx][x+i]^B[yy][y+i]);
    }
    writer(res,'\n');
  }

  myed;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define READER_BUF_SIZE 1048576
#define WRITER_BUF_SIZE 1048576
int reader_pt=READER_BUF_SIZE,reader_last;char reader_buf[READER_BUF_SIZE];
int writer_pt=0;char writer_buf[WRITER_BUF_SIZE];
#define mygc(c) {if(reader_pt==READER_BUF_SIZE)reader_pt=0,reader_last=fread(reader_buf,sizeof(char),READER_BUF_SIZE,stdin);(c)=reader_buf[reader_pt++];}
#define mypc(c) {if(writer_pt==WRITER_BUF_SIZE)writer_pt=0,fwrite(writer_buf,sizeof(char),WRITER_BUF_SIZE,stdout);writer_buf[writer_pt++]=(c);}
#define myed {fwrite(writer_buf,sizeof(char),writer_pt,stdout);writer_pt=0;}

#define ll long long
#define ull unsigned ll

void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(int *x, int *y){reader(x);reader(y);}
void reader(int *x, int *y, int *z){reader(x);reader(y);reader(z);}
void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}return s;}

void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}

template<class T> int bitCountSlow(T n){int r=0;while(n)r+=n%2,n/=2;return r;}

int bt[66666];
int bitCount(unsigned n){ return bt[n&65535]+bt[n>>16]; }

unsigned A[32][8000], B[32][8000];
int As, Bs, Len;
int Q;

char Araw[500000], Braw[500000];

int main(){
  int i, j, k, l;
  int x, xx, y, yy, z;
  int res;

  rep(i,66666) bt[i] = bitCountSlow(i);

  k = reader(Araw);
  //k = 200000; rep(i,k) Araw[i] = '0'+rand()%2;
  rep(i,k) if(Araw[i]=='1') A[0][i/32] |= (1ULL<<(i%32));
  k = reader(Braw);
  //k = 200000; rep(i,k) Braw[i] = '0'+rand()%2;
  rep(i,k) if(Braw[i]=='1') B[0][i/32] |= (1ULL<<(i%32));

  REP(i,1,32) rep(j,7900){
    A[i][j] = (A[i-1][j] >> 1) + ((A[i-1][j+1] % 2) << 31);
    B[i][j] = (B[i-1][j] >> 1) + ((B[i-1][j+1] % 2) << 31);
  }

  reader(&Q);
  //Q = 400000;
  while(Q--){
    reader(&As,&Bs,&Len);
    //As = rand()%5000; Bs = rand()%5000; Len = rand()%5000 + 189000;
    res = 0;
    while(Len%32){
      if(Araw[As] != Braw[Bs]) res++;
      As++; Bs++; Len--;
    }
    x = As/32; xx = As%32;
    y = Bs/32; yy = Bs%32;
    z = Len / 32;
    rep(i,z) res += bitCount(A[xx][x+i]^B[yy][y+i]);
    writer(res,'\n');
  }

  myed;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define READER_BUF_SIZE 1048576
#define WRITER_BUF_SIZE 1048576
int reader_pt=READER_BUF_SIZE,reader_last;char reader_buf[READER_BUF_SIZE];
int writer_pt=0;char writer_buf[WRITER_BUF_SIZE];
#define mygc(c) {if(reader_pt==READER_BUF_SIZE)reader_pt=0,reader_last=fread(reader_buf,sizeof(char),READER_BUF_SIZE,stdin);(c)=reader_buf[reader_pt++];}
#define mypc(c) {if(writer_pt==WRITER_BUF_SIZE)writer_pt=0,fwrite(writer_buf,sizeof(char),WRITER_BUF_SIZE,stdout);writer_buf[writer_pt++]=(c);}
#define myed {fwrite(writer_buf,sizeof(char),writer_pt,stdout);writer_pt=0;}

#define ll long long
#define ull unsigned ll

void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(int *x, int *y){reader(x);reader(y);}
void reader(int *x, int *y, int *z){reader(x);reader(y);reader(z);}
void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}return s;}

void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}

template<class T> int bitCountSlow(T n){int r=0;while(n)r+=n%2,n/=2;return r;}
template<class T> int bitCount(T n){int i,r=0;static int t=0,b[65536];if(t==0){t=1;rep(i,65536)b[i]=bitCountSlow(i);}while(n)r+=b[n%65536],n/=65536;return r;}

unsigned A[32][8000], B[32][8000];
int As, Bs, Len;
int Q;

char Araw[500000], Braw[500000];

int val = 300, skip = 3000;
int memo[32][32][400];

int main(){
  int i, j, k, l;
  int x, xx, y, yy, z;
  int res;

  k = reader(Araw);
  //k = 200000; rep(i,k) Araw[i] = '0'+rand()%2;
  rep(i,k) if(Araw[i]=='1') A[0][i/32] |= (1ULL<<(i%32));
  k = reader(Braw);
  //k = 200000; rep(i,k) Braw[i] = '0'+rand()%2;
  rep(i,k) if(Braw[i]=='1') B[0][i/32] |= (1ULL<<(i%32));

  REP(i,1,32) rep(j,7900){
    A[i][j] = (A[i-1][j] >> 1) + ((A[i-1][j+1] % 2) << 31);
    B[i][j] = (B[i-1][j] >> 1) + ((B[i-1][j+1] % 2) << 31);
  }

  reader(&Q);
  //Q = 400000;
  while(Q--){
    reader(&As,&Bs,&Len);
    //As = rand()%5000; Bs = rand()%5000; Len = rand()%5000 + 189000;
    res = 0;
    while(Len%32){
      if(Araw[As] != Braw[Bs]) res++;
      As++; Bs++; Len--;
    }
    x = As/32; xx = As%32;
    y = Bs/32; yy = Bs%32;
    z = Len / 32;
    rep(i,z){
      res += __builtin_popcount(A[xx][x+i]^B[yy][y+i]);
    }
    writer(res,'\n');
  }

  myed;
  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;
}