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 oo = 0x3f3f3f3f;
const long long ooo = 9223372036854775807ll;
const int _cnt = 1000 * 1000 + 7;
const int _p = 998244353;
const int N = 215005;
const double PI = acos(-1.0);
const double eps = 1e-9;
int o(int x) { return x % _p; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
void file_put() {
  freopen("filename.in", "r", stdin);
  freopen("filename.out", "w", stdout);
}
void build(vector<int> &V, int *l, int *r) {
  V.clear();
  for (auto t = l; t != r; ++t) V.push_back(*t);
}
inline void build(vector<int> &V, char *l, char *r) {
  V.clear();
  for (auto t = (l); t <= (r); ++t) V.push_back(2 * (*t - '0') - 1);
}
char s[N], t[N];
int n, m, q, l, r, x, y, L, B, dp[235][N], cnt = 0;
vector<int> A, BB, C;
inline void Query(int l, int r, int x, int y) {
  int ans = 0;
  while (l <= r && l % B != 0) ans += (s[l] == t[x]), ++l, ++x;
  while (l <= r && (r + 1) % B != 0 && r != n - 1)
    ans += (s[r] == t[y]), --r, --y;
  ans %= _p;
  for (; l <= r; l += B, x += B) ans += dp[l / B][x], ans %= _p;
  printf("%d\n", ans);
}
int getlen(int k) {
  return (((k + 1) * B) < (n) ? ((k + 1) * B) : (n)) - k * B;
}
void norm(vector<int> &V) {
  for (auto &t : V) {
    t = (t + _p) % _p;
    if (t > 200000) t -= _p;
  }
}
struct TT {
  const static int N = 1 << 19;
  const double pi = acos(-1.0);
  struct vir {
    double a, b;
    vir(double r = 0.0, double i = 0.0) { a = r, b = i; }
    vir operator+(const vir &o) const { return vir(a + o.a, b + o.b); }
    vir operator-(const vir &o) const { return vir(a - o.a, b - o.b); }
    vir operator*(const vir &o) const {
      return vir(a * o.a - b * o.b, b * o.a + a * o.b);
    }
    vir operator*(const double &o) const { return vir(a * o, b * o); }
    vir operator!() const { return vir(a, -b); }
  } x[N | 1], y[N | 1], z[N | 1], w[N | 1];
  int K;
  void fft(vir x[], int k, int v) {
    for (int i = 0, j = 0; i < k; i++) {
      if (i > j) swap(x[i], x[j]);
      for (int l = k >> 1; (j ^= l) < l; l >>= 1)
        ;
    }
    w[0] = vir(1, 0);
    for (int i = 2; i <= k; i <<= 1) {
      vir g = vir(cos(2 * pi / i), (v ? -1 : 1) * sin(2 * pi / i));
      for (int j = (i >> 1); j >= 0; j -= 2) w[j] = w[j >> 1];
      for (int j = 1; j < i >> 1; j += 2) w[j] = w[j - 1] * g;
      for (int j = 0; j < k; j += i) {
        vir *a = x + j, *b = a + (i >> 1);
        for (int l = 0; l < i >> 1; l++) {
          vir o = b[l] * w[l];
          b[l] = a[l] - o;
          a[l] = a[l] + o;
        }
      }
    }
    if (v)
      for (int i = 0; i < k; i++) x[i] = vir(x[i].a / k, x[i].b / k);
  }
  void multiply(int *a, int *b, int na, int nb, vector<int> &C) {
    reverse(a, a + na);
    na--, nb--;
    for (K = 1; K <= na + nb >> 1; K <<= 1)
      ;
    for (auto i = (0); i <= (K - 1); ++i) x[i] = y[i] = vir(0, 0);
    for (int i = 0; i <= na; i++) (i & 1 ? x[i >> 1].b : x[i >> 1].a) = a[i];
    for (int i = 0; i <= nb; i++) (i & 1 ? y[i >> 1].b : y[i >> 1].a) = b[i];
    fft(x, K, 0);
    fft(y, K, 0);
    for (auto i = (0); i <= (K - 1); ++i) {
      int j = K - 1 & K - i;
      vir tmp = (i & K >> 1) ? vir(1, 0) - w[i ^ K >> 1] : w[i] + vir(1, 0);
      z[i] = (x[i] * y[i] * 4 - (x[i] - !x[j]) * (y[i] - !y[j]) * tmp) * 0.25;
    }
    fft(z, K, 1);
    C.resize(na + nb + 1);
    for (auto i = (0); i <= (na + nb); ++i)
      C[i] = i & 1 ? z[i >> 1].b + 0.1 : z[i >> 1].a + 0.1;
    for (auto i = (na); i <= (na + nb); ++i) C[i - na] = C[i];
    C.resize(nb + 1);
    reverse(a, a + na + 1);
  }
} TTT;
int main() {
  scanf("%s%s%d", s, t, &q), n = strlen(s), m = strlen(t);
  for (auto i = (0); i <= (m - 1); ++i) t[i] ^= 1;
  B = sqrt(n) + 0.5;
  B = 1000;
  cnt = (n - 1) / B + 1;
  build(BB, t, t + m);
  for (auto k = (0); k <= (cnt - 1); ++k) {
    build(A, s + k * B, s + (((k + 1) * B) < (n) ? ((k + 1) * B) : (n)) - 1);
    TTT.multiply((int *)A.data(), (int *)BB.data(), (int)A.size(),
                 (int)BB.size(), C);
    norm(C);
    for (auto i = (0); i <= (m - 1); ++i)
      dp[k][i] = (long long)(getlen(k) + C[i]) >> 1;
  }
  while (q--) {
    scanf("%d%d%d", &l, &x, &L), r = l + L - 1, y = x + L - 1;
    Query(l, r, x, y);
  }
  return 0;
}