#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair < int, int > ii;

namespace fft {
  typedef double dbl;

  struct num {
    dbl x, y;
    num() { x = y = 0; }
    num(dbl x, dbl y) : x(x), y(y) { }
  };

  inline num operator+(num a, num b) { return num(a.x + b.x, a.y + b.y); }
  inline num operator-(num a, num b) { return num(a.x - b.x, a.y - b.y); }
  inline num operator*(num a, num b) { return num(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); }
  inline num conj(num a) { return num(a.x, -a.y); }

  int base = 1;
  vector<num> roots = {{0, 0}, {1, 0}};
  vector<int> rev = {0, 1};

  const dbl PI = acosl(-1.0);

  void ensure_base(int nbase) {
    if (nbase <= base) {
      return;
    }
    rev.resize(1 << nbase);
    for (int i = 0; i < (1 << nbase); i++) {
      rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1));
    }
    roots.resize(1 << nbase);
    while (base < nbase) {
      dbl angle = 2 * PI / (1 << (base + 1));
//      num z(cos(angle), sin(angle));
      for (int i = 1 << (base - 1); i < (1 << base); i++) {
        roots[i << 1] = roots[i];
//        roots[(i << 1) + 1] = roots[i] * z;
        dbl angle_i = angle * (2 * i + 1 - (1 << base));
        roots[(i << 1) + 1] = num(cos(angle_i), sin(angle_i));
      }
      base++;
    }
  }

  void fft(vector<num> &a, int n = -1) {
    if (n == -1) {
      n = a.size();
    }
    assert((n & (n - 1)) == 0);
    int zeros = __builtin_ctz(n);
    ensure_base(zeros);
    int shift = base - zeros;
    for (int i = 0; i < n; i++) {
      if (i < (rev[i] >> shift)) {
        swap(a[i], a[rev[i] >> shift]);
      }
    }
    for (int k = 1; k < n; k <<= 1) {
      for (int i = 0; i < n; i += 2 * k) {
        for (int j = 0; j < k; j++) {
          num z = a[i + j + k] * roots[j + k];
          a[i + j + k] = a[i + j] - z;
          a[i + j] = a[i + j] + z;
        }
      }
    }
  }

  vector<num> fa, fb;

  vector<int> multiply(vector<int> &a, vector<int> &b) {
    int need = a.size() + b.size() - 1;
    int nbase = 0;
    while ((1 << nbase) < need) nbase++;
    ensure_base(nbase);
    int sz = 1 << nbase;
    if (sz > (int) fa.size()) {
      fa.resize(sz);
    }
    for (int i = 0; i < sz; i++) {
      int x = (i < (int) a.size() ? a[i] : 0);
      int y = (i < (int) b.size() ? b[i] : 0);
      fa[i] = num(x, y);
    }
    fft(fa, sz);
    num r(0, -0.25 / sz);
    for (int i = 0; i <= (sz >> 1); i++) {
      int j = (sz - i) & (sz - 1);
      num z = (fa[j] * fa[j] - conj(fa[i] * fa[i])) * r;
      if (i != j) {
        fa[j] = (fa[i] * fa[i] - conj(fa[j] * fa[j])) * r;
      }
      fa[i] = z;
    }
    fft(fa, sz);
    vector<int> res(need);
    for (int i = 0; i < need; i++) {
      res[i] = fa[i].x + (fa[i].x > 0 ? 0.5 : -0.5);
    }
    return res;
  }
};

const int N = 2e5 + 5;
const int K = 5000;
const int MASK = (1 << 16) - 1;

int n, m, q;
char a[N], b[N];
int cnt[N];
unsigned a1[32][N >> 5], a2[32][N >> 5];
vector < int > mul[N / K + 5];

int get(int l, int r, int len) {
  int ans = 0;
  while(len >= 32 and l % K != 1 and l % K and (l + 32) % K > l % K) {
    int w1 = l & 31;
    int w2 = r & 31;
    int x = l >> 5;
    int y = r >> 5;
    unsigned mask = a1[w1][x] ^ a2[w2][y];
    ans += cnt[mask & MASK] + cnt[mask >> 16];
    l += 32;
    r += 32;
    len -= 32;
  }
  while(len and l % K != 1) {
    ans += a[l] != b[r];
    l++;
    r++;
    len--;
  }
  while(len >= K) {
    int id = (l - 1) / K;
    int i = m - 1 - (r - 1);
    ans += (K - mul[id][i]) / 2;
    l += K;
    r += K;
    len -= K;
  }
  while(len >= 32 and l % K != 1 and l % K and (l + 32) % K > l % K) {
    int w1 = l & 31;
    int w2 = r & 31;
    int x = l >> 5;
    int y = r >> 5;
    unsigned mask = a1[w1][x] ^ a2[w2][y];
    ans += cnt[mask & MASK] + cnt[mask >> 16];
    l += 32;
    r += 32;
    len -= 32;
  }
  while(len) {
    ans += a[l] != b[r];
    l++;
    r++;
    len--;
  }
  return ans;
}

int main() {
  for(int i = 1; i < (1 << 16); i++)
    cnt[i] = cnt[i - (i & -i)] + 1;
  scanf("%s %s", a + 1, b + 1);
  n = strlen(a + 1);
  m = strlen(b + 1);
  for(int j = 0; j < 32; j++) {
    for(int i = 1; i + j <= n; i++)
      if(a[i + j] == '1')
        a1[j][i >> 5] |= 1 << (i & 31);
  }
  for(int j = 0; j < 32; j++) {
    for(int i = 1; i + j <= m; i++)
      if(b[i + j] == '1')
        a2[j][i >> 5] |= 1 << (i & 31);
  }
  auto upd = [&](char s[N], int n) {
    for(int i = 1; i <= n; i++) {
      if(s[i] == '1')
        s[i] = 1;
      else
        s[i] = -1;
    }
  };
  upd(a, n);
  upd(b, m);
  auto getVec = [&](char s[N], int l, int r) {
    vector < int > v;
    for(int i = l; i <= r; i++) {
      v.push_back(s[i]);
    }
    return v;
  };
  vector < int > vb = getVec(b, 1, m);
  reverse(vb.begin(), vb.end());
  for(int i = 1; i <= n; i += K) {
    int id = (i - 1) / K;
    int end = min(n, i + K - 1);
    vector < int > va = getVec(a, i, end);
    mul[id] = fft :: multiply(va, vb);
  }
  scanf("%d", &q);
  for(int i = 1; i <= q; i++) {
    int l, r, len;
    scanf("%d %d %d", &l, &r, &len);
    l++;
    r++;
    int res = get(l, r, len);
    printf("%d\n", res);
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair < int, int > ii;

namespace fft {
  typedef double dbl;

  struct num {
    dbl x, y;
    num() { x = y = 0; }
    num(dbl x, dbl y) : x(x), y(y) { }
  };

  inline num operator+(num a, num b) { return num(a.x + b.x, a.y + b.y); }
  inline num operator-(num a, num b) { return num(a.x - b.x, a.y - b.y); }
  inline num operator*(num a, num b) { return num(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); }
  inline num conj(num a) { return num(a.x, -a.y); }

  int base = 1;
  vector<num> roots = {{0, 0}, {1, 0}};
  vector<int> rev = {0, 1};

  const dbl PI = acosl(-1.0);

  void ensure_base(int nbase) {
    if (nbase <= base) {
      return;
    }
    rev.resize(1 << nbase);
    for (int i = 0; i < (1 << nbase); i++) {
      rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1));
    }
    roots.resize(1 << nbase);
    while (base < nbase) {
      dbl angle = 2 * PI / (1 << (base + 1));
//      num z(cos(angle), sin(angle));
      for (int i = 1 << (base - 1); i < (1 << base); i++) {
        roots[i << 1] = roots[i];
//        roots[(i << 1) + 1] = roots[i] * z;
        dbl angle_i = angle * (2 * i + 1 - (1 << base));
        roots[(i << 1) + 1] = num(cos(angle_i), sin(angle_i));
      }
      base++;
    }
  }

  void fft(vector<num> &a, int n = -1) {
    if (n == -1) {
      n = a.size();
    }
    assert((n & (n - 1)) == 0);
    int zeros = __builtin_ctz(n);
    ensure_base(zeros);
    int shift = base - zeros;
    for (int i = 0; i < n; i++) {
      if (i < (rev[i] >> shift)) {
        swap(a[i], a[rev[i] >> shift]);
      }
    }
    for (int k = 1; k < n; k <<= 1) {
      for (int i = 0; i < n; i += 2 * k) {
        for (int j = 0; j < k; j++) {
          num z = a[i + j + k] * roots[j + k];
          a[i + j + k] = a[i + j] - z;
          a[i + j] = a[i + j] + z;
        }
      }
    }
  }

  vector<num> fa, fb;

  vector<int> multiply(vector<int> &a, vector<int> &b) {
    int need = a.size() + b.size() - 1;
    int nbase = 0;
    while ((1 << nbase) < need) nbase++;
    ensure_base(nbase);
    int sz = 1 << nbase;
    if (sz > (int) fa.size()) {
      fa.resize(sz);
    }
    for (int i = 0; i < sz; i++) {
      int x = (i < (int) a.size() ? a[i] : 0);
      int y = (i < (int) b.size() ? b[i] : 0);
      fa[i] = num(x, y);
    }
    fft(fa, sz);
    num r(0, -0.25 / sz);
    for (int i = 0; i <= (sz >> 1); i++) {
      int j = (sz - i) & (sz - 1);
      num z = (fa[j] * fa[j] - conj(fa[i] * fa[i])) * r;
      if (i != j) {
        fa[j] = (fa[i] * fa[i] - conj(fa[j] * fa[j])) * r;
      }
      fa[i] = z;
    }
    fft(fa, sz);
    vector<int> res(need);
    for (int i = 0; i < need; i++) {
      res[i] = fa[i].x + (fa[i].x > 0 ? 0.5 : -0.5);
    }
    return res;
  }
};

const int N = 2e5 + 5;
const int K = 8000;
const int MASK = (1 << 16) - 1;

int n, m, q;
char a[N], b[N];
int cnt[N];
unsigned a1[32][N >> 5], a2[32][N >> 5];
vector < int > mul[N / K + 5];

int get(int l, int r, int len) {
  int ans = 0;
  while(len >= 32 and l % K != 1 and l % K and ((l + 32) % K > l % K or (l + 32) % K == 0)) {
    int w1 = (l - 1) & 31;
    int w2 = (r - 1) & 31;
    int x = (l - 1) >> 5;
    int y = (r - 1) >> 5;
    unsigned mask = a1[w1][x] ^ a2[w2][y];
    ans += cnt[mask & MASK] + cnt[mask >> 16];
    l += 32;
    r += 32;
    len -= 32;
  }
  while(len and l % K != 1) {
    ans += a[l] != b[r];
    l++;
    r++;
    len--;
  }
  while(len >= K) {
    int id = (l - 1) / K;
    int i = m - 1 - (r - 1);
    ans += (K - mul[id][i]) / 2;
    l += K;
    r += K;
    len -= K;
  }
  while(len >= 32) {
    int w1 = (l - 1) & 31;
    int w2 = (r - 1) & 31;
    int x = (l - 1) >> 5;
    int y = (r - 1) >> 5;
    unsigned mask = a1[w1][x] ^ a2[w2][y];
    ans += cnt[mask & MASK] + cnt[mask >> 16];
    l += 32;
    r += 32;
    len -= 32;
  }
  while(len) {
    ans += a[l] != b[r];
    l++;
    r++;
    len--;
  }
  return ans;
}

int main() {
  for(int i = 1; i < (1 << 16); i++)
    cnt[i] = cnt[i - (i & -i)] + 1;
  scanf("%s %s", a + 1, b + 1);
  n = strlen(a + 1);
  m = strlen(b + 1);
  for(int j = 0; j < 32; j++) {
    for(int i = 0; i + j < n; i++)
      if(a[i + j + 1] == '1')
        a1[j][i >> 5] |= 1 << (i & 31);
  }
  for(int j = 0; j < 32; j++) {
    for(int i = 0; i + j < m; i++)
      if(b[i + j + 1] == '1')
        a2[j][i >> 5] |= 1 << (i & 31);
  }
  auto upd = [&](char s[N], int n) {
    for(int i = 1; i <= n; i++) {
      if(s[i] == '1')
        s[i] = 1;
      else
        s[i] = -1;
    }
  };
  upd(a, n);
  upd(b, m);
  auto getVec = [&](char s[N], int l, int r) {
    vector < int > v;
    for(int i = l; i <= r; i++) {
      v.push_back(s[i]);
    }
    return v;
  };
  vector < int > vb = getVec(b, 1, m);
  reverse(vb.begin(), vb.end());
  for(int i = 1; i <= n; i += K) {
    int id = (i - 1) / K;
    int end = min(n, i + K - 1);
    vector < int > va = getVec(a, i, end);
    mul[id] = fft :: multiply(va, vb);
  }
  scanf("%d", &q);
  for(int i = 1; i <= q; i++) {
    int l, r, len;
    scanf("%d %d %d", &l, &r, &len);
    l++;
    r++;
    int res = get(l, r, len);
    printf("%d\n", res);
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair < int, int > ii;

namespace fft {
  typedef double dbl;

  struct num {
    dbl x, y;
    num() { x = y = 0; }
    num(dbl x, dbl y) : x(x), y(y) { }
  };

  inline num operator+(num a, num b) { return num(a.x + b.x, a.y + b.y); }
  inline num operator-(num a, num b) { return num(a.x - b.x, a.y - b.y); }
  inline num operator*(num a, num b) { return num(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); }
  inline num conj(num a) { return num(a.x, -a.y); }

  int base = 1;
  vector<num> roots = {{0, 0}, {1, 0}};
  vector<int> rev = {0, 1};

  const dbl PI = acosl(-1.0);

  void ensure_base(int nbase) {
    if (nbase <= base) {
      return;
    }
    rev.resize(1 << nbase);
    for (int i = 0; i < (1 << nbase); i++) {
      rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1));
    }
    roots.resize(1 << nbase);
    while (base < nbase) {
      dbl angle = 2 * PI / (1 << (base + 1));
//      num z(cos(angle), sin(angle));
      for (int i = 1 << (base - 1); i < (1 << base); i++) {
        roots[i << 1] = roots[i];
//        roots[(i << 1) + 1] = roots[i] * z;
        dbl angle_i = angle * (2 * i + 1 - (1 << base));
        roots[(i << 1) + 1] = num(cos(angle_i), sin(angle_i));
      }
      base++;
    }
  }

  void fft(vector<num> &a, int n = -1) {
    if (n == -1) {
      n = a.size();
    }
    assert((n & (n - 1)) == 0);
    int zeros = __builtin_ctz(n);
    ensure_base(zeros);
    int shift = base - zeros;
    for (int i = 0; i < n; i++) {
      if (i < (rev[i] >> shift)) {
        swap(a[i], a[rev[i] >> shift]);
      }
    }
    for (int k = 1; k < n; k <<= 1) {
      for (int i = 0; i < n; i += 2 * k) {
        for (int j = 0; j < k; j++) {
          num z = a[i + j + k] * roots[j + k];
          a[i + j + k] = a[i + j] - z;
          a[i + j] = a[i + j] + z;
        }
      }
    }
  }

  vector<num> fa, fb;

  vector<int> multiply(vector<int> &a, vector<int> &b) {
    int need = a.size() + b.size() - 1;
    int nbase = 0;
    while ((1 << nbase) < need) nbase++;
    ensure_base(nbase);
    int sz = 1 << nbase;
    if (sz > (int) fa.size()) {
      fa.resize(sz);
    }
    for (int i = 0; i < sz; i++) {
      int x = (i < (int) a.size() ? a[i] : 0);
      int y = (i < (int) b.size() ? b[i] : 0);
      fa[i] = num(x, y);
    }
    fft(fa, sz);
    num r(0, -0.25 / sz);
    for (int i = 0; i <= (sz >> 1); i++) {
      int j = (sz - i) & (sz - 1);
      num z = (fa[j] * fa[j] - conj(fa[i] * fa[i])) * r;
      if (i != j) {
        fa[j] = (fa[i] * fa[i] - conj(fa[j] * fa[j])) * r;
      }
      fa[i] = z;
    }
    fft(fa, sz);
    vector<int> res(need);
    for (int i = 0; i < need; i++) {
      res[i] = fa[i].x + (fa[i].x > 0 ? 0.5 : -0.5);
    }
    return res;
  }
};

const int N = 2e5 + 5;
const int K = 5000;
const int MASK = (1 << 16) - 1;

int n, m, q;
char a[N], b[N];
int cnt[N];
unsigned a1[32][N >> 5], a2[32][N >> 5];
vector < int > mul[N / K + 5];

int get(int l, int r, int len) {
  int ans = 0;
  // while(len >= 32 and l % K != 1 and l % K and ((l + 32) % K > l % K or (l + 32) % K == 0)) {
  //   int w1 = l & 31;
  //   int w2 = r & 31;
  //   int x = l >> 5;
  //   int y = r >> 5;
  //   unsigned mask = a1[w1][x] ^ a2[w2][y];
  //   ans += cnt[mask & MASK] + cnt[mask >> 16];
  //   l += 32;
  //   r += 32;
  //   len -= 32;
  // }
  while(len and l % K != 1) {
    ans += a[l] != b[r];
    l++;
    r++;
    len--;
  }
  while(len >= K) {
    int id = (l - 1) / K;
    int i = m - 1 - (r - 1);
    ans += (K - mul[id][i]) / 2;
    l += K;
    r += K;
    len -= K;
  }
  while(len >= 32) {
    int w1 = (l - 1) & 31;
    int w2 = (r - 1) & 31;
    int x = (l - 1) >> 5;
    int y = (r - 1) >> 5;
    unsigned mask = a1[w1][x] ^ a2[w2][y];
    ans += cnt[mask & MASK] + cnt[mask >> 16];
    l += 32;
    r += 32;
    len -= 32;
  }
  while(len) {
    ans += a[l] != b[r];
    l++;
    r++;
    len--;
  }
  return ans;
}

int main() {
  for(int i = 1; i < (1 << 16); i++)
    cnt[i] = cnt[i - (i & -i)] + 1;
  scanf("%s %s", a + 1, b + 1);
  n = strlen(a + 1);
  m = strlen(b + 1);
  for(int j = 0; j < 32; j++) {
    for(int i = 0; i + j < n; i++)
      if(a[i + j] == '1')
        a1[j][i >> 5] |= 1 << (i & 31);
  }
  for(int j = 0; j < 32; j++) {
    for(int i = 0; i + j < m; i++)
      if(b[i + j] == '1')
        a2[j][i >> 5] |= 1 << (i & 31);
  }
  auto upd = [&](char s[N], int n) {
    for(int i = 1; i <= n; i++) {
      if(s[i] == '1')
        s[i] = 1;
      else
        s[i] = -1;
    }
  };
  upd(a, n);
  upd(b, m);
  auto getVec = [&](char s[N], int l, int r) {
    vector < int > v;
    for(int i = l; i <= r; i++) {
      v.push_back(s[i]);
    }
    return v;
  };
  vector < int > vb = getVec(b, 1, m);
  reverse(vb.begin(), vb.end());
  for(int i = 1; i <= n; i += K) {
    int id = (i - 1) / K;
    int end = min(n, i + K - 1);
    vector < int > va = getVec(a, i, end);
    mul[id] = fft :: multiply(va, vb);
  }
  scanf("%d", &q);
  for(int i = 1; i <= q; i++) {
    int l, r, len;
    scanf("%d %d %d", &l, &r, &len);
    l++;
    r++;
    int res = get(l, r, len);
    printf("%d\n", res);
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair < int, int > ii;

namespace fft {
  typedef double dbl;

  struct num {
    dbl x, y;
    num() { x = y = 0; }
    num(dbl x, dbl y) : x(x), y(y) { }
  };

  inline num operator+(num a, num b) { return num(a.x + b.x, a.y + b.y); }
  inline num operator-(num a, num b) { return num(a.x - b.x, a.y - b.y); }
  inline num operator*(num a, num b) { return num(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); }
  inline num conj(num a) { return num(a.x, -a.y); }

  int base = 1;
  vector<num> roots = {{0, 0}, {1, 0}};
  vector<int> rev = {0, 1};

  const dbl PI = acosl(-1.0);

  void ensure_base(int nbase) {
    if (nbase <= base) {
      return;
    }
    rev.resize(1 << nbase);
    for (int i = 0; i < (1 << nbase); i++) {
      rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1));
    }
    roots.resize(1 << nbase);
    while (base < nbase) {
      dbl angle = 2 * PI / (1 << (base + 1));
//      num z(cos(angle), sin(angle));
      for (int i = 1 << (base - 1); i < (1 << base); i++) {
        roots[i << 1] = roots[i];
//        roots[(i << 1) + 1] = roots[i] * z;
        dbl angle_i = angle * (2 * i + 1 - (1 << base));
        roots[(i << 1) + 1] = num(cos(angle_i), sin(angle_i));
      }
      base++;
    }
  }

  void fft(vector<num> &a, int n = -1) {
    if (n == -1) {
      n = a.size();
    }
    assert((n & (n - 1)) == 0);
    int zeros = __builtin_ctz(n);
    ensure_base(zeros);
    int shift = base - zeros;
    for (int i = 0; i < n; i++) {
      if (i < (rev[i] >> shift)) {
        swap(a[i], a[rev[i] >> shift]);
      }
    }
    for (int k = 1; k < n; k <<= 1) {
      for (int i = 0; i < n; i += 2 * k) {
        for (int j = 0; j < k; j++) {
          num z = a[i + j + k] * roots[j + k];
          a[i + j + k] = a[i + j] - z;
          a[i + j] = a[i + j] + z;
        }
      }
    }
  }

  vector<num> fa, fb;

  vector<int> multiply(vector<int> &a, vector<int> &b) {
    int need = a.size() + b.size() - 1;
    int nbase = 0;
    while ((1 << nbase) < need) nbase++;
    ensure_base(nbase);
    int sz = 1 << nbase;
    if (sz > (int) fa.size()) {
      fa.resize(sz);
    }
    for (int i = 0; i < sz; i++) {
      int x = (i < (int) a.size() ? a[i] : 0);
      int y = (i < (int) b.size() ? b[i] : 0);
      fa[i] = num(x, y);
    }
    fft(fa, sz);
    num r(0, -0.25 / sz);
    for (int i = 0; i <= (sz >> 1); i++) {
      int j = (sz - i) & (sz - 1);
      num z = (fa[j] * fa[j] - conj(fa[i] * fa[i])) * r;
      if (i != j) {
        fa[j] = (fa[i] * fa[i] - conj(fa[j] * fa[j])) * r;
      }
      fa[i] = z;
    }
    fft(fa, sz);
    vector<int> res(need);
    for (int i = 0; i < need; i++) {
      res[i] = fa[i].x + (fa[i].x > 0 ? 0.5 : -0.5);
    }
    return res;
  }
};

const int N = 2e5 + 5;
const int K = 5000;
const int MASK = (1 << 16) - 1;

int n, m, q;
char a[N], b[N];
int cnt[N];
unsigned a1[32][N >> 5], a2[32][N >> 5];
vector < int > mul[N / K + 5];

int get(int l, int r, int len) {
  int ans = 0;
  // while(len >= 32 and l % K != 1 and l % K and ((l + 32) % K > l % K or (l + 32) % K == 0)) {
  //   int w1 = l & 31;
  //   int w2 = r & 31;
  //   int x = l >> 5;
  //   int y = r >> 5;
  //   unsigned mask = a1[w1][x] ^ a2[w2][y];
  //   ans += cnt[mask & MASK] + cnt[mask >> 16];
  //   l += 32;
  //   r += 32;
  //   len -= 32;
  // }
  while(len and l % K != 1) {
    ans += a[l] != b[r];
    l++;
    r++;
    len--;
  }
  while(len >= K) {
    int id = (l - 1) / K;
    int i = m - 1 - (r - 1);
    ans += (K - mul[id][i]) / 2;
    l += K;
    r += K;
    len -= K;
  }
  while(len >= 32) {
    int w1 = l & 31;
    int w2 = r & 31;
    int x = l >> 5;
    int y = r >> 5;
    unsigned mask = a1[w1][x] ^ a2[w2][y];
    ans += cnt[mask & MASK] + cnt[mask >> 16];
    l += 32;
    r += 32;
    len -= 32;
  }
  while(len) {
    ans += a[l] != b[r];
    l++;
    r++;
    len--;
  }
  return ans;
}

int main() {
  for(int i = 1; i < (1 << 16); i++)
    cnt[i] = cnt[i - (i & -i)] + 1;
  scanf("%s %s", a + 1, b + 1);
  n = strlen(a + 1);
  m = strlen(b + 1);
  for(int j = 0; j < 32; j++) {
    for(int i = 1; i + j <= n; i++)
      if(a[i + j] == '1')
        a1[j][i >> 5] |= 1 << (i & 31);
  }
  for(int j = 0; j < 32; j++) {
    for(int i = 1; i + j <= m; i++)
      if(b[i + j] == '1')
        a2[j][i >> 5] |= 1 << (i & 31);
  }
  auto upd = [&](char s[N], int n) {
    for(int i = 1; i <= n; i++) {
      if(s[i] == '1')
        s[i] = 1;
      else
        s[i] = -1;
    }
  };
  upd(a, n);
  upd(b, m);
  auto getVec = [&](char s[N], int l, int r) {
    vector < int > v;
    for(int i = l; i <= r; i++) {
      v.push_back(s[i]);
    }
    return v;
  };
  vector < int > vb = getVec(b, 1, m);
  reverse(vb.begin(), vb.end());
  for(int i = 1; i <= n; i += K) {
    int id = (i - 1) / K;
    int end = min(n, i + K - 1);
    vector < int > va = getVec(a, i, end);
    mul[id] = fft :: multiply(va, vb);
  }
  scanf("%d", &q);
  for(int i = 1; i <= q; i++) {
    int l, r, len;
    scanf("%d %d %d", &l, &r, &len);
    l++;
    r++;
    int res = get(l, r, len);
    printf("%d\n", res);
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair < int, int > ii;

namespace fft {
  typedef double dbl;

  struct num {
    dbl x, y;
    num() { x = y = 0; }
    num(dbl x, dbl y) : x(x), y(y) { }
  };

  inline num operator+(num a, num b) { return num(a.x + b.x, a.y + b.y); }
  inline num operator-(num a, num b) { return num(a.x - b.x, a.y - b.y); }
  inline num operator*(num a, num b) { return num(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); }
  inline num conj(num a) { return num(a.x, -a.y); }

  int base = 1;
  vector<num> roots = {{0, 0}, {1, 0}};
  vector<int> rev = {0, 1};

  const dbl PI = acosl(-1.0);

  void ensure_base(int nbase) {
    if (nbase <= base) {
      return;
    }
    rev.resize(1 << nbase);
    for (int i = 0; i < (1 << nbase); i++) {
      rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1));
    }
    roots.resize(1 << nbase);
    while (base < nbase) {
      dbl angle = 2 * PI / (1 << (base + 1));
//      num z(cos(angle), sin(angle));
      for (int i = 1 << (base - 1); i < (1 << base); i++) {
        roots[i << 1] = roots[i];
//        roots[(i << 1) + 1] = roots[i] * z;
        dbl angle_i = angle * (2 * i + 1 - (1 << base));
        roots[(i << 1) + 1] = num(cos(angle_i), sin(angle_i));
      }
      base++;
    }
  }

  void fft(vector<num> &a, int n = -1) {
    if (n == -1) {
      n = a.size();
    }
    assert((n & (n - 1)) == 0);
    int zeros = __builtin_ctz(n);
    ensure_base(zeros);
    int shift = base - zeros;
    for (int i = 0; i < n; i++) {
      if (i < (rev[i] >> shift)) {
        swap(a[i], a[rev[i] >> shift]);
      }
    }
    for (int k = 1; k < n; k <<= 1) {
      for (int i = 0; i < n; i += 2 * k) {
        for (int j = 0; j < k; j++) {
          num z = a[i + j + k] * roots[j + k];
          a[i + j + k] = a[i + j] - z;
          a[i + j] = a[i + j] + z;
        }
      }
    }
  }

  vector<num> fa, fb;

  vector<int> multiply(vector<int> &a, vector<int> &b) {
    int need = a.size() + b.size() - 1;
    int nbase = 0;
    while ((1 << nbase) < need) nbase++;
    ensure_base(nbase);
    int sz = 1 << nbase;
    if (sz > (int) fa.size()) {
      fa.resize(sz);
    }
    for (int i = 0; i < sz; i++) {
      int x = (i < (int) a.size() ? a[i] : 0);
      int y = (i < (int) b.size() ? b[i] : 0);
      fa[i] = num(x, y);
    }
    fft(fa, sz);
    num r(0, -0.25 / sz);
    for (int i = 0; i <= (sz >> 1); i++) {
      int j = (sz - i) & (sz - 1);
      num z = (fa[j] * fa[j] - conj(fa[i] * fa[i])) * r;
      if (i != j) {
        fa[j] = (fa[i] * fa[i] - conj(fa[j] * fa[j])) * r;
      }
      fa[i] = z;
    }
    fft(fa, sz);
    vector<int> res(need);
    for (int i = 0; i < need; i++) {
      res[i] = fa[i].x + (fa[i].x > 0 ? 0.5 : -0.5);
    }
    return res;
  }
};

const int N = 2e5 + 5;
const int K = 5000;
const int MASK = (1 << 16) - 1;

int n, m, q;
char a[N], b[N];
int cnt[N];
unsigned a1[32][N >> 5], a2[32][N >> 5];
vector < int > mul[N / K + 5];

int get(int l, int r, int len) {
  int ans = 0;
  while(len >= 32 and l % K != 1 and l % K and ((l + 32) % K > l % K or (l + 32) % K == 0)) {
    int w1 = l & 31;
    int w2 = r & 31;
    int x = l >> 5;
    int y = r >> 5;
    unsigned mask = a1[w1][x] ^ a2[w2][y];
    ans += cnt[mask & MASK] + cnt[mask >> 16];
    l += 32;
    r += 32;
    len -= 32;
  }
  while(len and l % K != 1) {
    ans += a[l] != b[r];
    l++;
    r++;
    len--;
  }
  while(len >= K) {
    int id = (l - 1) / K;
    int i = m - 1 - (r - 1);
    ans += (K - mul[id][i]) / 2;
    l += K;
    r += K;
    len -= K;
  }
  while(len >= 32) {
    int w1 = l & 31;
    int w2 = r & 31;
    int x = l >> 5;
    int y = r >> 5;
    unsigned mask = a1[w1][x] ^ a2[w2][y];
    ans += cnt[mask & MASK] + cnt[mask >> 16];
    l += 32;
    r += 32;
    len -= 32;
  }
  while(len) {
    ans += a[l] != b[r];
    l++;
    r++;
    len--;
  }
  return ans;
}

int main() {
  for(int i = 1; i < (1 << 16); i++)
    cnt[i] = cnt[i - (i & -i)] + 1;
  scanf("%s %s", a + 1, b + 1);
  n = strlen(a + 1);
  m = strlen(b + 1);
  for(int j = 0; j < 32; j++) {
    for(int i = 1; i + j <= n; i++)
      if(a[i + j] == '1')
        a1[j][i >> 5] |= 1 << (i & 31);
  }
  for(int j = 0; j < 32; j++) {
    for(int i = 1; i + j <= m; i++)
      if(b[i + j] == '1')
        a2[j][i >> 5] |= 1 << (i & 31);
  }
  auto upd = [&](char s[N], int n) {
    for(int i = 1; i <= n; i++) {
      if(s[i] == '1')
        s[i] = 1;
      else
        s[i] = -1;
    }
  };
  upd(a, n);
  upd(b, m);
  auto getVec = [&](char s[N], int l, int r) {
    vector < int > v;
    for(int i = l; i <= r; i++) {
      v.push_back(s[i]);
    }
    return v;
  };
  vector < int > vb = getVec(b, 1, m);
  reverse(vb.begin(), vb.end());
  for(int i = 1; i <= n; i += K) {
    int id = (i - 1) / K;
    int end = min(n, i + K - 1);
    vector < int > va = getVec(a, i, end);
    mul[id] = fft :: multiply(va, vb);
  }
  scanf("%d", &q);
  for(int i = 1; i <= q; i++) {
    int l, r, len;
    scanf("%d %d %d", &l, &r, &len);
    l++;
    r++;
    int res = get(l, r, len);
    printf("%d\n", res);
  }
  return 0;
}


#include <cstdio>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
#define LEN_MAX 200000
char a[LEN_MAX+1];
char b[LEN_MAX+1];
int main() {
    int q; scanf("%[01] %[01]%d", a, b, &q);
    for (char *p = a; *p; ++ p) *p = (*p == '1');
    for (char *p = b; *p; ++ p) *p = (*p == '1');
    while (q --) {
        int p1, p2, len; scanf("%d%d%d", &p1, &p2, &len);
        int cnt = 0;
        int i = 0;
        for (; i < len-16; ) {
            __asm__ (
                    "pxor %%xmm1, %%xmm1 ;" :);
            for (int j = 0; j < 127 and i < len-16; ++ j, i += 16) {
                volatile char *pa = a + p1 + i;
                volatile char *pb = b + p2 + i;
                __asm__ (
                        "vmovdqu (%0), %%xmm2 ;"
                        "vmovdqu (%1), %%xmm3 ;"
                        "vpxor %%xmm2, %%xmm3, %%xmm2 ;"
                        "vpaddb %%xmm1, %%xmm2, %%xmm1 ;"
                        : : "r" (pa), "r" (pb));
            }
            volatile char acc[16];
            __asm__ (
                    "vmovdqu %%xmm1, (%0) ;"
                    : : "r" (acc));
            repeat (k,16) cnt += acc[k];
        }
        for (; i < len; ++ i) if (a[p1 + i] != b[p2 + i]) ++ cnt;
        printf("%d\n", cnt);
    }
    return 0;
}


#include <cstdio>
#include <immintrin.h>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
#define LEN_MAX 200000
char a[LEN_MAX+1];
char b[LEN_MAX+1];
int main() {
    int q; scanf("%[01] %[01]%d", a, b, &q);
    for (char *p = a; *p; ++ p) *p = (*p == '1');
    for (char *p = b; *p; ++ p) *p = (*p == '1');
    while (q --) {
        int p1, p2, len; scanf("%d%d%d", &p1, &p2, &len);
        int cnt = 0;
        int i = 0;
        for (; i < len-16; ) {
            _mm256_loadu_si256();
            __asm__ (
                    "pxor %%xmm1, %%xmm1 ;" :);
            for (int j = 0; j < 127 and i < len-16; ++ j, i += 16) {
                volatile char *pa = a + p1 + i;
                volatile char *pb = b + p2 + i;
                __asm__ (
                        "vmovdqu (%0), %%xmm2 ;"
                        "vmovdqu (%1), %%xmm3 ;"
                        "vpxor %%xmm2, %%xmm3, %%xmm2 ;"
                        "vpaddb %%xmm1, %%xmm2, %%xmm1 ;"
                        : : "r" (pa), "r" (pb));
            }
            volatile char acc[16];
            __asm__ (
                    "vmovdqu %%xmm1, (%0) ;"
                    : : "r" (acc));
            repeat (k,16) cnt += acc[k];
        }
        for (; i < len; ++ i) if (a[p1 + i] != b[p2 + i]) ++ cnt;
        printf("%d\n", cnt);
    }
    return 0;
}


#include <cstdio>
#include <immintrin.h>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
#define LEN_MAX 200000
char a[LEN_MAX+1] __attribute__((aligned(32)));
char b[LEN_MAX+1] __attribute__((aligned(32)));
int main() {
    int q; scanf("%[01] %[01]%d", a, b, &q);
    for (char *p = a; *p; ++ p) *p = (*p == '1');
    for (char *p = b; *p; ++ p) *p = (*p == '1');
    while (q --) {
        int p1, p2, len; scanf("%d%d%d", &p1, &p2, &len);
        int cnt = 0;
        int i = 0;
        for (; i < len-32; ) {
            __m256i acc = {};
            char *pacc = (char *)&acc;
            for (int j = 0; j < 127 and i < len-32; ++ j, i += 32) {
                char *pa = a + p1 + i;
                char *pb = b + p2 + i;
                __asm__ (
                        "vmovdqu (%1), %%xmm1 ;"
                        "vmovdqu (%2), %%xmm2 ;"
                        "vpxor %%xmm1, %%xmm2, %%xmm1 ;"
                        "mov %0, rax ;"
                        "vpaddb %%xmm4, %%xmm1, (rax) ;"
                        : : "r" (pacc), "r" (pa), "r" (pb) : "rax");
            }
            repeat (k,32) cnt += reinterpret_cast<char *>(& acc)[k];
        }
        for (; i < len; ++ i) if (a[p1 + i] != b[p2 + i]) ++ cnt;
        printf("%d\n", cnt);
    }
    return 0;
}


#include <cstdio>
#include <immintrin.h>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
#define LEN_MAX 200000
char a[LEN_MAX+1];
char b[LEN_MAX+1];
int main() {
    int q; scanf("%[01] %[01]%d", a, b, &q);
    for (char *p = a; *p; ++ p) *p = (*p == '1');
    for (char *p = b; *p; ++ p) *p = (*p == '1');
    while (q --) {
        int p1, p2, len; scanf("%d%d%d", &p1, &p2, &len);
        int cnt = 0;
        int i = 0;
        for (; i < len-16; ) {
            __asm__ (
                    "pxor %%xmm1, %%xmm1 ;" :);
            for (int j = 0; j < 127 and i < len-16; ++ j, i += 16) {
                volatile char *pa = a + p1 + i;
                volatile char *pb = b + p2 + i;
                __asm__ (
                        "vmovdqu (%0), %%xmm2 ;"
                        "vmovdqu (%1), %%xmm3 ;"
                        "vpxor %%xmm2, %%xmm3, %%xmm2 ;"
                        "vpaddb %%xmm1, %%xmm2, %%xmm1 ;"
                        : : "r" (pa), "r" (pb));
            }
            volatile char acc[16];
            __asm__ (
                    "vmovdqu %%xmm1, (%0) ;"
                    : : "r" (acc));
            _mm256_loadu_si256(acc);
            repeat (k,16) cnt += acc[k];
        }
        for (; i < len; ++ i) if (a[p1 + i] != b[p2 + i]) ++ cnt;
        printf("%d\n", cnt);
    }
    return 0;
}


#include <cstdio>
#include <immintrin.h>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
#define LEN_MAX 200000
char a[LEN_MAX+1] __attribute__((aligned(32)));
char b[LEN_MAX+1] __attribute__((aligned(32)));
int main() {
    int q; scanf("%[01] %[01]%d", a, b, &q);
    for (char *p = a; *p; ++ p) *p = (*p == '1');
    for (char *p = b; *p; ++ p) *p = (*p == '1');
    while (q --) {
        int p1, p2, len; scanf("%d%d%d", &p1, &p2, &len);
        int cnt = 0;
        int i = 0;
        for (; i < len-32; ) {
            volatile __m256i acc = {};
            char *pacc = (char *)&acc;
            for (int j = 0; j < 127 and i < len-32; ++ j, i += 32) {
                char *pa = a + p1 + i;
                char *pb = b + p2 + i;
                __asm__ (
                        "vmovdqu (%0), %%ymm1 ;"
                        "vmovdqu (%1), %%ymm2 ;"
                        "vmovdqu (%2), %%ymm3 ;"
                        "vpxor %%ymm2, %%ymm3, %%ymm2 ;"
                        "vpaddb %%ymm1, %%ymm2, %%ymm1 ;"
                        "vmovdqu %%ymm1, (%0) ;"
                        : : "r" (pacc), "r" (pa), "r" (pb) : "ymm1", "ymm2", "ymm3");
            }
            repeat (k,32) cnt += ((char *)&acc)[k];
        }
        for (; i < len; ++ i) if (a[p1 + i] != b[p2 + i]) ++ cnt;
        printf("%d\n", cnt);
    }
    return 0;
}


#include <cstdio>
#include <immintrin.h>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
#define LEN_MAX 200000
char a[LEN_MAX+1];
char b[LEN_MAX+1];
int main() {
    int q; scanf("%[01] %[01]%d", a, b, &q);
    for (char *p = a; *p; ++ p) *p = (*p == '1');
    for (char *p = b; *p; ++ p) *p = (*p == '1');
    while (q --) {
        int p1, p2, len; scanf("%d%d%d", &p1, &p2, &len);
        int cnt = 0;
        int i = 0;
        for (; i < len-16; ) {
            __asm__ (
                    "pxor %%xmm1, %%xmm1 ;" :);
            for (int j = 0; j < 127 and i < len-16; ++ j, i += 16) {
                volatile char *pa = a + p1 + i;
                volatile char *pb = b + p2 + i;
                __asm__ (
                        "vmovdqu (%0), %%xmm2 ;"
                        "vmovdqu (%1), %%xmm3 ;"
                        "vpxor %%xmm2, %%xmm3, %%xmm2 ;"
                        "vpaddb %%xmm1, %%xmm2, %%xmm1 ;"
                        : : "r" (pa), "r" (pb));
            }
            volatile char acc[16];
            __asm__ (
                    "vmovdqu %%xmm1, (%0) ;"
                    : : "r" (acc));
            _mm256_setzero_si256();
            repeat (k,16) cnt += acc[k];
        }
        for (; i < len; ++ i) if (a[p1 + i] != b[p2 + i]) ++ cnt;
        printf("%d\n", cnt);
    }
    return 0;
}


#include <cstdio>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
#define LEN_MAX 200000
char a[LEN_MAX+1] __attribute__((aligned(32)));
char b[LEN_MAX+1] __attribute__((aligned(32)));
int main() {
    int q; scanf("%[01] %[01]%d", a, b, &q);
    for (char *p = a; *p; ++ p) *p = (*p == '1');
    for (char *p = b; *p; ++ p) *p = (*p == '1');
    while (q --) {
        int p1, p2, len; scanf("%d%d%d", &p1, &p2, &len);
        int cnt = 0;
        int i = 0;
        for (; i < len-16; ) {
            volatile char acc[16] = {};
            for (int j = 0; j < 127 and i < len-16; ++ j, i += 16) {
                volatile char *pa = a + p1 + i;
                volatile char *pb = b + p2 + i;
                __asm__ (
                        "vmovdqu (%0), %%xmm1 ;"
                        "vmovdqu (%1), %%xmm2 ;"
                        "vmovdqu (%2), %%xmm3 ;"
                        "vpxor %%xmm2, %%xmm3, %%xmm2 ;"
                        "vpaddb %%xmm1, %%xmm2, %%xmm1 ;"
                        "vmovdqu %%xmm1, (%0) ;"
                        : : "r" (acc), "r" (pa), "r" (pb));
            }
            repeat (k,16) cnt += acc[k];
        }
        for (; i < len; ++ i) if (a[p1 + i] != b[p2 + i]) ++ cnt;
        printf("%d\n", cnt);
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
int main() {
    string a, b; int q; cin >> a >> b >> q;
    while (q --) {
        int p1, p2, len; cin >> p1 >> p2 >> len;
        int cnt = 0;
        repeat (i,len) cnt += a[p1 + i] != b[p2 + i];
        cout << cnt << endl;
    }
    return 0;
}


#include <cstdio>
#include <immintrin.h>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
#define LEN_MAX 200000
char a[LEN_MAX+1] __attribute__((aligned(32)));
char b[LEN_MAX+1] __attribute__((aligned(32)));
int main() {
    int q; scanf("%[01] %[01]%d", a, b, &q);
    for (char *p = a; *p; ++ p) *p = (*p == '1');
    for (char *p = b; *p; ++ p) *p = (*p == '1');
    while (q --) {
        int p1, p2, len; scanf("%d%d%d", &p1, &p2, &len);
        int cnt = 0;
        int i = 0;
        for (; i < len-32; ) {
            __m256i acc = {};
            char *pacc = (char *)&acc;
            for (int j = 0; j < 127 and i < len-32; ++ j, i += 32) {
                char *pa = a + p1 + i;
                char *pb = b + p2 + i;
                __asm__ (
                        "vmovdqu (%1), %%xmm1 ;"
                        "vmovdqu (%2), %%xmm2 ;"
                        "vpxor %%xmm1, %%xmm2, %%xmm1 ;"
                        "mov %0, %%rax ;"
                        "vpaddb %%xmm4, %%xmm1, (rax) ;"
                        : : "r" (pacc), "r" (pa), "r" (pb) : "rax");
            }
            repeat (k,32) cnt += reinterpret_cast<char *>(& acc)[k];
        }
        for (; i < len; ++ i) if (a[p1 + i] != b[p2 + i]) ++ cnt;
        printf("%d\n", cnt);
    }
    return 0;
}


#pragma GCC optimize ("-O3")
#pragma GCC target ("tune=native")
#include <cstdio>
#include <x86intrin.h>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
#define LEN_MAX 200000
char a[LEN_MAX+1] __attribute__((aligned(32)));
char b[LEN_MAX+1] __attribute__((aligned(32)));
int main() {
    int q; scanf("%[01] %[01]%d", a, b, &q);
    for (char *p = a; *p; ++ p) *p = (*p == '1');
    for (char *p = b; *p; ++ p) *p = (*p == '1');
    while (q --) {
        int p1, p2, len; scanf("%d%d%d", &p1, &p2, &len);
        int cnt = 0;
        int i = 0;
        for (; i < len-32; ) {
            __m256i acc = _mm256_setzero_si256();
            for (int j = 0; j < 127 and i < len-32; ++ j, i += 32) {
                __m256i va = _mm256_loadu_si256(reinterpret_cast<__m256i *>(a + p1 + i));
                __m256i vb = _mm256_loadu_si256(reinterpret_cast<__m256i *>(b + p2 + i));
                acc += _mm256_xor_si256(va, vb);
            }
            repeat (k,32) cnt += reinterpret_cast<char *>(& acc)[k];
        }
        for (; i < len; ++ i) if (a[p1 + i] != b[p2 + i]) ++ cnt;
        printf("%d\n", cnt);
    }
    return 0;
}


#include <cstdio>
#include <immintrin.h>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
#define LEN_MAX 200000
char a[LEN_MAX+1] __attribute__((aligned(32)));
char b[LEN_MAX+1] __attribute__((aligned(32)));
int main() {
    int q; scanf("%[01] %[01]%d", a, b, &q);
    for (char *p = a; *p; ++ p) *p = (*p == '1');
    for (char *p = b; *p; ++ p) *p = (*p == '1');
    while (q --) {
        int p1, p2, len; scanf("%d%d%d", &p1, &p2, &len);
        int cnt = 0;
        int i = 0;
        for (; i < len-32; ) {
            __m256i acc; __asm__("vpxor %0, %0, %0" : "+x" (acc));
            for (int j = 0; j < 127 and i < len-32; ++ j, i += 32) {
                char *pa = a + p1 + i; __m256i va; __asm__("vmovdqu (%1), %0" : "=x" (va) : "r" (pa));
                char *pb = b + p2 + i; __m256i vb; __asm__("vmovdqu (%1), %0" : "=x" (vb) : "r" (pb));
                __m256i vc; __asm__("vpxor %1, %2, %0" : "=x" (vc) : "x" (va), "x" (vb) );
                __asm__("vpaddb %0, %1, %0" : "+x" (acc) : "x" (vc));
            }
            repeat (k,32) cnt += reinterpret_cast<char *>(& acc)[k];
        }
        for (; i < len; ++ i) if (a[p1 + i] != b[p2 + i]) ++ cnt;
        printf("%d\n", cnt);
    }
    return 0;
}


#include <cstdio>
#include <immintrin.h>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
#define LEN_MAX 200000
char a[LEN_MAX+1] __attribute__((aligned(32)));
char b[LEN_MAX+1] __attribute__((aligned(32)));
int main() {
    int q; scanf("%[01] %[01]%d", a, b, &q);
    for (char *p = a; *p; ++ p) *p = (*p == '1');
    for (char *p = b; *p; ++ p) *p = (*p == '1');
    while (q --) {
        int p1, p2, len; scanf("%d%d%d", &p1, &p2, &len);
        int cnt = 0;
        int i = 0;
        for (; i < len-32; ) {
            __m256i acc = {};
            for (int j = 0; j < 127 and i < len-32; ++ j, i += 32) {
                char *pa = a + p1 + i;
                char *pb = b + p2 + i;
                __asm__ (
                        "vmovdqu (%1), %%xmm1 ;"
                        "vmovdqu (%2), %%xmm2 ;"
                        "vpxor %%xmm1, %%xmm2, %%xmm1 ;"
                        "vpaddb %%xmm4, %%xmm1, (%0) ;"
                        : "=x" (acc) : "r" (pa), "r" (pb));
            }
            repeat (k,32) cnt += reinterpret_cast<char *>(& acc)[k];
        }
        for (; i < len; ++ i) if (a[p1 + i] != b[p2 + i]) ++ cnt;
        printf("%d\n", cnt);
    }
    return 0;
}


#include <cstdio>
#include <immintrin.h>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
#define LEN_MAX 200000
char a[LEN_MAX+1] __attribute__((aligned(32)));
char b[LEN_MAX+1] __attribute__((aligned(32)));
int main() {
    int q; scanf("%[01] %[01]%d", a, b, &q);
    for (char *p = a; *p; ++ p) *p = (*p == '1');
    for (char *p = b; *p; ++ p) *p = (*p == '1');
    while (q --) {
        int p1, p2, len; scanf("%d%d%d", &p1, &p2, &len);
        int cnt = 0;
        int i = 0;
        for (; i < len-32; ) {
            __m256i acc = {};
            char *pacc = (char *)&acc;
            for (int j = 0; j < 127 and i < len-32; ++ j, i += 32) {
                char *pa = a + p1 + i;
                char *pb = b + p2 + i;
                __asm__ (
                        "vmovdqu (%0), %%ymm1 ;"
                        "vmovdqu (%1), %%ymm2 ;"
                        "vmovdqu (%2), %%ymm3 ;"
                        "vpxor %%ymm2, %%ymm3, %%ymm2 ;"
                        "vpaddb %%ymm1, %%ymm2, %%ymm1 ;"
                        "vmovdqu %%ymm1, (%0) ;"
                        : : "r" (pacc), "r" (pa), "r" (pb) : "ymm1", "ymm2", "ymm3");
            }
            repeat (k,32) cnt += ((char *)&acc)[k];
        }
        for (; i < len; ++ i) if (a[p1 + i] != b[p2 + i]) ++ cnt;
        printf("%d\n", cnt);
    }
    return 0;
}


#include <cstdio>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
#define LEN_MAX 200000
char a[LEN_MAX+1] __attribute__((aligned(32)));
char b[LEN_MAX+1] __attribute__((aligned(32)));
int main() {
    int q; scanf("%[01] %[01]%d", a, b, &q);
    for (char *p = a; *p; ++ p) *p = (*p == '1');
    for (char *p = b; *p; ++ p) *p = (*p == '1');
    while (q --) {
        int p1, p2, len; scanf("%d%d%d", &p1, &p2, &len);
        int cnt = 0;
        int i = 0;
        for (; i < len-16; ) {
            __asm__ (
                    "pxor %%xmm1, %%xmm1 ;" :);
            for (int j = 0; j < 127 and i < len-16; ++ j, i += 16) {
                volatile char *pa = a + p1 + i;
                volatile char *pb = b + p2 + i;
                __asm__ (
                        "vmovdqu (%0), %%xmm2 ;"
                        "vmovdqu (%1), %%xmm3 ;"
                        "vpxor %%xmm2, %%xmm3, %%xmm2 ;"
                        "vpaddb %%xmm1, %%xmm2, %%xmm1 ;"
                        : : "r" (pa), "r" (pb));
            }
            volatile char acc[16];
            __asm__ (
                    "vmovdqu %%xmm1, (%0) ;"
                    : : "r" (acc));
            repeat (k,16) cnt += acc[k];
        }
        for (; i < len; ++ i) if (a[p1 + i] != b[p2 + i]) ++ cnt;
        printf("%d\n", cnt);
    }
    return 0;
}


#include <cstdio>
#include <immintrin.h>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
#define LEN_MAX 200000
char a[LEN_MAX+1] __attribute__((aligned(32)));
char b[LEN_MAX+1] __attribute__((aligned(32)));
int main() {
    int q; scanf("%[01] %[01]%d", a, b, &q);
    for (char *p = a; *p; ++ p) *p = (*p == '1');
    for (char *p = b; *p; ++ p) *p = (*p == '1');
    while (q --) {
        int p1, p2, len; scanf("%d%d%d", &p1, &p2, &len);
        int cnt = 0;
        int i = 0;
        for (; i < len-32; ) {
            __m256i acc = {};
            char *pacc = (char *)&acc;
            for (int j = 0; j < 127 and i < len-32; ++ j, i += 32) {
                char *pa = a + p1 + i;
                char *pb = b + p2 + i;
                __asm__ (
                        "vmovdqu (%1), %%ymm1 ;"
                        "vmovdqu (%2), %%ymm2 ;"
                        "vpxor %%ymm1, %%ymm2, %%ymm1 ;"
                        "mov %0, %%rax ;"
                        "vpaddb %%ymm4, %%ymm1, (%%rax) ;"
                        : : "r" (pacc), "r" (pa), "r" (pb) : "rax");
            }
            repeat (k,32) cnt += reinterpret_cast<char *>(& acc)[k];
        }
        for (; i < len; ++ i) if (a[p1 + i] != b[p2 + i]) ++ cnt;
        printf("%d\n", cnt);
    }
    return 0;
}


#pragma GCC optimize ("-O3")
#pragma GCC target ("tune=native")
#include <iostream>
#include <bitset>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
#define LEN_MAX 200000
int main() {
    string a, b; int q; cin >> a >> b >> q;
    bitset<LEN_MAX> va, vb;
    repeat (i, a.length()) if (a[i] == '1') va.set(i);
    repeat (i, b.length()) if (b[i] == '1') vb.set(i);
    bitset<LEN_MAX> mask = (~ bitset<LEN_MAX>());
    while (q --) {
        int p1, p2, len; cin >> p1 >> p2 >> len;
        int cnt = (((va >> p1) ^ (vb >> p2)) & (mask >> (LEN_MAX - len))).count();
        cout << cnt << endl;
    }
    return 0;
}


#include <cstdio>
#include <immintrin.h>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
#define LEN_MAX 200000
char a[LEN_MAX+1] __attribute__((aligned(32)));
char b[LEN_MAX+1] __attribute__((aligned(32)));
int main() {
    int q; scanf("%[01] %[01]%d", a, b, &q);
    for (char *p = a; *p; ++ p) *p = (*p == '1');
    for (char *p = b; *p; ++ p) *p = (*p == '1');
    while (q --) {
        int p1, p2, len; scanf("%d%d%d", &p1, &p2, &len);
        int cnt = 0;
        int i = 0;
        for (; i < len-32; ) {
            __m256i acc = {};
            char *pacc = (char *)&acc;
            for (int j = 0; j < 127 and i < len-32; ++ j, i += 32) {
                char *pa = a + p1 + i;
                char *pb = b + p2 + i;
                __asm__ (
                        "vmovdqu (%0), %%ymm1 ;"
                        "vmovdqu (%1), %%ymm2 ;"
                        "vmovdqu (%2), %%ymm3 ;"
                        "vpxor %%ymm2, %%ymm3, %%ymm2 ;"
                        "vpaddb %%ymm1, %%ymm2, %%ymm1 ;"
                        "vmovdqu %%ymm1, (%0) ;"
                        : : "r" (pacc), "r" (pa), "r" (pb));
            }
            repeat (k,32) cnt += reinterpret_cast<char *>(& acc)[k];
        }
        for (; i < len; ++ i) if (a[p1 + i] != b[p2 + i]) ++ cnt;
        printf("%d\n", cnt);
    }
    return 0;
}


#include <cstdio>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
#define LEN_MAX 200000
char a[LEN_MAX+1] __attribute__((aligned(32)));
char b[LEN_MAX+1] __attribute__((aligned(32)));
int main() {
    int q; scanf("%[01] %[01]%d", a, b, &q);
    for (char *p = a; *p; ++ p) *p = (*p == '1');
    for (char *p = b; *p; ++ p) *p = (*p == '1');
    while (q --) {
        int p1, p2, len; scanf("%d%d%d", &p1, &p2, &len);
        int cnt = 0;
        int i = 0;
        for (; i < len-32; ) {
            volatile char acc[256] = {};
            for (int j = 0; j < 127 and i < len-32; ++ j, i += 32) {
                char *pa = a + p1 + i;
                char *pb = b + p2 + i;
                __asm__ (
                        "vmovdqu (%0), %%ymm1 ;"
                        "vmovdqu (%1), %%ymm2 ;"
                        "vmovdqu (%2), %%ymm3 ;"
                        "vpxor %%ymm2, %%ymm3, %%ymm2 ;"
                        "vpaddb %%ymm1, %%ymm2, %%ymm1 ;"
                        "vmovdqu %%ymm1, (%0) ;"
                        : : "r" (acc), "r" (pa), "r" (pb));
            }
            repeat (k,32) cnt += acc[k];
        }
        for (; i < len; ++ i) if (a[p1 + i] != b[p2 + i]) ++ cnt;
        printf("%d\n", cnt);
    }
    return 0;
}


#include <cstdio>
#include <immintrin.h>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
#define LEN_MAX 200000
char a[LEN_MAX+1] __attribute__((aligned(32)));
char b[LEN_MAX+1] __attribute__((aligned(32)));
int main() {
    int q; scanf("%[01] %[01]%d", a, b, &q);
    for (char *p = a; *p; ++ p) *p = (*p == '1');
    for (char *p = b; *p; ++ p) *p = (*p == '1');
    while (q --) {
        int p1, p2, len; scanf("%d%d%d", &p1, &p2, &len);
        int cnt = 0;
        int i = 0;
        for (; i < len-32; ) {
            __m256i acc = {};
            char *pacc = &acc;
            for (int j = 0; j < 127 and i < len-32; ++ j, i += 32) {
                char *pa = a + p1 + i;
                char *pb = b + p2 + i;
                __asm__ (
                        "vmovdqu (%1), %%xmm1 ;"
                        "vmovdqu (%2), %%xmm2 ;"
                        "vpxor %%xmm1, %%xmm2, %%xmm1 ;"
                        "mov %0, rax ;"
                        "vpaddb %%xmm4, %%xmm1, (rax) ;"
                        : "r" (pacc) : "r" (pa), "r" (pb) : "rax");
            }
            repeat (k,32) cnt += reinterpret_cast<char *>(& acc)[k];
        }
        for (; i < len; ++ i) if (a[p1 + i] != b[p2 + i]) ++ cnt;
        printf("%d\n", cnt);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const unsigned N=2e5;
unsigned a[32][N+31>>5];
unsigned b[32][N+31>>5];
char s[N+1];
static int pc(unsigned n){
    int c;
    __asm__("popcnt %0, %1" : "=r"(c) : "r"(n));
    return c;
}
unsigned get(unsigned p,unsigned q,unsigned len){
	unsigned x=p>>5, y=q>>5, c=0;
	p&=31; q&=31;
	while(len>=32){
		c+=pc(a[p][x]^b[q][y]);
		++x, ++y;
		len-=32;
	}
	c+=pc((a[p][x]^b[q][y])&((1u<<len)-1));
	return c;
}
int main(){
	int n, m, q, p1, p2, len;
	scanf("%s",s); n=strlen(s);
	for(int i=0;i<32;++i){
    	for(int j=0;i+j<n;++j){
      		if(s[i+j]=='1')
				a[i][j>>5]|=(1<<(j&31));
   		}
  	}
	scanf("%s",s); m=strlen(s);
	for(int i=0;i<32;++i)
    	for(int j=0;i+j<m;++j)
      		if(s[i+j]=='1')
				b[i][j>>5]|=(1<<(j&31));

	scanf("%d",&q);
	while(q--){
		scanf("%d %d %d",&p1,&p2,&len);
		printf("%d\n",get(p1,p2,len));
	}
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <fstream>

using namespace std;

#define LL long long
#define ull unsigned long long
#define N 301000
#define M 4000100
#define MP make_pair
#define Pi acos(-1.0)
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define ls (rt << 1)
#define rs (ls | 1)
#define md ((ll+rr)/2)
#define lson ls, ll, md
#define rson rs, md+1, rr
#define mod 1000000007
#define inf 0x3f3f3f3f
const LL INF = 1LL<<62;
#define sqr(x) ((x)*(x))
#define eps 1e-9
#define uLL unsidisned londis londis
#define ui unsidisned int
LL powmod(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
#define F(x) ((x)/3+((x)%3 == 1 ? 0 : tb))
#define dis(x) ((x)<tb ? (x)*3+1 : ((x) - tb)*3+2)
#define lowbit(x) ((x)&(-x))
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<LL,int>
#define pll pair<LL,LL>
#define PB push_back
#define mp make_pair
#define SZ(x) x.size()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int pos[N];

namespace FFT {
    struct comp {
        double r , i ;
        comp ( double _r = 0 , double _i = 0 ) : r ( _r ) , i ( _i ) {}
        comp operator + ( const comp& x ) {
            return comp ( r + x.r , i + x.i ) ;
        }
        comp operator - ( const comp& x ) {
            return comp ( r - x.r , i - x.i ) ;
        }
        comp operator * ( const comp& x ) {
            return comp ( r * x.r - i * x.i , i * x.r + r * x.i ) ;
        }
        comp conj () {
            return comp ( r , -i ) ;
        }
    } A[N] , B[N] ;

    const double pi = acos ( -1.0 ) ;
    void FFT ( comp a[] , int n , int t ) {
        for ( int i = 1 ; i < n ; ++ i ) if ( pos[i] > i ) swap ( a[i] , a[pos[i]] ) ;
        for ( int d = 0 ; ( 1 << d ) < n ; ++ d ) {
            int m = 1 << d , m2 = m << 1 ;
            double o = pi * 2 / m2 * t ;
            comp _w ( cos ( o ) , sin ( o ) ) ;
            for ( int i = 0 ; i < n ; i += m2 ) {
                comp w ( 1 , 0 ) ;
                for ( int j = 0 ; j < m ; ++ j ) {
                    comp& A = a[i + j + m] , &B = a[i + j] , t = w * A ;
                    A = B - t ;
                    B = B + t ;
                    w = w * _w ;
                }
            }
        }
        if ( t == -1 ) for ( int i = 0 ; i < n ; ++ i ) a[i].r /= n ;
    }
    void mul ( int *a , int *b , int *c ,int k) {
        int i , j ;
        for ( i = 0 ; i < k ; ++ i ) A[i] = comp ( a[i] , b[i] ) ;
        j = __builtin_ctz ( k ) - 1 ;
        for ( int i = 0 ; i < k ; ++ i ) {
            pos[i] = pos[i >> 1] >> 1 | ( ( i & 1 ) << j ) ;
        }
        FFT ( A , k , 1 ) ;
        for ( int i = 0 ; i < k ; ++ i ) {
            j = ( k - i ) & ( k - 1 ) ;
            B[i] = ( A[i] * A[i] - ( A[j] * A[j] ).conj () ) * comp ( 0 , -0.25 ) ;
        }
        FFT ( B , k , -1 ) ;
        for ( int i = 0 ; i < k ; ++ i ) {
            if(B[i].r>=0)
                c[i] = ( int ) ( B[i].r + 0.5 )  ;
            else c[i]=(int)(B[i].r-0.5);
        }
    }
}

int belong[N];
int r[450], l[450];
short x[450][N];
char a[N], b[N];
int x1[N << 1], x2[N << 1], x3[N << 1];

int main()
{
    scanf("%s %s", a, b);
    int m = read();
    int tot = 0, n = strlen(a), nn = strlen(b);

    int blo = pow(n, 2.0/3);
    for(int i = 0; i < n; i++)
    {
        int rr = i;
        ++tot;
        l[tot] = i;
        while(rr < n && rr - i <= blo)
        {
            belong[rr] = tot;
            rr++;
        }
        r[tot] = rr - 1;
        i = rr - 1;
    }

    for(int i = 1; i <= tot; i++)
    {
        int ii = r[i] - l[i] + 1;
        int len = 1;
        while(len <= nn) len *= 2;
        for(int j = 0; j < len; j++)
        {
            if(l[i] + j <= r[i])
            {
                if(a[l[i] + j] == '1') x1[j] = 1;
                else x1[j] = -1;
            }
            else x1[j] = 0;
            if(j < nn)
            {
                if(b[j] == '1') x2[j] = 1;
                else x2[j] = -1;
            }
            else x2[j] = 0;
        }

        FFT::mul(x1, x2, x3, len);
        for(int j = ii - 1; j < nn; j++)
        {
            x[i][j] = (ii - x3[j]) / 2;
        }
    }

    for(int i = 0; i < m; i++)
    {
        int s1 = read(), s2 = read(), len = read();
        int ans = 0;
        int ll = belong[s1];
        int rr = belong[s1 + len - 1];

        if(ll + 1 >= rr)
        {
            for(int j = s1; j < s1 + len; j++)
                if(a[j] != b[j - s1 + s2]) ans++;
        }
        else
        {
            for(int j = s1; j <= r[ll]; j++)
                if(a[j] != b[j - s1 + s2]) ans++;

            for(int j = ll + 1; j < rr; j++)
            {
                ans += x[j][nn - (l[i] - s1 + s2) - 1];
            }

            for(int j = l[rr]; j < s1 + len; j++)
                if(a[j] != b[j - s1 + s2]) ans++;
        }

        printf("%d\n",ans);
    }

    return 0;

}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <fstream>

using namespace std;

#define LL long long
#define ull unsigned long long
#define N 201000
#define M 4000100
#define MP make_pair
#define Pi acos(-1.0)
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define ls (rt << 1)
#define rs (ls | 1)
#define md ((ll+rr)/2)
#define lson ls, ll, md
#define rson rs, md+1, rr
#define mod 1000000007
#define inf 0x3f3f3f3f
const LL INF = 1LL<<62;
#define sqr(x) ((x)*(x))
#define eps 1e-9
#define uLL unsidisned londis londis
#define ui unsidisned int
LL powmod(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
#define F(x) ((x)/3+((x)%3 == 1 ? 0 : tb))
#define dis(x) ((x)<tb ? (x)*3+1 : ((x) - tb)*3+2)
#define lowbit(x) ((x)&(-x))
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<LL,int>
#define pll pair<LL,LL>
#define PB push_back
#define mp make_pair
#define SZ(x) x.size()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int pos[N];

namespace FFT {
    struct comp {
        double r , i ;
        comp ( double _r = 0 , double _i = 0 ) : r ( _r ) , i ( _i ) {}
        comp operator + ( const comp& x ) {
            return comp ( r + x.r , i + x.i ) ;
        }
        comp operator - ( const comp& x ) {
            return comp ( r - x.r , i - x.i ) ;
        }
        comp operator * ( const comp& x ) {
            return comp ( r * x.r - i * x.i , i * x.r + r * x.i ) ;
        }
        comp conj () {
            return comp ( r , -i ) ;
        }
    } A[N] , B[N] ;

    const double pi = acos ( -1.0 ) ;
    void FFT ( comp a[] , int n , int t ) {
        for ( int i = 1 ; i < n ; ++ i ) if ( pos[i] > i ) swap ( a[i] , a[pos[i]] ) ;
        for ( int d = 0 ; ( 1 << d ) < n ; ++ d ) {
            int m = 1 << d , m2 = m << 1 ;
            double o = pi * 2 / m2 * t ;
            comp _w ( cos ( o ) , sin ( o ) ) ;
            for ( int i = 0 ; i < n ; i += m2 ) {
                comp w ( 1 , 0 ) ;
                for ( int j = 0 ; j < m ; ++ j ) {
                    comp& A = a[i + j + m] , &B = a[i + j] , t = w * A ;
                    A = B - t ;
                    B = B + t ;
                    w = w * _w ;
                }
            }
        }
        if ( t == -1 ) for ( int i = 0 ; i < n ; ++ i ) a[i].r /= n ;
    }
    void mul ( int *a , int *b , int *c ,int k) {
        int i , j ;
        for ( i = 0 ; i < k ; ++ i ) A[i] = comp ( a[i] , b[i] ) ;
        j = __builtin_ctz ( k ) - 1 ;
        for ( int i = 0 ; i < k ; ++ i ) {
            pos[i] = pos[i >> 1] >> 1 | ( ( i & 1 ) << j ) ;
        }
        FFT ( A , k , 1 ) ;
        for ( int i = 0 ; i < k ; ++ i ) {
            j = ( k - i ) & ( k - 1 ) ;
            B[i] = ( A[i] * A[i] - ( A[j] * A[j] ).conj () ) * comp ( 0 , -0.25 ) ;
        }
        FFT ( B , k , -1 ) ;
        for ( int i = 0 ; i < k ; ++ i ) {
            if(B[i].r>=0)
                c[i] = ( int ) ( B[i].r + 0.5 )  ;
            else c[i]=(int)(B[i].r-0.5);
        }
    }
}

int belong[N];
int r[450], l[450];
int x[450][N];
char a[N], b[N];
int x1[N << 1], x2[N << 1], x3[N << 1];

int main()
{
    scanf("%s %s", a, b);
    int m = read();
    int tot = 0, n = strlen(a), nn = strlen(b);

    int blo = pow(n, 2.0/3);
    for(int i = 0; i < n; i++)
    {
        int rr = i;
        ++tot;
        l[tot] = i;
        while(rr < n && rr - i <= blo)
        {
            belong[rr] = tot;
            rr++;
        }
        r[tot] = rr - 1;
        i = rr - 1;
    }

    for(int i = 1; i <= tot; i++)
    {
        int ii = r[i] - l[i] + 1;
        int len = 1;
        while(len <= nn) len *= 2;
        for(int j = 0; j < len; j++)
        {
            if(l[i] + j <= r[i])
            {
                if(a[l[i] + j] == '1') x1[j] = 1;
                else x1[j] = -1;
            }
            else x1[j] = 0;
            if(j < nn)
            {
                if(b[j] == '1') x2[j] = 1;
                else x2[j] = -1;
            }
            else x2[j] = 0;
        }

        FFT::mul(x1, x2, x3, len);
        for(int j = ii - 1; j < nn; j++)
        {
            x[i][j] = (ii - x3[j]) / 2;
        }
    }

    for(int i = 0; i < m; i++)
    {
        int s1 = read(), s2 = read(), len = read();
        int ans = 0;
        int ll = belong[s1];
        int rr = belong[s1 + len - 1];

        if(ll + 1 >= rr)
        {
            for(int j = s1; j < s1 + len; j++)
                if(a[j] != b[j - s1 + s2]) ans++;
        }
        else
        {
            for(int j = s1; j <= r[ll]; j++)
                if(a[j] != b[j - s1 + s2]) ans++;

            for(int j = ll + 1; j < rr; j++)
            {
                ans += x[j][nn - (l[i] - s1 + s2) - 1];
            }

            for(int j = l[rr]; j < s1 + len; j++)
                if(a[j] != b[j - s1 + s2]) ans++;
        }

        printf("%d\n",ans);
    }

    return 0;

}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <fstream>

using namespace std;

#define LL long long
#define ull unsigned long long
#define N 201000
#define M 4000100
#define MP make_pair
#define Pi acos(-1.0)
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define ls (rt << 1)
#define rs (ls | 1)
#define md ((ll+rr)/2)
#define lson ls, ll, md
#define rson rs, md+1, rr
#define mod 1000000007
#define inf 0x3f3f3f3f
const LL INF = 1LL<<62;
#define sqr(x) ((x)*(x))
#define eps 1e-9
#define uLL unsidisned londis londis
#define ui unsidisned int
LL powmod(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
#define F(x) ((x)/3+((x)%3 == 1 ? 0 : tb))
#define dis(x) ((x)<tb ? (x)*3+1 : ((x) - tb)*3+2)
#define lowbit(x) ((x)&(-x))
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<LL,int>
#define pll pair<LL,LL>
#define PB push_back
#define mp make_pair
#define SZ(x) x.size()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int pos[M];

namespace FFT {
    struct comp {
        double r , i ;
        comp ( double _r = 0 , double _i = 0 ) : r ( _r ) , i ( _i ) {}
        comp operator + ( const comp& x ) {
            return comp ( r + x.r , i + x.i ) ;
        }
        comp operator - ( const comp& x ) {
            return comp ( r - x.r , i - x.i ) ;
        }
        comp operator * ( const comp& x ) {
            return comp ( r * x.r - i * x.i , i * x.r + r * x.i ) ;
        }
        comp conj () {
            return comp ( r , -i ) ;
        }
    } A[N] , B[N] ;

    const double pi = acos ( -1.0 ) ;
    void FFT ( comp a[] , int n , int t ) {
        for ( int i = 1 ; i < n ; ++ i ) if ( pos[i] > i ) swap ( a[i] , a[pos[i]] ) ;
        for ( int d = 0 ; ( 1 << d ) < n ; ++ d ) {
            int m = 1 << d , m2 = m << 1 ;
            double o = pi * 2 / m2 * t ;
            comp _w ( cos ( o ) , sin ( o ) ) ;
            for ( int i = 0 ; i < n ; i += m2 ) {
                comp w ( 1 , 0 ) ;
                for ( int j = 0 ; j < m ; ++ j ) {
                    comp& A = a[i + j + m] , &B = a[i + j] , t = w * A ;
                    A = B - t ;
                    B = B + t ;
                    w = w * _w ;
                }
            }
        }
        if ( t == -1 ) for ( int i = 0 ; i < n ; ++ i ) a[i].r /= n ;
    }
    void mul ( int *a , int *b , int *c ,int k) {
        int i , j ;
        for ( i = 0 ; i < k ; ++ i ) A[i] = comp ( a[i] , b[i] ) ;
        j = __builtin_ctz ( k ) - 1 ;
        for ( int i = 0 ; i < k ; ++ i ) {
            pos[i] = pos[i >> 1] >> 1 | ( ( i & 1 ) << j ) ;
        }
        FFT ( A , k , 1 ) ;
        for ( int i = 0 ; i < k ; ++ i ) {
            j = ( k - i ) & ( k - 1 ) ;
            B[i] = ( A[i] * A[i] - ( A[j] * A[j] ).conj () ) * comp ( 0 , -0.25 ) ;
        }
        FFT ( B , k , -1 ) ;
        for ( int i = 0 ; i < k ; ++ i ) {
            if(B[i].r>=0)
                c[i] = ( int ) ( B[i].r + 0.5 )  ;
            else c[i]=(int)(B[i].r-0.5);
        }
    }
}

int belong[N];
int r[450], l[450];
short x[450][N];
char a[N], b[N];
int x1[N << 1], x2[N << 1], x3[N << 1];

int main()
{
    scanf("%s %s", a, b);
    int m = read();
    int tot = 0, n = strlen(a), nn = strlen(b);

    int blo = pow(n, 2.0/3);
    for(int i = 0; i < n; i++)
    {
        int rr = i;
        ++tot;
        l[tot] = i;
        while(rr < n && rr - i <= blo)
        {
            belong[rr] = tot;
            rr++;
        }
        r[tot] = rr - 1;
        i = rr - 1;
    }

    for(int i = 1; i <= tot; i++)
    {
        int ii = r[i] - l[i] + 1;
        int len = 1;
        while(len <= nn) len *= 2;
        for(int j = 0; j < len; j++)
        {
            if(l[i] + j <= r[i])
            {
                if(a[l[i] + j] == '1') x1[j] = 1;
                else x1[j] = -1;
            }
            else x1[j] = 0;
            if(j < nn)
            {
                if(b[j] == '1') x2[j] = 1;
                else x2[j] = -1;
            }
            else x2[j] = 0;
        }

        FFT::mul(x1, x2, x3, len);
        for(int j = ii - 1; j < nn; j++)
        {
            x[i][j] = (ii - x3[j]) / 2;
        }
    }

    for(int i = 0; i < m; i++)
    {
        int s1 = read(), s2 = read(), len = read();
        int ans = 0;
        int ll = belong[s1];
        int rr = belong[s1 + len - 1];

        if(ll + 1 >= rr)
        {
            for(int j = s1; j < s1 + len; j++)
                if(a[j] != b[j - s1 + s2]) ans++;
        }
        else
        {
            for(int j = s1; j <= r[ll]; j++)
                if(a[j] != b[j - s1 + s2]) ans++;

            for(int j = ll + 1; j < rr; j++)
            {
                ans += x[j][nn - (l[i] - s1 + s2) - 1];
            }

            for(int j = l[rr]; j < s1 + len; j++)
                if(a[j] != b[j - s1 + s2]) ans++;
        }

        printf("%d\n",ans);
    }

    return 0;

}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <fstream>

using namespace std;

#define LL long long
#define ull unsigned long long
#define N 201000
#define M 4000100
#define MP make_pair
#define Pi acos(-1.0)
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define ls (rt << 1)
#define rs (ls | 1)
#define md ((ll+rr)/2)
#define lson ls, ll, md
#define rson rs, md+1, rr
#define mod 1000000007
#define inf 0x3f3f3f3f
const LL INF = 1LL<<62;
#define sqr(x) ((x)*(x))
#define eps 1e-9
#define uLL unsidisned londis londis
#define ui unsidisned int
LL powmod(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
#define F(x) ((x)/3+((x)%3 == 1 ? 0 : tb))
#define dis(x) ((x)<tb ? (x)*3+1 : ((x) - tb)*3+2)
#define lowbit(x) ((x)&(-x))
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<LL,int>
#define pll pair<LL,LL>
#define PB push_back
#define mp make_pair
#define SZ(x) x.size()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int pos[M];

namespace FFT {
    struct comp {
        double r , i ;
        comp ( double _r = 0 , double _i = 0 ) : r ( _r ) , i ( _i ) {}
        comp operator + ( const comp& x ) {
            return comp ( r + x.r , i + x.i ) ;
        }
        comp operator - ( const comp& x ) {
            return comp ( r - x.r , i - x.i ) ;
        }
        comp operator * ( const comp& x ) {
            return comp ( r * x.r - i * x.i , i * x.r + r * x.i ) ;
        }
        comp conj () {
            return comp ( r , -i ) ;
        }
    } A[M] , B[M] ;

    const double pi = acos ( -1.0 ) ;
    void FFT ( comp a[] , int n , int t ) {
        for ( int i = 1 ; i < n ; ++ i ) if ( pos[i] > i ) swap ( a[i] , a[pos[i]] ) ;
        for ( int d = 0 ; ( 1 << d ) < n ; ++ d ) {
            int m = 1 << d , m2 = m << 1 ;
            double o = pi * 2 / m2 * t ;
            comp _w ( cos ( o ) , sin ( o ) ) ;
            for ( int i = 0 ; i < n ; i += m2 ) {
                comp w ( 1 , 0 ) ;
                for ( int j = 0 ; j < m ; ++ j ) {
                    comp& A = a[i + j + m] , &B = a[i + j] , t = w * A ;
                    A = B - t ;
                    B = B + t ;
                    w = w * _w ;
                }
            }
        }
        if ( t == -1 ) for ( int i = 0 ; i < n ; ++ i ) a[i].r /= n ;
    }
    void mul ( int *a , int *b , int *c ,int k) {
        int i , j ;
        for ( i = 0 ; i < k ; ++ i ) A[i] = comp ( a[i] , b[i] ) ;
        j = __builtin_ctz ( k ) - 1 ;
        for ( int i = 0 ; i < k ; ++ i ) {
            pos[i] = pos[i >> 1] >> 1 | ( ( i & 1 ) << j ) ;
        }
        FFT ( A , k , 1 ) ;
        for ( int i = 0 ; i < k ; ++ i ) {
            j = ( k - i ) & ( k - 1 ) ;
            B[i] = ( A[i] * A[i] - ( A[j] * A[j] ).conj () ) * comp ( 0 , -0.25 ) ;
        }
        FFT ( B , k , -1 ) ;
        for ( int i = 0 ; i < k ; ++ i ) {
            if(B[i].r>=0)
                c[i] = ( int ) ( B[i].r + 0.5 )  ;
            else c[i]=(int)(B[i].r-0.5);
        }
    }
}

int belong[N];
int r[450], l[450];
short x[450][N];
char a[N], b[N];
int x1[N << 1], x2[N << 1], x3[N << 1];

int main()
{
    scanf("%s %s", a, b);
    int m = read();
    int tot = 0, n = strlen(a), nn = strlen(b);

    int blo = pow(n, 2.0/3);
    for(int i = 0; i < n; i++)
    {
        int rr = i;
        ++tot;
        l[tot] = i;
        while(rr < n && rr - i <= blo)
        {
            belong[rr] = tot;
            rr++;
        }
        r[tot] = rr - 1;
        i = rr - 1;
    }

    for(int i = 1; i <= tot; i++)
    {
        int ii = r[i] - l[i] + 1;
        int len = 1;
        while(len <= nn) len *= 2;
        for(int j = 0; j < len; j++)
        {
            if(l[i] + j <= r[i])
            {
                if(a[l[i] + j] == '1') x1[j] = 1;
                else x1[j] = -1;
            }
            else x1[j] = 0;
            if(j < nn)
            {
                if(b[j] == '1') x2[j] = 1;
                else x2[j] = -1;
            }
            else x2[j] = 0;
        }

        FFT::mul(x1, x2, x3, len);
        for(int j = ii - 1; j < nn; j++)
        {
            x[i][j] = (ii - x3[j]) / 2;
        }
    }

    for(int i = 0; i < m; i++)
    {
        int s1 = read(), s2 = read(), len = read();
        int ans = 0;
        int ll = belong[s1];
        int rr = belong[s1 + len - 1];

        if(ll + 1 >= rr)
        {
            for(int j = s1; j < s1 + len; j++)
                if(a[j] != b[j - s1 + s2]) ans++;
        }
        else
        {
            for(int j = s1; j <= r[ll]; j++)
                if(a[j] != b[j - s1 + s2]) ans++;

            for(int j = ll + 1; j < rr; j++)
            {
                ans += x[j][nn - (l[i] - s1 + s2) - 1];
            }

            for(int j = l[rr]; j < s1 + len; j++)
                if(a[j] != b[j - s1 + s2]) ans++;
        }

        printf("%d\n",ans);
    }

    return 0;

}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <fstream>

using namespace std;

#define LL long long
#define ull unsigned long long
#define N 201000
#define M 4000100
#define MP make_pair
#define Pi acos(-1.0)
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define ls (rt << 1)
#define rs (ls | 1)
#define md ((ll+rr)/2)
#define lson ls, ll, md
#define rson rs, md+1, rr
#define mod 1000000007
#define inf 0x3f3f3f3f
const LL INF = 1LL<<62;
#define sqr(x) ((x)*(x))
#define eps 1e-9
#define uLL unsidisned londis londis
#define ui unsidisned int
LL powmod(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
#define F(x) ((x)/3+((x)%3 == 1 ? 0 : tb))
#define dis(x) ((x)<tb ? (x)*3+1 : ((x) - tb)*3+2)
#define lowbit(x) ((x)&(-x))
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<LL,int>
#define pll pair<LL,LL>
#define PB push_back
#define mp make_pair
#define SZ(x) x.size()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int pos[N];

namespace FFT {
    struct comp {
        double r , i ;
        comp ( double _r = 0 , double _i = 0 ) : r ( _r ) , i ( _i ) {}
        comp operator + ( const comp& x ) {
            return comp ( r + x.r , i + x.i ) ;
        }
        comp operator - ( const comp& x ) {
            return comp ( r - x.r , i - x.i ) ;
        }
        comp operator * ( const comp& x ) {
            return comp ( r * x.r - i * x.i , i * x.r + r * x.i ) ;
        }
        comp conj () {
            return comp ( r , -i ) ;
        }
    } A[N] , B[N] ;

    const double pi = acos ( -1.0 ) ;
    void FFT ( comp a[] , int n , int t ) {
        for ( int i = 1 ; i < n ; ++ i ) if ( pos[i] > i ) swap ( a[i] , a[pos[i]] ) ;
        for ( int d = 0 ; ( 1 << d ) < n ; ++ d ) {
            int m = 1 << d , m2 = m << 1 ;
            double o = pi * 2 / m2 * t ;
            comp _w ( cos ( o ) , sin ( o ) ) ;
            for ( int i = 0 ; i < n ; i += m2 ) {
                comp w ( 1 , 0 ) ;
                for ( int j = 0 ; j < m ; ++ j ) {
                    comp& A = a[i + j + m] , &B = a[i + j] , t = w * A ;
                    A = B - t ;
                    B = B + t ;
                    w = w * _w ;
                }
            }
        }
        if ( t == -1 ) for ( int i = 0 ; i < n ; ++ i ) a[i].r /= n ;
    }
    void mul ( int *a , int *b , int *c ,int k) {
        int i , j ;
        for ( i = 0 ; i < k ; ++ i ) A[i] = comp ( a[i] , b[i] ) ;
        j = __builtin_ctz ( k ) - 1 ;
        for ( int i = 0 ; i < k ; ++ i ) {
            pos[i] = pos[i >> 1] >> 1 | ( ( i & 1 ) << j ) ;
        }
        FFT ( A , k , 1 ) ;
        for ( int i = 0 ; i < k ; ++ i ) {
            j = ( k - i ) & ( k - 1 ) ;
            B[i] = ( A[i] * A[i] - ( A[j] * A[j] ).conj () ) * comp ( 0 , -0.25 ) ;
        }
        FFT ( B , k , -1 ) ;
        for ( int i = 0 ; i < k ; ++ i ) {
            if(B[i].r>=0)
                c[i] = ( int ) ( B[i].r + 0.5 )  ;
            else c[i]=(int)(B[i].r-0.5);
        }
    }
}

int belong[N];
int r[450], l[450];
short x[450][N];
char a[N], b[N];
int x1[N << 1], x2[N << 1], x3[N << 1];

int main()
{
    scanf("%s %s", a, b);
    int m = read();
    int tot = 0, n = strlen(a), nn = strlen(b);

    int blo = pow(n, 2.0/3);
    for(int i = 0; i < n; i++)
    {
        int rr = i;
        ++tot;
        l[tot] = i;
        while(rr < n && rr - i <= blo)
        {
            belong[rr] = tot;
            rr++;
        }
        r[tot] = rr - 1;
        i = rr - 1;
    }

    for(int i = 1; i <= tot; i++)
    {
        int ii = r[i] - l[i] + 1;
        int len = 1;
        while(len <= nn) len *= 2;
        for(int j = 0; j < len; j++)
        {
            if(l[i] + j <= r[i])
            {
                if(a[l[i] + j] == '1') x1[j] = 1;
                else x1[j] = -1;
            }
            else x1[j] = 0;
            if(j < nn)
            {
                if(b[j] == '1') x2[j] = 1;
                else x2[j] = -1;
            }
            else x2[j] = 0;
        }

        FFT::mul(x1, x2, x3, len);
        for(int j = ii - 1; j < nn; j++)
        {
            x[i][j] = (ii - x3[j]) / 2;
        }
    }

    for(int i = 0; i < m; i++)
    {
        int s1 = read(), s2 = read(), len = read();
        int ans = 0;
        int ll = belong[s1];
        int rr = belong[s1 + len - 1];

        if(ll + 1 >= rr)
        {
            for(int j = s1; j < s1 + len; j++)
                if(a[j] != b[j - s1 + s2]) ans++;
        }
        else
        {
            for(int j = s1; j <= r[ll]; j++)
                if(a[j] != b[j - s1 + s2]) ans++;

            for(int j = ll + 1; j < rr; j++)
            {
                ans += x[j][nn - (l[i] - s1 + s2) - 1];
            }

            for(int j = l[rr]; j < s1 + len; j++)
                if(a[j] != b[j - s1 + s2]) ans++;
        }

        printf("%d\n",ans);
    }

    return 0;

}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <fstream>

using namespace std;

#define LL long long
#define ull unsigned long long
#define N 201000
#define M 500100
#define MP make_pair
#define Pi acos(-1.0)
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define ls (rt << 1)
#define rs (ls | 1)
#define md ((ll+rr)/2)
#define lson ls, ll, md
#define rson rs, md+1, rr
#define mod 1000000007
#define inf 0x3f3f3f3f
const LL INF = 1LL<<62;
#define sqr(x) ((x)*(x))
#define eps 1e-9
#define uLL unsidisned londis londis
#define ui unsidisned int
LL powmod(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
#define F(x) ((x)/3+((x)%3 == 1 ? 0 : tb))
#define dis(x) ((x)<tb ? (x)*3+1 : ((x) - tb)*3+2)
#define lowbit(x) ((x)&(-x))
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<LL,int>
#define pll pair<LL,LL>
#define PB push_back
#define mp make_pair
#define SZ(x) x.size()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int pos[M];

namespace FFT {
    struct comp {
        double r , i ;
        comp ( double _r = 0 , double _i = 0 ) : r ( _r ) , i ( _i ) {}
        comp operator + ( const comp& x ) {
            return comp ( r + x.r , i + x.i ) ;
        }
        comp operator - ( const comp& x ) {
            return comp ( r - x.r , i - x.i ) ;
        }
        comp operator * ( const comp& x ) {
            return comp ( r * x.r - i * x.i , i * x.r + r * x.i ) ;
        }
        comp conj () {
            return comp ( r , -i ) ;
        }
    } A[M] , B[M] ;

    const double pi = acos ( -1.0 ) ;
    void FFT ( comp a[] , int n , int t ) {
        for ( int i = 1 ; i < n ; ++ i ) if ( pos[i] > i ) swap ( a[i] , a[pos[i]] ) ;
        for ( int d = 0 ; ( 1 << d ) < n ; ++ d ) {
            int m = 1 << d , m2 = m << 1 ;
            double o = pi * 2 / m2 * t ;
            comp _w ( cos ( o ) , sin ( o ) ) ;
            for ( int i = 0 ; i < n ; i += m2 ) {
                comp w ( 1 , 0 ) ;
                for ( int j = 0 ; j < m ; ++ j ) {
                    comp& A = a[i + j + m] , &B = a[i + j] , t = w * A ;
                    A = B - t ;
                    B = B + t ;
                    w = w * _w ;
                }
            }
        }
        if ( t == -1 ) for ( int i = 0 ; i < n ; ++ i ) a[i].r /= n ;
    }
    void mul ( int *a , int *b , int *c ,int k) {
        int i , j ;
        for ( i = 0 ; i < k ; ++ i ) A[i] = comp ( a[i] , b[i] ) ;
        j = __builtin_ctz ( k ) - 1 ;
        for ( int i = 0 ; i < k ; ++ i ) {
            pos[i] = pos[i >> 1] >> 1 | ( ( i & 1 ) << j ) ;
        }
        FFT ( A , k , 1 ) ;
        for ( int i = 0 ; i < k ; ++ i ) {
            j = ( k - i ) & ( k - 1 ) ;
            B[i] = ( A[i] * A[i] - ( A[j] * A[j] ).conj () ) * comp ( 0 , -0.25 ) ;
        }
        FFT ( B , k , -1 ) ;
        for ( int i = 0 ; i < k ; ++ i ) {
            if(B[i].r>=0)
                c[i] = ( int ) ( B[i].r + 0.5 )  ;
            else c[i]=(int)(B[i].r-0.5);
        }
    }
}

int belong[N];
int r[450], l[450];
short x[450][N];
char a[N], b[N];
int x1[N << 1], x2[N << 1], x3[N << 1];

int main()
{
    scanf("%s %s", a, b);
    int m = read();
    int tot = 0, n = strlen(a), nn = strlen(b);

    int blo = pow(n, 2.0/3);
    for(int i = 0; i < n; i++)
    {
        int rr = i;
        ++tot;
        l[tot] = i;
        while(rr < n && rr - i <= blo)
        {
            belong[rr] = tot;
            rr++;
        }
        r[tot] = rr - 1;
        i = rr - 1;
    }

    for(int i = 1; i <= tot; i++)
    {
        int ii = r[i] - l[i] + 1;
        int len = 1;
        while(len <= nn) len *= 2;
        for(int j = 0; j < len; j++)
        {
            if(l[i] + j <= r[i])
            {
                if(a[l[i] + j] == '1') x1[j] = 1;
                else x1[j] = -1;
            }
            else x1[j] = 0;
            if(j < nn)
            {
                if(b[j] == '1') x2[j] = 1;
                else x2[j] = -1;
            }
            else x2[j] = 0;
        }

        FFT::mul(x1, x2, x3, len);
        for(int j = ii - 1; j < nn; j++)
        {
            x[i][j] = (ii - x3[j]) / 2;
        }
    }

    for(int i = 0; i < m; i++)
    {
        int s1 = read(), s2 = read(), len = read();
        int ans = 0;
        int ll = belong[s1];
        int rr = belong[s1 + len - 1];

        if(ll + 1 >= rr)
        {
            for(int j = s1; j < s1 + len; j++)
                if(a[j] != b[j - s1 + s2]) ans++;
        }
        else
        {
            for(int j = s1; j <= r[ll]; j++)
                if(a[j] != b[j - s1 + s2]) ans++;

            for(int j = ll + 1; j < rr; j++)
            {
                ans += x[j][nn - (l[i] - s1 + s2) - 1];
            }

            for(int j = l[rr]; j < s1 + len; j++)
                if(a[j] != b[j - s1 + s2]) ans++;
        }

        printf("%d\n",ans);
    }

    return 0;

}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <fstream>

using namespace std;

#define LL long long
#define ull unsigned long long
#define N 201000
#define M 600100
#define MP make_pair
#define Pi acos(-1.0)
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define ls (rt << 1)
#define rs (ls | 1)
#define md ((ll+rr)/2)
#define lson ls, ll, md
#define rson rs, md+1, rr
#define mod 1000000007
#define inf 0x3f3f3f3f
const LL INF = 1LL<<62;
#define sqr(x) ((x)*(x))
#define eps 1e-9
#define uLL unsidisned londis londis
#define ui unsidisned int
LL powmod(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
#define F(x) ((x)/3+((x)%3 == 1 ? 0 : tb))
#define dis(x) ((x)<tb ? (x)*3+1 : ((x) - tb)*3+2)
#define lowbit(x) ((x)&(-x))
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<LL,int>
#define pll pair<LL,LL>
#define PB push_back
#define mp make_pair
#define SZ(x) x.size()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int pos[M];

namespace FFT {
    struct comp {
        double r , i ;
        comp ( double _r = 0 , double _i = 0 ) : r ( _r ) , i ( _i ) {}
        comp operator + ( const comp& x ) {
            return comp ( r + x.r , i + x.i ) ;
        }
        comp operator - ( const comp& x ) {
            return comp ( r - x.r , i - x.i ) ;
        }
        comp operator * ( const comp& x ) {
            return comp ( r * x.r - i * x.i , i * x.r + r * x.i ) ;
        }
        comp conj () {
            return comp ( r , -i ) ;
        }
    } A[M] , B[M] ;

    const double pi = acos ( -1.0 ) ;
    void FFT ( comp a[] , int n , int t ) {
        for ( int i = 1 ; i < n ; ++ i ) if ( pos[i] > i ) swap ( a[i] , a[pos[i]] ) ;
        for ( int d = 0 ; ( 1 << d ) < n ; ++ d ) {
            int m = 1 << d , m2 = m << 1 ;
            double o = pi * 2 / m2 * t ;
            comp _w ( cos ( o ) , sin ( o ) ) ;
            for ( int i = 0 ; i < n ; i += m2 ) {
                comp w ( 1 , 0 ) ;
                for ( int j = 0 ; j < m ; ++ j ) {
                    comp& A = a[i + j + m] , &B = a[i + j] , t = w * A ;
                    A = B - t ;
                    B = B + t ;
                    w = w * _w ;
                }
            }
        }
        if ( t == -1 ) for ( int i = 0 ; i < n ; ++ i ) a[i].r /= n ;
    }
    void mul ( int *a , int *b , int *c ,int k) {
        int i , j ;
        for ( i = 0 ; i < k ; ++ i ) A[i] = comp ( a[i] , b[i] ) ;
        j = __builtin_ctz ( k ) - 1 ;
        for ( int i = 0 ; i < k ; ++ i ) {
            pos[i] = pos[i >> 1] >> 1 | ( ( i & 1 ) << j ) ;
        }
        FFT ( A , k , 1 ) ;
        for ( int i = 0 ; i < k ; ++ i ) {
            j = ( k - i ) & ( k - 1 ) ;
            B[i] = ( A[i] * A[i] - ( A[j] * A[j] ).conj () ) * comp ( 0 , -0.25 ) ;
        }
        FFT ( B , k , -1 ) ;
        for ( int i = 0 ; i < k ; ++ i ) {
            if(B[i].r>=0)
                c[i] = ( int ) ( B[i].r + 0.5 )  ;
            else c[i]=(int)(B[i].r-0.5);
        }
    }
}

int belong[N];
int r[450], l[450];
short x[450][N];
char a[N], b[N];
int x1[N << 1], x2[N << 1], x3[N << 1];

int main()
{
    scanf("%s %s", a, b);
    int m = read();
    int tot = 0, n = strlen(a), nn = strlen(b);

    int blo = pow(n, 2.0/3);
    for(int i = 0; i < n; i++)
    {
        int rr = i;
        ++tot;
        l[tot] = i;
        while(rr < n && rr - i <= blo)
        {
            belong[rr] = tot;
            rr++;
        }
        r[tot] = rr - 1;
        i = rr - 1;
    }

    for(int i = 1; i <= tot; i++)
    {
        int ii = r[i] - l[i] + 1;
        int len = 1;
        while(len <= nn) len *= 2;
        for(int j = 0; j < len; j++)
        {
            if(l[i] + j <= r[i])
            {
                if(a[l[i] + j] == '1') x1[j] = 1;
                else x1[j] = -1;
            }
            else x1[j] = 0;
            if(j < nn)
            {
                if(b[j] == '1') x2[j] = 1;
                else x2[j] = -1;
            }
            else x2[j] = 0;
        }

        FFT::mul(x1, x2, x3, len);
        for(int j = ii - 1; j < nn; j++)
        {
            x[i][j] = (ii - x3[j]) / 2;
        }
    }

    for(int i = 0; i < m; i++)
    {
        int s1 = read(), s2 = read(), len = read();
        int ans = 0;
        int ll = belong[s1];
        int rr = belong[s1 + len - 1];

        if(ll + 1 >= rr)
        {
            for(int j = s1; j < s1 + len; j++)
                if(a[j] != b[j - s1 + s2]) ans++;
        }
        else
        {
            for(int j = s1; j <= r[ll]; j++)
                if(a[j] != b[j - s1 + s2]) ans++;

            for(int j = ll + 1; j < rr; j++)
            {
                ans += x[j][nn - (l[j] - s1 + s2) - 1];
            }

            for(int j = l[rr]; j < s1 + len; j++)
                if(a[j] != b[j - s1 + s2]) ans++;
        }

        printf("%d\n",ans);
    }

    return 0;

}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <fstream>

using namespace std;

#define LL long long
#define ull unsigned long long
#define N 201000
#define M 600100
#define MP make_pair
#define Pi acos(-1.0)
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define ls (rt << 1)
#define rs (ls | 1)
#define md ((ll+rr)/2)
#define lson ls, ll, md
#define rson rs, md+1, rr
#define mod 1000000007
#define inf 0x3f3f3f3f
const LL INF = 1LL<<62;
#define sqr(x) ((x)*(x))
#define eps 1e-9
#define uLL unsidisned londis londis
#define ui unsidisned int
LL powmod(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
#define F(x) ((x)/3+((x)%3 == 1 ? 0 : tb))
#define dis(x) ((x)<tb ? (x)*3+1 : ((x) - tb)*3+2)
#define lowbit(x) ((x)&(-x))
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<LL,int>
#define pll pair<LL,LL>
#define PB push_back
#define mp make_pair
#define SZ(x) x.size()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int pos[M];

namespace FFT {
    struct comp {
        double r , i ;
        comp ( double _r = 0 , double _i = 0 ) : r ( _r ) , i ( _i ) {}
        comp operator + ( const comp& x ) {
            return comp ( r + x.r , i + x.i ) ;
        }
        comp operator - ( const comp& x ) {
            return comp ( r - x.r , i - x.i ) ;
        }
        comp operator * ( const comp& x ) {
            return comp ( r * x.r - i * x.i , i * x.r + r * x.i ) ;
        }
        comp conj () {
            return comp ( r , -i ) ;
        }
    } A[M] , B[M] ;

    const double pi = acos ( -1.0 ) ;
    void FFT ( comp a[] , int n , int t ) {
        for ( int i = 1 ; i < n ; ++ i ) if ( pos[i] > i ) swap ( a[i] , a[pos[i]] ) ;
        for ( int d = 0 ; ( 1 << d ) < n ; ++ d ) {
            int m = 1 << d , m2 = m << 1 ;
            double o = pi * 2 / m2 * t ;
            comp _w ( cos ( o ) , sin ( o ) ) ;
            for ( int i = 0 ; i < n ; i += m2 ) {
                comp w ( 1 , 0 ) ;
                for ( int j = 0 ; j < m ; ++ j ) {
                    comp& A = a[i + j + m] , &B = a[i + j] , t = w * A ;
                    A = B - t ;
                    B = B + t ;
                    w = w * _w ;
                }
            }
        }
        if ( t == -1 ) for ( int i = 0 ; i < n ; ++ i ) a[i].r /= n ;
    }
    void mul ( int *a , int *b , int *c ,int k) {
        int i , j ;
        for ( i = 0 ; i < k ; ++ i ) A[i] = comp ( a[i] , b[i] ) ;
        j = __builtin_ctz ( k ) - 1 ;
        for ( int i = 0 ; i < k ; ++ i ) {
            pos[i] = pos[i >> 1] >> 1 | ( ( i & 1 ) << j ) ;
        }
        FFT ( A , k , 1 ) ;
        for ( int i = 0 ; i < k ; ++ i ) {
            j = ( k - i ) & ( k - 1 ) ;
            B[i] = ( A[i] * A[i] - ( A[j] * A[j] ).conj () ) * comp ( 0 , -0.25 ) ;
        }
        FFT ( B , k , -1 ) ;
        for ( int i = 0 ; i < k ; ++ i ) {
            if(B[i].r>=0)
                c[i] = ( int ) ( B[i].r + 0.5 )  ;
            else c[i]=(int)(B[i].r-0.5);
        }
    }
}

int belong[N];
int r[450], l[450];
short x[450][N];
char a[N], b[N];
int x1[N << 1], x2[N << 1], x3[N << 1];

int main()
{
    scanf("%s %s", a, b);
    int m = read();
    int tot = 0, n = strlen(a), nn = strlen(b);

    int blo = pow(n, 2.0/3);
    for(int i = 0; i < n; i++)
    {
        int rr = i;
        ++tot;
        l[tot] = i;
        while(rr < n && rr - i <= blo)
        {
            belong[rr] = tot;
            rr++;
        }
        r[tot] = rr - 1;
        i = rr - 1;
    }

    for(int i = 1; i <= tot; i++)
    {
        int ii = r[i] - l[i] + 1;
        int len = 1;
        while(len <= nn) len *= 2;
        for(int j = 0; j < len; j++)
        {
            if(l[i] + j <= r[i])
            {
                if(a[l[i] + j] == '1') x1[j] = 1;
                else x1[j] = -1;
            }
            else x1[j] = 0;
            if(j < nn)
            {
                if(b[j] == '1') x2[j] = 1;
                else x2[j] = -1;
            }
            else x2[j] = 0;
        }

        FFT::mul(x1, x2, x3, len);
        for(int j = ii - 1; j < nn; j++)
        {
            x[i][j] = (ii - x3[j]) / 2;
        }
    }

    for(int i = 0; i < m; i++)
    {
        int s1 = read(), s2 = read(), len = read();
        int ans = 0;
        int ll = belong[s1];
        int rr = belong[s1 + len - 1];

        if(ll + 1 >= rr)
        {
            for(int j = s1; j < s1 + len; j++)
                if(a[j] != b[j - s1 + s2]) ans++;
        }
        else
        {
            for(int j = s1; j <= r[ll]; j++)
                if(a[j] != b[j - s1 + s2]) ans++;

            for(int j = ll + 1; j < rr; j++)
            {
                ans += x[j][nn - (l[i] - s1 + s2) - 1];
            }

            for(int j = l[rr]; j < s1 + len; j++)
                if(a[j] != b[j - s1 + s2]) ans++;
        }

        printf("%d\n",ans);
    }

    return 0;

}