Problem: There is a simple way to create hard tasks: take one simple problem as the query, and try to find an algorithm that can solve it faster than bruteforce. This kind of tasks usually appears in OI contest, and usually involves data structures.

Let's try to create a task, for example, we take the "Hamming distance problem": for two binary strings s and t with the same length, the Hamming distance between them is the number of positions at which the corresponding symbols are different. For example, the Hamming distance between "00111" and "10101" is 2 (the different symbols are marked with bold).

We use the Hamming distance problem as a query in the following way: you are given two strings a and b and several queries. Each query will be: what is the Hamming distance between two strings ap1ap1 + 1...ap1 + len - 1 and bp2bp2 + 1...bp2 + len - 1?

Note, that in this problem the strings are zero-based, that is s = s0s1... s|s| - 1.

Input

The first line contains a string a (1 ≤ |a| ≤ 200000). The second line contains a string b (1 ≤ |b| ≤ 200000). Each character of both strings is either "0" or "1".

The third line contains an integer q (1 ≤ q ≤ 400000) — the number of queries. Each of the following q lines contains three integers: p1, p2 and len (0 ≤ p1 ≤ |a| - len; 0 ≤ p2 ≤ |b| - len), these numbers denote the parameters of the current query.

Output

Output q integers — the answers for the queries.

Examples

Input

101010
11110000
3
0 0 3
2 3 4
5 7 1


Output

1
1
0


Input

10001010101011001010100101010011010
101010100101001010100100101010
5
0 0 12
3 9 7
6 4 15
12 15 10
13 3 20


Output

5
4
3
5
13

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 200005, M = 7005, K = 55, mod = 104857601;
char A[N], B[N];
int n, m, q, len, bin[N << 2], f[K][N], Bin[70000], lim;
int p1, p2, lth, id[N], l[K], r[K], ans, inv2;
long long a[N << 2], b[N << 2], fA[N], fB[N];
int getint() {
  char ch;
  while (!isdigit(ch = getchar()))
    ;
  int x = ch - 48;
  while (isdigit(ch = getchar())) x = x * 10 + ch - 48;
  return x;
}
long long getmi(long long a, long long x) {
  long long rt = 1;
  while (x) {
    if (x & 1) rt = rt * a % mod;
    a = a * a % mod, x >>= 1;
  }
  return rt;
}
void FFT(long long a[], int len, int tp) {
  for (int i = 0; i <= len - 1; ++i)
    if (i < bin[i]) swap(a[i], a[bin[i]]);
  for (int i = 1; i < len; i <<= 1) {
    long long wn = getmi(3, (mod - 1) / (i << 1));
    if (tp == -1) wn = getmi(wn, mod - 2);
    for (int j = 0; j < len; j += i << 1) {
      long long w = 1, x, y;
      for (int k = 0; k <= i - 1; ++k) {
        x = a[j + k], y = a[i + j + k] * w % mod, w = w * wn % mod;
        a[j + k] = (x + y) % mod, a[i + j + k] = (x - y + mod) % mod;
      }
    }
  }
  if (tp == -1) {
    long long x = getmi(len, mod - 2);
    for (int i = 0; i <= len - 1; ++i) a[i] = a[i] * x % mod;
  }
}
void build(int id) {
  for (int i = l[id]; i <= r[id]; ++i) a[r[id] - i] = A[i] == '0' ? -1 : 1;
  for (int i = r[id] - l[id] + 1; i <= len - 1; ++i) a[i] = 0;
  FFT(a, len, 1);
  for (int i = 0; i <= len - 1; ++i) a[i] = a[i] * b[i] % mod;
  FFT(a, len, -1);
  for (int i = 0; i <= m - 1; ++i) {
    a[i + r[id] - l[id]] = (a[i + r[id] - l[id]] + mod) % mod;
    f[id][i] = (r[id] - l[id] + 1 - a[i + r[id] - l[id]]) * inv2 % mod;
    f[id][i] = (f[id][i] + mod) % mod;
  }
}
void prepare() {
  inv2 = getmi(2, mod - 2);
  for (len = 1; len <= lim - 1 + m - 1; len <<= 1)
    ;
  for (int i = 0; i <= len - 1; ++i)
    bin[i] = bin[i >> 1] >> 1 | ((i & 1) * (len >> 1));
  for (int i = 0; i <= m - 1; ++i) b[i] = B[i] == '0' ? -1 : 1;
  FFT(b, len, 1);
  for (int i = 0; i <= n - 1; ++i) id[i] = i / lim;
  for (int i = 0; i <= n - 1; ++i) r[id[i]] = i;
  for (int i = n - 1; i >= 0; --i) l[id[i]] = i;
  for (int i = 0; i <= id[n - 1]; ++i) build(i);
}
long long get(long long f[], int s) {
  int x = s >> 5, y = s & 31;
  long long s1 = f[x] >> y, s2 = f[x + 1] & ((1ll << y) - 1);
  return !y ? s1 : s1 | (s2 << (32 - y));
}
int solve_force(int l1, int r1, int l2) {
  long long rt = 0;
  for (int i = l1; i <= r1; ++i) rt += A[i] != B[l2 + i - l1];
  return rt;
}
int solve(int l1, int r1, int l2) {
  int rt = 0;
  for (int i = l1; i <= r1; i += 32) {
    if (i + 32 > r1) {
      rt += solve_force(i, r1, l2 + i - l1);
      break;
    }
    long long x = get(fA, i);
    long long y = get(fB, i - l1 + l2);
    x ^= y, rt += Bin[x >> 16] + Bin[x & 65535];
  }
  return rt;
}
void solve() {
  int ql, qr;
  for (int i = 0; i <= id[n - 1]; ++i)
    if (r[i] >= p1) {
      ans += solve(p1, r[i], p2), ql = i + 1;
      break;
    }
  for (int i = id[n - 1]; i >= 0; --i)
    if (l[i] <= p1 + lth - 1) {
      ans += solve(l[i], p1 + lth - 1, p2 - p1 + l[i]), qr = i - 1;
      break;
    }
  for (int i = ql; i <= qr; ++i) ans += f[i][p2 + l[i] - p1];
  printf("%d\n", ans);
}
int main() {
  scanf("%s", A), n = strlen(A);
  for (int i = 0; i <= n - 1; ++i)
    if (A[i] == '1') {
      int x = i >> 5, y = i & 31;
      fA[x] |= 1ll << y;
    }
  scanf("%s", B), m = strlen(B);
  for (int i = 0; i <= m - 1; ++i)
    if (B[i] == '1') {
      int x = i >> 5, y = i & 31;
      fB[x] |= 1ll << y;
    }
  for (int i = 1; i <= 65535; ++i) Bin[i] = Bin[i ^ (i & -i)] + 1;
  lim = M - 5;
  prepare(), q = getint();
  while (q--) {
    p1 = getint(), p2 = getint(), lth = getint();
    if (id[p1] == id[p1 + lth - 1]) {
      printf("%d\n", solve(p1, p1 + lth - 1, p2));
      continue;
    }
    ans = 0, solve();
  }
  return 0;
}