#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
unsigned a[33][200009], b[33][200009];
int cnt[(1 << 16) + 9];
char s[200009], t[200009];
const unsigned T = (1 << 16) - 1;
int go(unsigned x) { return cnt[x >> 16] + cnt[x & T]; }
int main() {
  for (int i = 1; i <= (1 << 16); i++) cnt[i] = __builtin_popcount(i);
  scanf("%s%s", s + 1, t + 1);
  int n = strlen(s + 1);
  int m = strlen(t + 1);
  for (int i = 1; i <= n; i++)
    for (int j = i; j < i + 32; j++)
      a[i & 31][i >> 5] = (a[i & 31][i >> 5] << 1) | (s[j] == '1');
  for (int i = 1; i <= m; i++)
    for (int j = i; j < i + 32; j++)
      b[i & 31][i >> 5] = (b[i & 31][i >> 5] << 1) | (t[j] == '1');
  int q;
  scanf("%d", &q);
  while (q--) {
    int x, y, len, ans = 0;
    scanf("%d%d%d", &x, &y, &len);
    x++;
    y++;
    int z = x + len;
    int xx = (x >> 5), yy = (y >> 5);
    int v1 = (x & 31), v2 = (y & 31);
    while (x + 32 <= z) {
      unsigned k = (a[v1][xx] ^ b[v2][yy]);
      ans += go(k);
      x += 32;
      xx++;
      y += 32;
      yy++;
    }
    while (x < z) ans += (s[x] != t[y]), x++, y++;
    printf("%d\n", ans);
  }
  return 0;
}
