#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int Maxn = 300000;
void show(int *A, int N) {
  for (int i = 0; i < N; i++) cout << A[i] << " ";
  cout << endl;
}
struct Complex {
  double x, y;
  Complex(double _x = 0, double _y = 0) : x(_x), y(_y) {}
  Complex operator+(Complex &tt) { return Complex(x + tt.x, y + tt.y); }
  Complex operator-(Complex &tt) { return Complex(x - tt.x, y - tt.y); }
  Complex operator*(Complex &tt) {
    return Complex(x * tt.x - y * tt.y, x * tt.y + y * tt.x);
  }
} tA[Maxn], tB[Maxn], tC[Maxn], tmp[Maxn];
void FFT(int n, Complex *A, int rev) {
  for (int i = 1, j = 0; i < n; ++i) {
    for (int k = n >> 1; k > (j ^= k); k >>= 1)
      ;
    if (i < j) std::swap(A[i], A[j]);
  }
  for (int m = 2; m <= n; m <<= 1) {
    Complex wm(cos(2 * pi * rev / m), sin(2 * pi * rev / m));
    for (int i = 0; i < n; i += m) {
      Complex w(1., 0.);
      for (int j = i; j < i + m / 2; ++j) {
        Complex t = w * A[j + m / 2];
        A[j + m / 2] = A[j] - t;
        A[j] = A[j] + t;
        w = w * wm;
      }
    }
  }
  if (rev == -1) {
    for (int i = 0; i < n; ++i) {
      A[i].x /= n;
      A[i].y /= n;
    }
  }
}
int Getlen(int x) {
  int ans = 1;
  while (x > ans) ans <<= 1;
  return ans;
}
string s1, s2;
int T, N, M;
int A[Maxn], B[Maxn], C[Maxn];
int f[70][200005];
int mk = 0;
int lim = 3005;
int a[200010], b[200010];
inline void read(int &x) {
  char c;
  for (c = getchar(); c < '0' || c > '9'; c = getchar())
    ;
  for (x = 0; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
}
int main(int argc, char const *argv[]) {
  cin >> s1 >> s2;
  N = s1.size(), M = s2.size();
  read(T);
  reverse(s2.begin(), s2.end());
  for (int i = 0; i < N; i++) A[i] = s1[i] - '0';
  for (int i = 0; i < M; i++) b[i] = s2[i] - '0';
  int nC = N + lim - 1, m = Getlen(nC);
  for (int i = 0; i < m; i++) tA[i] = Complex(0, 0);
  for (int i = 0; i < N; i++) tA[i] = Complex(A[i], 1 - A[i]);
  FFT(m, tA, 1);
  for (int i = 0; i < M / lim; i++) {
    for (int j = i * lim, k = 0; k < lim; k++) B[k] = b[j + k];
    for (int j = 0; j < m; j++) tB[j] = Complex(0, 0);
    for (int j = 0; j < lim; j++) tB[j] = Complex(B[j], 1 - B[j]);
    FFT(m, tB, 1);
    for (int j = 0; j < m; j++) tC[j] = tA[j] * tB[j];
    FFT(m, tC, -1);
    for (int j = 0; j <= N - lim; j++) f[i][j] = tC[j + lim - 1].y + 0.5;
  }
  int cs = 0;
  while (T--) {
    int x, y, l, r, len;
    read(x);
    read(l);
    read(len);
    y = x + len - 1;
    r = M - l - 1;
    l = r - len + 1;
    int ans = 0;
    for (; l % lim && l <= r; l++, y--) ans += A[y] != b[l];
    for (int k = l / lim; l + lim <= r; l += lim, y -= lim, k++)
      ans += f[k][y - lim + 1];
    for (; l <= r; l++, y--) ans += A[y] != b[l];
    printf("%d\n", ans);
  }
  return 0;
}
