#include <bits/stdc++.h>
using namespace std;
string st1, st2;
long ar1[1 << 18], ar2[1 << 18];
unsigned long v1[35][1 << 15], v2[35][1 << 15];
long tests, a, b, c, res;
long of1, of2;
long prec[1 << 17];
long calc(unsigned long x) {
  long res = 0;
  while (x) {
    if (x % 2) ++res;
    x /= 2;
  }
  return res;
}
long get(unsigned long x) { return prec[x >> 16] + prec[x & 65535]; }
long brute() {
  long res = 0;
  for (int i = 0; i < c; i++)
    if (ar1[i + a] != ar2[i + b]) ++res;
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  for (int i = 0; i < (1 << 16); i++) prec[i] = calc(i);
  cin >> st1;
  cin >> st2;
  for (int i = 0; i < st1.size(); i++) ar1[i] = st1[i] - 48;
  for (int i = 0; i < st2.size(); i++) ar2[i] = st2[i] - 48;
  for (int ofset = 0; ofset < 32; ofset++) {
    for (int i = 0; i + ofset < st1.size(); i++) {
      v1[ofset][i / 32] += (1 << (i % 32)) * ar1[i + ofset];
    }
    for (int i = 0; i + ofset < st2.size(); i++) {
      v2[ofset][i / 32] += (1 << (i % 32)) * ar2[i + ofset];
    }
  }
  long iters, sp1, sp2;
  cin >> tests;
  for (; tests; --tests) {
    cin >> a >> b >> c;
    res = 0;
    of1 = a % 32;
    of2 = b % 32;
    iters = c / 32;
    sp1 = a / 32;
    sp2 = b / 32;
    for (int i = 0; i < iters; i++) {
      res += get(v1[of1][sp1 + i] ^ v2[of2][sp2 + i]);
    }
    c -= iters * 32;
    a += iters * 32;
    b += iters * 32;
    for (int i = 0; i < c; i++) {
      if (ar1[a + i] != ar2[b + i]) ++res;
    }
    cout << res << "\n";
  }
  cin.get();
  cin.get();
  return 0;
}
