"""
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""

import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right

from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())

MOD = 10**9+7

"""
4 6
6 8 10
8 10 12 14
10 12 14 16 18
12 14 16 18 20 22
"""

def solve():
    N = getInt()
    ans = []
    for j in range(N):
        ans.append((N+j)*2)
    print(*ans)
    return

for _ in range(getInt()):
    solve()


"""
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""

import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right

from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())

MOD = 10**9+7

"""

"""

def solve():
    N = getInt()
    ans = []
    for j in range(N):
        ans.append(4+2*j)
    print(*ans)
    return

for _ in range(getInt()):
    solve()


for _ in range(int(input()):
    n = int(input())

    ls = []
    for i in range(2*n,4*n,2):
        ls.append(i)

    print(*ls)


for _ in range(int(input())):
    n = int(input())

    ls = []
    for i in range(2*n,4*n,2):
        ls.append(i)

    print(*ls)


t=int(input())
for i in range(t):
    n=int(input())
    g=2*n-2
    ans=[g]
    if n==1:
        print(1)
        continue
    if n==2:
        print(4,6)
        continue
    for k in range(g+2,4*n+1,2):
        #print(ans)
        f=0
        if len(ans)>=n:
            break
        for j in ans:
            #print(k,j)
            if k%j==0:
                f=1
                break
        if f==0:
            ans.append(k)
        if len(ans)>=n:
            break
    print(*ans)
    #print(len(ans),"klklklklk")


t=int(input())
for i in range(t):
    n=int(input())
    ans=[4]
    for k in range(6,1000000,2):
        #print(ans)
        f=0
        if len(ans)>=n:
            break
        for j in ans:
            #print(k,j)
            if k%j==0:
                f=1
                break
        if f==0:
            ans.append(k)
        if len(ans)>=n:
            break
    print(*ans)


t=int(input())
for i in range(t):
    n=int(input())
    g=2*n-2
    ans=[g]
    if n==2:
        print(4,6)
        continue
    for k in range(g+2,4*n+1,2):
        #print(ans)
        f=0
        if len(ans)>=n:
            break
        for j in ans:
            #print(k,j)
            if k%j==0:
                f=1
                break
        if f==0:
            ans.append(k)
        if len(ans)>=n:
            break
    print(*ans)


for tc in range(int(input())):
    n = int(input())
    results = []
    for i in range(4*n-2, 0, -2):
        flag = True
        for j in results:
            if int(j) % i == 0:
                flag = False
        if flag:
            results.append(str(i))
        if len(results) == n:
            break
    ans = " ".join(results)
    print(n, results)


for tc in range(int(input())):
    n = int(input())
    results = []
    for i in range(4*n-2, 0, -2):
        flag = True
        for j in results:
            if int(j) % i == 0:
                flag = False
        if flag:
            results.append(str(i))
        if len(results) == n:
            break
    ans = " ".join(results)
    print(ans)


def sieve_of_Eratosthenes(num):
    limitn = num + 1
    not_prime_num = set()
    prime_sums = []

    for i in range(2, limitn):
        if i in not_prime_num:
            continue

        for f in range(i * 2, limitn, i):
            not_prime_num.add(f)

        prime_sums.append(i)

    return prime_sums

for tc in range(int(input())):
    n = int(input())
    start = sieve_of_Eratosthenes(2 * n)[-1] * 2
    results = []
    for i in range(4*n):
        flag = True
        for j in results:
            if i % int(j) == 0:
                flag = False
        if flag:
            results.append(str(start - 2*i))
        if len(results) == n:
            break
    ans = " ".join(results)
    print(ans)


def sieve_of_Eratosthenes(num):
    limitn = num + 1
    not_prime_num = set()
    prime_sums = []

    for i in range(2, limitn):
        if i in not_prime_num:
            continue

        for f in range(i * 2, limitn, i):
            not_prime_num.add(f)

        prime_sums.append(i)

    return prime_sums

for tc in range(int(input())):
    n = int(input())
    start = sieve_of_Eratosthenes(2 * n)[-1] * 2
    results = []
    for i in range(n):
        results.append(str(start - 2*i))
    ans = " ".join(results)
    print(ans)


def sieve_of_Eratosthenes(num):
    limitn = num + 1
    not_prime_num = set()
    prime_sums = []

    for i in range(2, limitn):
        if i in not_prime_num:
            continue

        for f in range(i * 2, limitn, i):
            not_prime_num.add(f)

        prime_sums.append(i)

    return prime_sums

for tc in range(1,101):
    n = tc
    start = sieve_of_Eratosthenes(2 * n)[-1] * 2
    results = []
    for i in range(4*n):
        flag = True
        for j in results:
            if i % int(j) == 0:
                flag = False
        if flag:
            results.append(str(start - 2*i))
        if len(results) == n:
            break
    ans = " ".join(results)
    print(ans)


def isPrime(n) :

    if (n <= 1) :
        return False
    if (n <= 3) :
        return True

    if (n % 2 == 0 or n % 3 == 0) :
        return False

    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6

    return True

i=2
j=1
L=[2]
while True:
    i+=1
    if isPrime(i):
        j+=1
        L.append(i)
    if j>105:
        break
t=int(input())
for q in range(t):
    n=int(input())
    ch=""
    for i in range(n):
        ch+=str(2*L[i])+" "
    print(ch)


t=int(input())
for q in range(t):
    n=int(input())
    L=[4*n-2]
    ch=""
    while len(L)<n:
        L.append(L[-1]-2)
    for i in range(n):
        ch+=str(L[i])+" "
    print(ch)


def isPrime(n) :

    if (n <= 1) :
        return False
    if (n <= 3) :
        return True

    if (n % 2 == 0 or n % 3 == 0) :
        return False

    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6

    return True

i=3
j=1
L=[3]
while True:
    i+=1
    if isPrime(i):
        j+=1
        L.append(i)
    if j>105:
        break
t=int(input())
for q in range(t):
    n=int(input())
    ch=""
    for i in range(n):
        ch+=str(2*L[i])+" "
    print(ch)


# Legends Always Come Up with Solution
# Author: Manvir Singh

import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt, pi, ceil, log, inf,gcd
from itertools import permutations
from copy import deepcopy
from heapq import *
from sys import setrecursionlimit
def main():
    for _ in range(int(input())):
        n = int(input())
        # n,k=map(int,input().split())
        b = []
        for i in range(2*n, 4 * n + 1,2):
            b.append(i)
            if len(b)==n:
                break
        print(*b)

# region fastio
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


# Legends Always Come Up with Solution
# Author: Manvir Singh

import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt, pi, ceil, log, inf,gcd
from itertools import permutations
from copy import deepcopy
from heapq import *
from sys import setrecursionlimit
def main():
    for _ in range(int(input())):
        n = int(input())
        # n,k=map(int,input().split())
        b = []
        for i in range(2*n, 4 * n + 1):
            b.append(i)
            if len(b)==n:
                break
        print(*b)

# region fastio
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


# Legends Always Come Up with Solution
# Author: Manvir Singh

import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt, pi, ceil, log, inf,gcd
from itertools import permutations
from copy import deepcopy
from heapq import *
from sys import setrecursionlimit

def main():
    for _ in range(int(input())):
        n = int(input())
        # n,k=map(int,input().split())
        b = []
        for i in range(4, 4 * n + 1):
            f = 1
            for j in b:
                if i % j == 0:
                    f = 0
                    break
            if f:
                b.append(i)
                if len(b) == n:
                    break
        print(*b)

# region fastio
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


# Legends Always Come Up with Solution
# Author: Manvir Singh

import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt, pi, ceil, log, inf,gcd
from itertools import permutations
from copy import deepcopy
from heapq import *
from sys import setrecursionlimit
def prime(x):
    i=2
    while i*i<=x:
        if x%i==0:
            return 1
        i+=1
    return 0
def main():
    for _ in range(int(input())):
        n = int(input())
        # n,k=map(int,input().split())
        b = []
        for i in range(4, 4 * n + 1):
            if prime(i):
                f = 1
                for j in b:
                    if i % j == 0:
                        f = 0
                        break
                if f:
                    b.append(i)
                    if len(b) == n:
                        break
        print(*b)

# region fastio
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


from math import gcd
for _ in range(int(input())):
    n=int(input())
    #n,k=map(int,input().split())
    b=[3]
    for i in range(4,401):
        if gcd(b[-1],i)==1:
            b.append(i)
            if len(b)==n:
                break
    print(*b)


import sys

NMax = 101

if __name__ == '__main__':
    k = {2 + 2 * i for i in range(1, 4 * NMax + 1)}

    for i in range(1, NMax + 1):
        v = 2 + 2 * i
        for j in range(2 * v, 4 * NMax + 1, v):
            if j in k:
                k.remove(j)

    k = list(k)
    t = int(sys.stdin.readline().strip())

    for i in range(t):
        n = int(sys.stdin.readline().strip())

        print(" ".join(map(str, k[:n])))


import sys

NMax = 101

if __name__ == '__main__':
    k = {2 + 2 * i for i in range(1, (4 * NMax - 2) // 2 + 1)}

    k_op = reversed(list(k))
    for x in k_op:
        for i in range(2, x, 2):
            if x % i == 0:
                if i in k:
                    k.remove(i)
    k = list(k)
    t = int(sys.stdin.readline().strip())

    for i in range(t):
        n = int(sys.stdin.readline().strip())

        print(" ".join(map(str, k[:n])))


import sys

NMax = 101

def get_n(n):
    k = {2 + 2 * i for i in range(1, (4 * n - 2) // 2 + 1)}

    k_op = reversed(list(k))
    for x in k_op:
        for i in range(2, x, 2):
            if x % i == 0:
                if i in k:
                    k.remove(i)
    return list(k)

if __name__ == '__main__':

    t = int(sys.stdin.readline().strip())

    for i in range(t):
        n = int(sys.stdin.readline().strip())

        print(" ".join(map(str, get_n(n)[:n])))


def check(a):
    if a == 1:
        return 0
    k = 2
    while k * k <= a:
        if a % k == 0:
            return 0
        k += 1
    return 1
for _ in range(int(input())):
    n = int(input())
    ans = []
    i = 2
    while len(ans) < 400:
        if check(i):
            ans.append(i)
        i += 1
    res = []
    for i in range(len(ans)):
        for j in range(i + 1, len(ans)):
            if len(res) == n:
                continue
            if 2 * ans[i] * ans[j] <= 4 * n:
                res.append(2 * ans[i] * ans[j])
    print(*res)


def check(a):
    if a == 1:
        return 0
    k = 2
    while k * k <= a:
        if a % k == 0:
            return 0
        k += 1
    return 1
for _ in range(int(input())):
    n = int(input())
    for i in range(2 * n, 4 * n, 2):
        print(i, end=' ')
    print()


def check(a):
    if a == 1:
        return 0
    k = 2
    while k * k <= a:
        if a % k == 0:
            return 0
        k += 1
    return 1
for _ in range(int(input())):
    n = int(input())
    ans = []
    for i in range(1, 4 * n + 1):
        if check(i):
            ans.append(i * 2)
        if len(ans) == n:
            break
    print(*ans)


def check(a):
    if a == 1:
        return 0
    k = 2
    while k * k <= a:
        if a % k == 0:
            return 0
        k += 1
    return 1
for _ in range(int(input())):
    n = int(input())
    ans = [1]
    num = 3
    while len(ans) < 400:
        if check(num):
            ans.append(num)
        num += 1
    res = [4]
    for i in range(len(ans)):
        for j in range(i, len(ans)):
            if len(res) == n:
                continue
            if ans[i] == ans[j] == 1:
                continue
            if 2 * ans[i] * ans[j] <= 4 * n:
                res.append(2 * ans[i] * ans[j])
    print(*res)


def check(a):
    if a == 1:
        return 0
    k = 2
    while k * k <= a:
        if a % k == 0:
            return 0
        k += 1
    return 1
for _ in range(int(input())):
    n = int(input())
    ans = [1]
    num = 2
    while len(ans) < 400:
        if check(num):
            ans.append(num)
        num += 1
    res = []
    for i in range(len(ans)):
        for j in range(i + 1, len(ans)):
            if len(res) == n:
                continue
            if 2 * ans[i] * ans[j] <= 4 * n:
                res.append(2 * ans[i] * ans[j])
    print(*res)


t=int(input())
while (t>0):
	n=int(input())
	k=2*n
	while(n>0):
		print(k,end=" ")
		k=k+2
		n=n-1
	t=t-1


t=int(input())
while (t>0):
	n=int(input())
	k=2*n
	while(n>0):
		print(k,end=" ")
		k=k+2
		n=n-1
	print('\n')
	t=t-1


import sys
import math as m
def mod(a,b):
    if a % b == 0:
        return b
    return mod(b , a%b)
t = int(input())
while t:
    t-= 1
    n = int(input())
    for i in range(n):
        if i == n-1:
            print(n*4-i*2)
        else:
            print(n*4-2*i,end=' ')


import sys
import math as m
def mod(a,b):
    if a % b == 0:
        return b
    return mod(b , a%b)
t = int(input())
while t:
    t -= 1
    n = int(input())
    if n == 1:
        print("2")
        continue
    count = 1
    pos = 4
    tem = pos
    for i in range(1,4*n):
        if count == n:
            while pos % 4 == 0 and pos % tem == 0:
                pos += 2
            print(pos)
            break
        else:
            print(pos , end=' ')
        count += 1
        tem = pos
        if (pos + 4) % pos == 0:
            pos += 2
        else:
            pos += 4


import sys
import math as m
def mod(a,b):
    if a % b == 0:
        return b
    return mod(b , a%b)
t = int(input())
while t:
    n = int(input())
    for i in range(n):
        if i == n-1:
            print(n*4-i*2)
        else:
            print(n*4-2*i,end=' ')


import sys
import math as m
def mod(a,b):
    if a % b == 0:
        return b
    return mod(b , a%b)
t = int(input())
while t:
    t -= 1
    n = int(input())
    count = 1
    pos = 4
    tem = pos
    for i in range(1,4*n):
        if count == n:
            while pos % 4 == 0 and pos % tem == 0:
                pos += 2
            print(pos)
            break
        else:
            print(pos , end=' ')
        count += 1
        tem = pos
        if (pos + 4) % pos == 0:
            pos += 2
        else:
            pos += 4


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
import threading
import sys
import time

def get_int(): return int(stdin.readline().strip())
def get_tuple(): return map(int, stdin.readline().split())
def get_list(): return list(map(int, stdin.readline().split()))

def solve(t,T):
    n = get_int()
    ans = []
    start = 4*n
    for i in range(n):
        while True:
            flag = True
            for val in ans:
                if start%val==0 or val%start==0:
                    flag = False
                    break
            if flag:
                ans.append(start)
                break
            start -= 2
    print(*ans)

def main(i,t):
    solve(i,t)

TestCases = True

if TestCases:
    t = get_int()
    for i in range(t):
        main(i+1,t)
else:
    main()


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
import threading
import sys
import time

def get_int(): return int(stdin.readline().strip())
def get_tuple(): return map(int, stdin.readline().split())
def get_list(): return list(map(int, stdin.readline().split()))

def solve(t,T):
    n = get_int()
    ans = []
    start = 4
    for i in range(n):
        while True:
            flag = True
            for val in ans:
                if start%val==0 or val%start==0:
                    flag = False
                    break
            if flag:
                ans.append(start)
                break
            start += 2
    print(*ans)

def main(i,t):
    solve(i,t)

TestCases = True

if TestCases:
    t = get_int()
    for i in range(t):
        main(i+1,t)
else:
    main()


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
import threading
import sys
import time

def get_int(): return int(stdin.readline().strip())
def get_tuple(): return map(int, stdin.readline().split())
def get_list(): return list(map(int, stdin.readline().split()))

def solve(t,T):
    n = get_int()
    ans = [i for i in range(2,2*n+2,2)]
    print(*ans)

def main(i,t):
    solve(i,t)

TestCases = True

if TestCases:
    t = get_int()
    for i in range(t):
        main(i+1,t)
else:
    main()


for _ in range(int(input())):
    n=int(input())
    ans=[]
    i=0
    while len(ans)<n:
        ans.append(2*n+i)
        i+=2
    print(*ans)


import math

prime=[2]
for i in range(3,401,2):
    test=0
    for j in range(2,math.ceil(i**0.5)+1):
        if i%j==0:
            test=1
            break
    if not test:
        prime.append(i)
#print(len(prime))

for _ in range(int(input())):
    n=int(input())
    ans=[]
    for i in range(n):
        ans.append(2*prime[i])
    print(*ans)


l=[4,6]
for i in range(8,401,2):
    if i%4==0 or i%6==0:
        continue
    else:
        l.append(i)

for _ in range(int(input())):
    n=int(input())
    #print(len(l))
    print(*l[:n])


test_case=int(input())
for i in range(test_case):
    val=int(input())
    n=4*val
    for i in range(0,val):
        n-=2
        print(n,end=' ')
    print()


test_case=int(input())
for i in range(test_case):
    val=int(input())
    k=1
    while(k<=val):
        print(2*k,end=" ")
        k+=1
    print()


t = int(input())
outputs = ['']*t
ns = [0]*t
m = 0
for i in range(t):
    ns[i] = int(input())
    m = max(ns[i], m)
A = [True]*(4*m + 1)
A[0] = A[1] = False
for k in range(2, len(A)):
    if A[k]:
        for d in range(k*k, len(A), k):
            A[d] = False
n = 0
k = 0
for i in ns:
    k = i*4
    while n < i:
        if not A[k] and k%2 == 0:
            print(k, end=' ')
            n += 1
        k -= 1
    else:
        n = 0
        print(end='\n')


t = int(input())
for i in range(t):
    n = int(input())
    for k in range(4*n, 2*n, -2):
        print(k, end=' ')
    print()


t = int(input())
outputs = ['']*t
ns = [0]*t
m = 0
for i in range(t):
    ns[i] = int(input())
    m = max(ns[i], m)
A = [True]*(2*m + 1)
A[0] = A[1] = False
for k in range(2, len(A)):
    if A[k]:
        for d in range(k*k, len(A), k):
            A[d] = False
n = 0
k = 0
for i in ns:
    while n < i:
        if A[k]:
            print(k*2, end=' ')
            n += 1
        k += 1
    else:
        n = k = 0
        print(end='\n')


ns = [0]*t
m = 0
for i in range(t):
    ns[i] = int(input())
    m = max(ns[i], m)
A = [True]*(2*m + 1)
A[0] = A[1] = False
for k in range(2, len(A)):
    if A[k]:
        for d in range(k*k, len(A), k):
            A[d] = False
n = 0
k = 0
for i in ns:
    while n < i:
        if A[k]:
            print(k*2, end=' ')
            n += 1
        k += 1
    else:
        n = k = 0
        print(end='\n')


#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

for i in range(inp()):
    n = inp()
    ans = [i for i in range(2,4*n+1,4)]
    print(*ans)


#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

for i in range(inp()):
    n = inp()
    ans = [i for i in range(4*n,2*n,-2)]
    print(*ans)


#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

for i in range(inp()):
    n = inp()
    ans = [i for i in range(2,2*n+1,2)]
    print(*ans)


import sys, math

tc = int(sys.stdin.readline())
for _ in range(tc):
    n = int(sys.stdin.readline())
    arr = [i for i in range(2, 4 * n + 1, 2)]
    cnt = n
    for i in range(len(arr) - 1, -1, -1):
        if cnt <= 0:
            break
        cnt -= 1
        print(arr[i], end=' ')
    print()


import sys, collections

def eratos(num):
    check = [True] * (num + 1)
    primes = []
    for i in range(2, int(num ** 0.5) + 1):
        if check[i]:
             j = 2 * i
             while j <= num:
                 check[j] = False
                 j += i
    for i in range(2, num + 1):
        if check[i]:
            primes.append(i)
    return primes

dp = eratos(1000)

tc = int(sys.stdin.readline())
for _ in range(tc):
    n = int(sys.stdin.readline())
    ans = set()
    done = False
    for j in range(2, 101):
        if done:
            break
        for i in range(n):
            if len(ans) == n:
                done = True
                break
            if j * dp[i] <= 4 * n:
                ans.add(j * dp[i])
    print(' '.join(map(str, ans)))


import sys, collections

def eratos(num):
    check = [True] * (num + 1)
    primes = []
    for i in range(2, int(num ** 0.5) + 1):
        if check[i]:
             j = 2 * i
             while j <= num:
                 check[j] = False
                 j += i
    for i in range(2, num + 1):
        if check[i]:
            primes.append(i)
    return primes

dp = eratos(1000)

tc = int(sys.stdin.readline())
for _ in range(tc):
    n = int(sys.stdin.readline())
    for i in range(n):
        print(2 * dp[i], end=' ')
    print()


import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
##########################################################
def update(bit, i):
    while (i < len(bit)):
        bit[i] += 1
        i += (i & (-i))

def getsum(bit, i):
    res = 0
    while (i > 0):
        res += bit[i]
        i -= (i & (-i))
    return res

for _ in range(int(input())):

    n=int(input())
    if n==1:
        print(1)
    else:
        ls=[]
        for i in range(4,4*n+1):
            if len(ls)==n:
                break
            else:
                if i%2==0:
                    f=0
                    for j in ls:
                        if i%j==0:
                            f=1

                    if f==0:
                        ls.append(i)
        print(*ls)


import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
##########################################################
def update(bit, i):
    while (i < len(bit)):
        bit[i] += 1
        i += (i & (-i))

def getsum(bit, i):
    res = 0
    while (i > 0):
        res += bit[i]
        i -= (i & (-i))
    return res

for _ in range(int(input())):

    n=int(input())

    if n==1:
        print(1)
    else:
        ls=[]
        flag=0
        for st in range(4,4*n+1,2):
            ls=[]
            for i in range(st,4*n+1):
                if len(ls)==n:
                    flag=1
                    break
                else:
                    if i%2==0:
                        f=0
                        for j in ls:
                            if i%j==0:
                                f=1

                        if f==0:
                            ls.append(i)

            if flag==1 or len(ls)==n:
                break

        print(*ls)


import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
##########################################################
def update(bit, i):
    while (i < len(bit)):
        bit[i] += 1
        i += (i & (-i))

def getsum(bit, i):
    res = 0
    while (i > 0):
        res += bit[i]
        i -= (i & (-i))
    return res

for _ in range(int(input())):

    n=int(input())
    if n==1:
        print(1)
    else:
        ls=[]
        for i in range(max(4,n+n%2),4*n+1):
            if len(ls)==n:
                break
            else:
                if i%2==0:
                    f=0
                    for j in ls:
                        if i%j==0:
                            f=1

                    if f==0:
                        ls.append(i)
        print(*ls)


def computegcd(x, y):

   while(y):
       x, y = y, x % y

   return x
def divcheck(ans, num):
    flag=True
    for x in ans:
        if num%x==0 or x%num==0 or computegcd(x,num)==1:
            flag=False
            break;
    return flag
t=int(input())
final=[]
for i in range(t):
    ans=[]
    n=int(input())
    if n==1:
        ans.append(1)
        final.append(ans)
        continue;
    l=list(range(2,2*n+1))
    l.reverse()
    k=0
    u=0
    while k <n:
          r=l[u]*2
          u=u+1
          if divcheck(ans,r)==True and r<n*4:
              ans.append(r)
              k=k+1
    final.append(ans)
for k in final:
    for j in k:
        print(j,end=" ")
    print()


import math
def divcheck(ans, num):
    flag=True
    for x in ans:
        if num%x==0 or x%num==0 or math.gcd(x,num)==1:
            flag=False
            break;
    return flag
t=int(input())
final=[]
if(t>=1 and t<=100):
    for i in range(t):
        ans=[]
        n=int(input())
        if(n>=1 and n<=100):
          l=list(range(2,2*n+1))
          l.reverse()
          k=0
          u=0
          mul=2
          while k <n:
              r=l[u]*mul
              u=u+1
              if divcheck(ans,r)==True and r<n*4:
                  ans.append(r)
                  k=k+1
              if u==len(l):
                  mul=mul+1
                  u=0
          final.append(ans)
for k in final:
    for j in k:
        print(j,end=" ")
    print()


import math
def divcheck(ans, num):
    flag=True
    for x in ans:
        if num%x==0 or x%num==0 or math.gcd(x,num)==1:
            flag=False
            break;
    return flag
t=int(input())
final=[]
for i in range(t):
    ans=[]
    n=int(input())
    l=list(range(2,2*n+1))
    l.reverse()
    k=0
    u=0
    mul=2
    while k <n:
          r=l[u]*mul
          u=u+1
          if divcheck(ans,r)==True and r<n*4:
              ans.append(r)
              k=k+1
          if u==len(l):
              mul=mul+1
              u=0
    final.append(ans)
for k in final:
    for j in k:
        print(j,end=" ")
    print()


import math
for _ in range(int(input())):
    n=int(input())
    ls=[4]
    for i in range(4,4*n+1):
        if len(ls)==n:
            break
        p=1
        for j in ls:
            if i%j==0 or math.gcd(i,j)==1:
                p=0
                break
        if p:
            ls.append(i)
    print(''.join(str(a)+' ' for a in ls))


import math
for _ in range(int(input())):
    n=int(input())
    for ii in range(3,4*n):
        ls=[ii+1]
        for i in range(ls[0],4*n+1):
            if len(ls)==n:
                break
            p=1
            for j in ls:
                if i%j==0 or math.gcd(i,j)==1 or j%i==0:
                    p=0
                    break
            if p:
                ls.append(i)
        #print(ls)
        if len(ls)==n:
            print(''.join(str(a)+' ' for a in ls))
            break


import math
for _ in range(int(input())):
    n=int(input())
    ls=[4]
    for i in range(4,4*n+1):
        if len(ls)==n:
            break
        p=1
        for j in ls:
            if i%j==0 or math.gcd(i,j)==1 or j%i==0:
                p=0
                break
        if p:
            ls.append(i)
    print(''.join(str(a)+' ' for a in ls))


def gcd(a, b):
    # Everything divides 0
    if (a == 0):
        return b
    if (b == 0):
        return a

    # base case
    if (a == b):
        return a

    # a is greater
    if (a > b):
        return gcd(a - b, b)
    return gcd(a, b - a)
for i in range(int(input())):
    x=int(input())
    q=[]
    y=[]
    e=6
    y.append(4)
    while(len(y)<x):
        for j in range(len(y)):
            # #print(y[j]%e ,y[j],len(y),y,e)
            # print(e%y[j])
            # print(gcd(e,y[j]))

            if(gcd(e,y[j])!=1 and y[j]%e!=0 and e%y[j]!=0):
                y.append(e)
                break
            if(y[j]%e==0 or e%y[j]==0):
                break
        e+=1

    print(y)


for i in range(int(input())):
    x=int(input())
    y=[]
    z=4*x
    for i in range(x):
        y.append(z)
        z=z-2

    print(*y)


def gcd(a, b):
    # Everything divides 0
    if (a == 0):
        return b
    if (b == 0):
        return a

    # base case
    if (a == b):
        return a

    # a is greater
    if (a > b):
        return gcd(a - b, b)
    return gcd(a, b - a)

for i in range(int(input())):
    x=int(input())
    q=[]
    y=[]
    e=6
    y.append(4)
    while(len(y)<x):
        for j in range(len(y)):
            # #print(y[j]%e ,y[j],len(y),y,e)
            # print(e%y[j])
            # print(gcd(e,y[j]))

            if(gcd(e,y[j])!=1 and y[j]%e!=0 and e%y[j]!=0):
                y.append(e)
                break
            if(y[j]%e==0 or e%y[j]==0):
                break
        e+=1

    print(*y)


def gcd(a, b):
    # Everything divides 0
    if (a == 0):
        return b
    if (b == 0):
        return a

    # base case
    if (a == b):
        return a

    # a is greater
    if (a > b):
        return gcd(a - b, b)
    return gcd(a, b - a)

for i in range(int(input())):
    x=int(input())
    q=[]
    y=[]
    e=6
    y.append(4)
    while(len(y)<x):
        for j in range(len(y)):
            # #print(y[j]%e ,y[j],len(y),y,e)
            # print(e%y[j])
            # print(gcd(e,y[j]))

            if(gcd(e,y[j])!=1 and y[j]%e!=0 and e%y[j]!=0):
                y.append(e)
                break
            if(y[j]%e==0 or e%y[j]==0):
                break
            if(gcd(e,y[j])==1):
                break
        e+=1

    print(*y)


try:
    t = int(input())
    for i in range(t):
        a =int(input())

        ans = [i for i in range(1,4*a+1) if i%2==0][::-1]
        ans = ans[:a]
        print(*ans)

except:
    pass


# include <bits/stdc++.h>
const int MAXN = 2e5 + 5;
const int maxn = 1 << 21;
const int mod = 998244353;
char s[MAXN], t[MAXN];
int Q, N, rev[maxn], f[205][MAXN], A[maxn], B[maxn], wn[maxn], Ni, ni[maxn], len = 1000, bl[MAXN], n, m;

char xB[1 << 15], *xS = xB, *xT = xB;
# define getc (xS == xT && (xT = (xS = xB) + fread(xB, 1, 1 << 15, stdin), xS == xT) ? 0 : *xS ++)
inline int read() {
    register int x = 0, f = 1; char ch = getc;
    for (; !isdigit(ch); ch = getc) if (ch == '-') f = -f;
    for (; isdigit(ch); ch = getc) x = x * 10 + (ch ^ 48);
    return x * f;
}

inline void read(char s[]) {
    int cnt = 0; char c = getc;
    for (; c != '0' && c != '1'; c = getc) ;
    for (; c == '0' || c == '1'; c = getc) s[++cnt] = c;
}

inline int qpow(int x, int k) {
    int Ans = 1;
    for (; k; k >>= 1, x = 1ll * x * x % mod)
        if (k & 1) Ans = 1ll * x * Ans % mod;
    return Ans;
}

inline void Init(int n) {
    for (N = 1; N < (n << 1); N <<= 1);
    for (int i = 0; i < N; ++i)
        if (i & 1) rev[i] = rev[i >> 1] >> 1 | (N >> 1);
        else rev[i] = rev[i >> 1] >> 1;
    wn[0] = 1; wn[1] = qpow(3, (mod - 1) / N);
    for (int i = 2; i <= N; ++i) wn[i] = 1ll * wn[i - 1] * wn[1] % mod;
    std::reverse_copy(wn, &wn[N + 1], ni);
    Ni = qpow(N, mod - 2);
}

inline void fft(int *f, int type, int *wn) {
    register int i, j, k, *l, *r, *w, len, t;
    for (i = 0; i < N; ++i) if (i < rev[i]) std::swap(f[i], f[rev[i]]);
    for (k = 2, len = N >> 1; k <= N; k <<= 1, len >>= 1)
        for (j = 0; j < N; j += k) {
            l = f + j, r = l + (k >> 1), w = wn;
            for (i = 0; i < (k >> 1); ++i, ++l, ++ r, w += len)
                t = 1ll * *r * *w % mod, *r = (*l - t + mod) % mod, *l = (*l + t) % mod;
        }
    if (type == -1) for (i = 0; i < N; ++i) f[i] = 1ll * f[i] * Ni % mod;
}

inline void Work(char type, int bl) {
    if (!bl) return;
    memset(A, 0, N << 2);
    for (int i = 1; i <= n; ++i) A[i] = s[n - i + 1] == type;
    fft(A, 1, wn), fft(B, 1, wn);
    for (int i = 0; i < N; ++i) B[i] = 1ll * A[i] * B[i] % mod;
    fft(B, -1, ni);
    for (int i = len; i <= n + 1; ++i)
        f[bl][n - i + 2] += B[i];
    memset(B, 0, N << 2);
}

inline void Query(int l, int r, int Len) {
    int Ans = 0, last = l + bl[r] * len - r + 1;
    for (int i = bl[r] + 1; i < bl[r + Len - 1]; ++i) Ans += len - f[i][last], last += len;
    for (int i = r; i <= bl[r] * len && i < r + Len; ++i)
        Ans += t[i] ^ s[l + i - r];
    if (bl[r] != bl[r + Len - 1])
        for (int i = (bl[r + Len - 1] - 1) * len + 1; i < r + Len; ++i)
            Ans += t[i] ^ s[l + i - r];
    printf("%d\n", Ans);
}

int main() {
    // freopen("Cooook.in","r",stdin);
    // freopen("Cooook.out","w",stdout);
    read(s), read(t);
    n = strlen(s + 1), m = strlen(t + 1);
    Init(n + len + 2);
    int last = 0;
    for (int i = 1; i <= m; ++i) {
        bl[i] = (i - 1) / len + 1;
        if (bl[i - 1] != bl[i]) Work('1', bl[i - 1]), last = i - 1;
        B[i - last] = t[i] == '1';
    }

    memset(B, 0, N << 2);

    for (int i = 1; i <= m; ++i) {
        if (bl[i - 1] != bl[i]) Work('0', bl[i - 1]), last = i - 1;
        B[i - last] = t[i] == '0';
    }

    Q = read();
    register int l, r, Len, Ans, i;
    while (Q --) {
        l = read() + 1, r = read() + 1, Len = read();
        Query(l, r, Len);
    }
    // while (true);
    return 0;
}


# include <map>
# include <stdio.h>
# include <iostream>
const int MAXN = 2e5 + 5;
char s[MAXN], t[MAXN];
int Q;

char xB[1 << 15], *xS = xB, *xT = xB;
# define getc (xS == xT && (xT = (xS = xB) + fread(xB, 1, 1 << 15, stdin), xS == xT) ? 0 : *xS ++)
inline int read() {
    register int x = 0, f = 1; char ch = getc;
    for (; !isdigit(ch); ch = getc) if (ch == '-') f = -f;
    for (; isdigit(ch); ch = getc) x = x * 10 + (ch ^ 48);
    return x * f;
}

inline void read(char s[]) {
    int cnt = 0; char c = getc;
    for (; c != '0' && c != '1'; c = getc) ;
    for (; c == '0' || c == '1'; c = getc) s[cnt++] = c;
}

struct data {
    int l, r, val;
    data(int l = 0, int r = 0, int val = 0) : l(l), r(r), val(val) {  }
    inline bool operator == (const data &a) const {
        return l == a.l && r == a.r && val == a.val;
    }
    inline bool operator < (const data &a) const {
        if (l == a.l) {
            if (r == a.r) return val < a.val;
            return r < a.r;
        } return l < a.l;
    }
};

std::map<data, int> ma;

int main() {
    // freopen("Cooook.in","r",stdin);
    // freopen("Cooook.out","w",stdout);
    read(s), read(t);
    Q = read();
    register int l, r, Len, Ans, i;
    while (Q --) {
        l = read(), r = read(), Len = read(); Ans = 0;
        if (ma.count(data(l, r, Len))) { printf("%d\n", ma[data(l, r, Len)]); continue; }
        for (i = 0; i + 8 < Len; i += 8)
            Ans += s[l + i] != t[r + i],
            Ans += s[l + i + 1] != t[r + i + 1],
            Ans += s[l + i + 2] != t[r + i + 2],
            Ans += s[l + i + 3] != t[r + i + 3],
            Ans += s[l + i + 4] != t[r + i + 4],
            Ans += s[l + i + 5] != t[r + i + 5],
            Ans += s[l + i + 6] != t[r + i + 6],
            Ans += s[l + i + 7] != t[r + i + 7];
        for (; i < Len; ++i) Ans += s[l + i] != t[r + i];
        printf("%d\n", ma[data(l, r, Len)] = Ans);
    }
    // while (true);
    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;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef map<int, vector<int> > mvii;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef vector<pii > vpii;

// Order Statistic Tree

/* Special functions:

        find_by_order(k) --> returns iterator to the kth largest element counting from 0
        order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

// typedef tree<
// int,
// null_type,
// less<int>,
// rb_tree_tag,
// tree_order_statistics_node_update>
// ordered_set;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define ALL(a) a.begin(), a.end()
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define inf 1e9
#define INF 1e16
#define pb push_back
#define MAX 100005
#define debug(a,b) cout<<a<<": "<<b<<endl
#define Debug cout<<"Reached here"<<endl
#define prnt(a) cout<<a<<"\n"
#define mod 1000000007LL
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORr(i,a,b) for (int i=(a); i>=(b); i--)
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define lc ((node)<<1)
#define rc ((node)<<1|1)
#define VecPrnt(v) FOR(J,0,v.size()) cout<<v[J]<<" "; cout<<endl
#define endl "\n"
#define PrintPair(x) cout<<x.first<<" "<<x.second<<endl
#define EPS 1e-9
#define ArrPrint(a,st,en) for(int J=st; J<=en; J++) cout<<a[J]<<" "; cout<<endl;

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

template <class T> inline T bigmod(T p, T e, T M)
{
	ll ret = 1;
	for (; e > 0; e >>= 1)
	{
		if (e & 1) ret = (ret * p) % M;
		p = (p * p) % M;
	} return (T)ret;
}

template <class T> inline T gcd(T a, T b) {if (b == 0)return a; return gcd(b, a % b);}
template <class T> inline T modinverse(T a, T M) {return bigmod(a, M - 2, M);}
template <class T> inline T lcm(T a, T b) {a = abs(a); b = abs(b); return (a / gcd(a, b)) * b;}
template <class T, class X> inline bool getbit(T a, X i) { T t = 1; return ((a & (t << i)) > 0);}
template <class T, class X> inline T setbit(T a, X i) { T t = 1; return (a | (t << i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t = 1; return (a & (~(t << i)));}

inline ll getnum()
{
	char c = getchar();
	ll num, sign = 1;
	for (; c < '0' || c > '9'; c = getchar())if (c == '-')sign = -1;
	for (num = 0; c >= '0' && c <= '9';)
	{
		c -= '0';
		num = num * 10 + c;
		c = getchar();
	}
	return num * sign;
}

inline ll power(ll a, ll b)
{
	ll multiply = 1;
	FOR(i, 0, b)
	{
		multiply *= a;
	}
	return multiply;
}

/***************** END OF HEADER *****************/

const int MAXN = (1 << 21);

struct complex_base
{
	double x, y;
	complex_base(double _x = 0, double _y = 0) { x = _x; y = _y; }
	friend complex_base operator-(const complex_base &a, const complex_base &b) { return complex_base(a.x - b.x, a.y - b.y); }
	friend complex_base operator+(const complex_base &a, const complex_base &b) { return complex_base(a.x + b.x, a.y + b.y); }
	friend complex_base operator*(const complex_base &a, const complex_base &b) { return complex_base(a.x * b.x - a.y * b.y, a.y * b.x + b.y * a.x); }
	friend void operator/=(complex_base &a, const double &P) { a.x /= P; a.y /= P; }
};

int bit_rev[MAXN];

void fft(complex_base *a, int lg)
{
	int n = (1 << lg);
	for (int i = 1; i < n; i++)
	{
		bit_rev[i] = (bit_rev[i >> 1] >> 1) | ((i & 1) << (lg - 1));
		if (bit_rev[i] < i) swap(a[i], a[bit_rev[i]]);
	}

	for (int len = 2; len <= n; len <<= 1)
	{
		double ang = 2 * PI / len;
		complex_base w(1, 0), wn(cos(ang), sin(ang));
		for (int j = 0; j < (len >> 1); j++, w = w * wn)
			for (int i = 0; i < n; i += len)
			{
				complex_base u = a[i + j], v = w * a[i + j + (len >> 1)];
				a[i + j] = u + v;
				a[i + j + (len >> 1)] = u - v;
			}
	}
}

void inv_fft(complex_base *a, int lg)
{
	int n = (1 << lg);
	for (int i = 1; i < n; i++)
	{
		bit_rev[i] = (bit_rev[i >> 1] >> 1) | ((i & 1) << (lg - 1));
		if (bit_rev[i] < i) swap(a[i], a[bit_rev[i]]);
	}

	for (int len = 2; len <= n; len <<= 1)
	{
		double ang = -2 * PI / len;
		complex_base w(1, 0), wn(cos(ang), sin(ang));

		for (int j = 0; j < (len >> 1); j++, w = w * wn)
			for (int i = 0; i < n; i += len)
			{
				complex_base u = a[i + j], v = w * a[i + j + (len >> 1)];
				a[i + j] = u + v;
				a[i + j + (len >> 1)] = u - v;
			}
	}

	for (int i = 0; i < n; i++)
		a[i] /= n;
}

complex_base A[MAXN], B[MAXN];

vector<int> mult(vector<int> a, vector<int> b)
{
	// if (a.size() * b.size() <= 256)
	// {
	// 	vector<int> ans(a.size() + b.size(), 0);
	// 	for (int i = 0; i < (int)a.size(); i++)
	// 		for (int j = 0; j < (int)b.size(); j++)
	// 			ans[i + j] += a[i] * b[j];

	// 	return ans;
	// }

	int lg = 0; while ((1 << lg) < (a.size() + b.size())) ++lg;
	for (int i = 0; i < (1 << lg); i++) A[i] = B[i] = complex_base(0, 0);
	for (int i = 0; i < (int)a.size(); i++) A[i] = complex_base(a[i], 0);
	for (int i = 0; i < (int)b.size(); i++) B[i] = complex_base(b[i], 0);

	fft(A, lg); fft(B, lg);
	for (int i = 0; i < (1 << lg); i++)
		A[i] = A[i] * B[i];
	inv_fft(A, lg);

	vector<int> ans(a.size() + b.size(), 0);
	for (int i = 0; i < (int)ans.size(); i++)
		ans[i] = (int)(A[i].x + 0.5);

	return ans;
}

const int BLOCK=64;
const int blocksz=1<<13;
bitset<BLOCK> chunks[2*MAX], chunkt[2*MAX];
vi a, blocks[450];
string s, t;

vi hamming(int l, int r)
{
	vi b;
	int n=s.size(), m=r-l+1;

	FORr(i,r,l)
	{
		if(t[i]=='1') b.pb(1);
		else b.pb(-1);
	}

	// VecPrnt(b);

	vi c=mult(a,b), ret;
	for(int i=0; (i+m)<=n; i++)
		ret.pb(m-(c[i+m-1]+m)/2);

	// VecPrnt(ret);

	return ret;
}

int handle(int sx, int sy, int tx, int ty)
{
	int ret=0, i, j;

	for(i=sx, j=tx; ; i+=BLOCK, j+=BLOCK)
	{
		if(i+BLOCK-1>sy) break;
		bitset<BLOCK> temp=chunks[i]^chunkt[j];
		ret+=temp.count();
	}

	// cout<<i<<" "<<j<<endl;

	if(i<=sy)
	{
		for(int k=i, l=j; k<=sy, l<=ty; k++, l++)
			ret+=(s[k]!=t[l]);
	}

	return ret;
}

int handleBlocks(int sx, int sy, int tx, int l, int r)
{
	int ret=0;
	int pos=sx+l*blocksz-tx;

	// cout<<"start position for s: "<<pos<<endl;

	for(int i=l; i<=r; i++)
	{
		// VecPrnt(blocks[i]);
		if(pos+blocksz-1>sy) break;
		// cout<<"for block "<<i<<" take value from "<<pos<<endl;
		ret+=blocks[i][pos];
		pos+=blocksz;
	}

	return ret;
}

int findAns(int sx, int sy, int tx, int ty)
{
	int ret=0;

	int l=tx/blocksz+1;
	int r=ty/blocksz-1;

	// cout<<l<<" "<<r<<endl;

	if(l+1<r)
	{
		int pos1=sx+l*blocksz-tx;
		int pos2=sy-(ty-(r+1)*blocksz);
		ret=handle(sx,pos1-1,tx,l*blocksz-1);
		// prnt(ret);
		ret+=handle(pos2,sy,(r+1)*blocksz,ty);
		// prnt(ret);
		ret+=handleBlocks(sx,sy,tx,l,r);
		// prnt(ret);
	}
	else
	{
		// Debug;
		ret=handle(sx,sy,tx,ty);
	}

	return ret;
}

void handle()
{
	// Test();
	// cout<<s<<" "<<t<<endl;
	// prnt(handleBlocks(0,6,0,0,2));
	// prnt(findAns(0,s.size()-1,0,t.size()-1));
	int q, x, y, len;
	scanf("%d", &q);

	while(q--)
	{
		scanf("%d%d%d", &x, &y, &len);

		int sx=x, sy=x+len-1;
		int tx=y, ty=y+len-1;

		int out=findAns(sx,sy,tx,ty);
		printf("%d\n", out);
	}
}

void solve()
{
	int m=t.size(), last=0;
	int blockcnt=(m-1)/blocksz;

	// prnt(blocksz);

	for(int i=0; i<m; i+=blocksz)
	{
		blocks[i/blocksz]=hamming(i,min(m-1,i+blocksz-1));
		last=min(i+blocksz-1,m-1);
		// prnt(last);
	}

	if(last!=m-1) blocks[blockcnt]=hamming(last,m-1);

	// Debug;

	for(int i=0; i+BLOCK-1<s.size(); i++)
	{
		for(int j=i; j<=i+BLOCK-1; j++)
		{
			if(s[j]=='1') chunks[i].set(BLOCK-1-j+i);
		}
		// cout<<"chunk from index "<<i<<": "<<chunks[i].to_string()<<endl;
	}

	for(int i=0; i+BLOCK-1<t.size(); i++)
	{
		for(int j=i; j<=i+BLOCK-1; j++)
		{
			if(t[j]=='1') chunkt[i].set(BLOCK-1-j+i);
		}
		// cout<<"chunk from index "<<i<<": "<<chunks[i].to_string()<<endl;
	}

	handle();
}

int main()
{
	// ios_base::sync_with_stdio(0);
	// cin.tie(NULL); cout.tie(NULL);
	// freopen("in.txt","r",stdin);

	int test, cases = 1;

	cin >> s >> t;
	// if (s.size() < t.size()) swap(s, t);

	FOR(i,0,s.size())
	{
		if(s[i]=='1') a.pb(1);
		else a.pb(-1);
	}

	// cout<<s<<" "<<t<<endl;
	// hamming(0,2,4);

	solve();

	return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("popcnt")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 1e6 + 5, LG = 19, MOD = 998244353;
const int SQ =225;
const long double EPS = 1e-7;
using cd = complex<double>;
const double PI = acos(-1);
unsigned long long a[64][3125], b[64][3125];
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  string s1, s2;

  cin >> s1;

  f(i,0,s1.size()){
    if(s1[i] == '1')
        f(j,0,64)
          if(i>=j)
            a[j][(i - j) / 64] |= 1ull << (i - j) % 64;

  }

  cin >> s2;

  f(i,0,s2.size()){
    if(s2[i] == '1')
        f(j,0,64)
          if(i>=j)
            b[j][(i - j) / 64] |= 1ull << (i - j) % 64;

  }

  int q;
  cin >> q;

  while(q--){

    int p1, p2, len;
    cin >> p1 >> p2 >> len;

    int ans = 0;
    f(i,0,len/64)
      ans += __builtin_popcountll(a[p1%64][p1/64+i] ^ b[p2%64][p2/64+i]);
    for(int i = len / 64 * 64; i < len; i++)
      ans += s1[p1+i] ^ s2[p2 + i];
    cout <<ans << '\n';
  }

  return 0;
}


//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("popcnt")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 1e6 + 5, LG = 19, MOD = 998244353;
const int SQ =225;
const long double EPS = 1e-7;
using cd = complex<double>;
const double PI = acos(-1);
unsigned long long a[64][3125], b[64][3125];
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  string s1, s2;

  cin >> s1;

  f(i,0,s1.size()){
    if(s1[i] == '1')
        f(j,0,64)
          if(i>=j)
            a[j][(i - j) / 64] |= 1ull << (i - j) % 64;

  }

  cin >> s2;

  f(i,0,s2.size()){
    if(s2[i] == '1')
        f(j,0,64)
          if(i>=j)
            b[j][(i - j) / 64] |= 1ull << (i - j) % 64;

  }

  int q;
  cin >> q;

  while(q--){

    int p1, p2, len;
    cin >> p1 >> p2 >> len;

    int ans = 0;
    f(i,0,len/64)
      ans += __builtin_popcountll(a[p1%64][p1/64+i] ^ b[p2%64][p2/64+i]);
    for(int i = len / 64 * 64; i < len; i++)
      ans += s1[p1+i] ^ s2[p2 + i];
    cout <<ans << '\n';
  }

  return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 1e6 + 5, LG = 19, MOD = 998244353;
const int SQ =225;
const long double EPS = 1e-7;
using cd = complex<double>;
const double PI = acos(-1);
unsigned long long a[64][3125], b[64][3125];
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  string s1, s2;

  cin >> s1;

  f(i,0,s1.size()){
    if(s1[i] == '1')
        f(j,0,64)
          if(i>=j)
            a[j][(i - j) / 64] |= 1ull << (i - j) % 64;

  }

  cin >> s2;

  f(i,0,s2.size()){
    if(s2[i] == '1')
        f(j,0,64)
          if(i>=j)
            b[j][(i - j) / 64] |= 1ull << (i - j) % 64;

  }

  int q;
  cin >> q;

  while(q--){

    int p1, p2, len;
    cin >> p1 >> p2 >> len;

    int ans = 0;
    f(i,0,len/64)
      ans += __builtin_popcountll(a[p1%64][p1/64+i] ^ b[p2%64][p2/64+i]);
    for(int i = len / 64 * 64; i < len; i++)
      ans += s1[p1+i] ^ s2[p2 + i];
    cout <<ans << '\n';
  }

  return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 1e6 + 5, LG = 19, MOD = 998244353;
const int SQ =225;
const long double EPS = 1e-7;
using cd = complex<double>;
const double PI = acos(-1);
ll a[64][3125], b[64][3125];
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  string s1, s2;

  cin >> s1;

  f(i,0,s1.size()){
    if(s1[i] == '1')
        f(j,0,64)
          if(i>=j)
            a[j][(i - j) / 64] |= 1ull << (i - j) % 64;

  }

  cin >> s2;

  f(i,0,s2.size()){
    if(s2[i] == '1')
        f(j,0,64)
          if(i>=j)
            b[j][(i - j) / 64] |= 1ull << (i - j) % 64;

  }

  int q;
  cin >> q;

  while(q--){

    int p1, p2, len;
    cin >> p1 >> p2 >> len;

    int ans = 0;
    f(i,0,len/64)
      ans += __builtin_popcountll(a[p1%64][p1/64+i] ^ a[p2%64][p2/64+i]);
    for(int i = len / 64 * 64; i < len; i++)
      ans += s1[p1+i] ^ s2[p2 + i];
    cout <<ans << '\n';
  }

  return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 1e6 + 5, LG = 19, MOD = 998244353;
const int SQ =225;
const long double EPS = 1e-7;
using cd = complex<double>;
const double PI = acos(-1);
unsigned long long a[64][3125], b[64][3125];
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  string s1, s2;

  cin >> s1;

  f(i,0,s1.size()){
    if(s1[i] == '1')
        f(j,0,64)
          if(i>=j)
            a[j][(i - j) / 64] |= 1ull << (i - j) % 64;

  }

  cin >> s2;

  f(i,0,s2.size()){
    if(s2[i] == '1')
        f(j,0,64)
          if(i>=j)
            b[j][(i - j) / 64] |= 1ull << (i - j) % 64;

  }

  int q;
  cin >> q;

  while(q--){

    int p1, p2, len;
    cin >> p1 >> p2 >> len;

    int ans = 0;
    f(i,0,len/64)
      ans += __builtin_popcountll(a[p1%64][p1/64+i] ^ a[p2%64][p2/64+i]);
    for(int i = len / 64 * 64; i < len; i++)
      ans += s1[p1+i] ^ s2[p2 + i];
    cout <<ans << '\n';
  }

  return 0;
}


///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

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

ld PI = acos(-1);

struct base {
	ld a, b;
	base(ld _a = 0.0, ld _b = 0.0) : a(_a), b(_b) {}
	const base operator + (const base &c) const
		{ return base(a + c.a, b + c.b); }
	const base operator - (const base &c) const
		{ return base(a - c.a, b - c.b); }
	const base operator * (const base &c) const
		{ return base(a * c.a - b * c.b, a * c.b + b * c.a); }
};

const int N = 1 << 18;
base w_pre[N|1], w[N|1]; int rev[N];

void calcw() {
	for(int i = 0; i <= N; ++i)
		w_pre[i] = base(cos(2*PI/N*i), sin(2*PI/N*i));
}
void calcrev(int n) {
	int sz = 31 - __builtin_clz(n); sz = abs(sz);
	for(int i = 1; i < n - 1; ++i)
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << sz - 1);
}
void fft(base *p, int n, int dir = 0) {
	for(int i = 1; i < n - 1; i++)
		if(i < rev[i]) swap(p[i], p[rev[i]]);
	for(int h = 1; h < n; h <<= 1) { int l = h << 1;
		if(!dir) for(int j = 0; j < h; ++j) w[j] = w_pre[N/l*j];
		else for(int j = 0; j < h; ++j) w[j] = w_pre[N-N/l*j];
		for(int j = 0 ; j < n; j += l) {
			base t, *wn = w;
			base *u = p + j, *v = u + h, *e = v;
			while(u != e) {
				t = *v * *wn;
				*v = *u - t;
				*u = *u + t;
				++u, ++v, ++wn;
			}
		}
	} if(dir) for(int i = 0; i < n; ++i) p[i].a /= n;
}

const int M = 200010;
const int K = 2654;

char a[M], b[M];
base A[N], B[N];
short p[80][M];

int main(int argc, char const *argv[]) {
	scanf("%s", a); scanf("%s", b);
	int n = strlen(a), m = strlen(b), t = m + K - 1, sz = 1;
	while(sz < t) sz <<= 1;

	calcw(); calcrev(sz);

	for(int i = 0; i < m; i++) B[i] = base(b[i] == '0' ? -1 : 1, 0);
	fft(B, sz);

	for(int blc = 0; blc * K < n; blc++) {
		int l = blc * K, r = (blc + 1) * K;
		if(r > n) break;
		for(int i = l; i < r; i++)
			A[i - l] = base(a[r - i + l - 1] == '0' ? -1 : 1, 0);
		for(int i = K; i < sz; i++)
			A[i] = base(0, 0);

		fft(A, sz);
		for(int i = 0; i < sz; i++)
			A[i] = A[i] * B[i];
		fft(A, sz, 1);

		for(int i = 0; i <= m - K; i++)
			p[blc][i] = (K - (int)round(A[i + K - 1].a)) >> 1;
	}

	int Q; scanf("%d", &Q); while(Q--){
		int pa, pb, l; scanf("%d %d %d", &pa, &pb, &l);
		int l1 = pa, r1 = pa + l - 1;
		int l2 = pb, r2 = pb + l - 1;

		int ans = 0;
		int L = l1 / K, R = r1 / K;

		if(L == R) {
			for(int i = l1; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		} else {
			for(int i = l1; i < (L + 1) * K; i++)
				ans += a[i] != b[i - l1 + l2];
			for(int b = L + 1; b < R; b++)
				ans += p[b][b * K - l1 + l2];
			for(int i = R * K; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		}
		printf("%d\n", ans);
	}
}


///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

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

ld PI = acos(-1);

struct base {
	ld a, b;
	base(ld _a = 0.0, ld _b = 0.0) : a(_a), b(_b) {}
	const base operator + (const base &c) const
		{ return base(a + c.a, b + c.b); }
	const base operator - (const base &c) const
		{ return base(a - c.a, b - c.b); }
	const base operator * (const base &c) const
		{ return base(a * c.a - b * c.b, a * c.b + b * c.a); }
};

const int N = 1 << 18;
base w_pre[N|1], w[N|1]; int rev[N];

void calcw() {
	for(int i = 0; i <= N; ++i)
		w_pre[i] = base(cos(2*PI/N*i), sin(2*PI/N*i));
}
void calcrev(int n) {
	int sz = 31 - __builtin_clz(n); sz = abs(sz);
	for(int i = 1; i < n - 1; ++i)
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << sz - 1);
}
void fft(base *p, int n, int dir = 0) {
	for(int i = 1; i < n - 1; i++)
		if(i < rev[i]) swap(p[i], p[rev[i]]);
	for(int h = 1; h < n; h <<= 1) { int l = h << 1;
		if(!dir) for(int j = 0; j < h; ++j) w[j] = w_pre[N/l*j];
		else for(int j = 0; j < h; ++j) w[j] = w_pre[N-N/l*j];
		for(int j = 0 ; j < n; j += l) {
			base t, *wn = w;
			base *u = p + j, *v = u + h, *e = v;
			while(u != e) {
				t = *v * *wn;
				*v = *u - t;
				*u = *u + t;
				++u, ++v, ++wn;
			}
		}
	} if(dir) for(int i = 0; i < n; ++i) p[i].a /= n;
}

const int M = 200010;
const int K = 4000;

char a[M], b[M];
base A[N], B[N];
short p[60][M];

int main(int argc, char const *argv[]) {
	scanf("%s", a); scanf("%s", b);
	int n = strlen(a), m = strlen(b), t = m + K - 1, sz = 1;
	while(sz < t) sz <<= 1;

	calcw(); calcrev(sz);

	for(int i = 0; i < m; i++) B[i] = base(b[i] == '0' ? -1 : 1, 0);
	fft(B, sz);

	for(int blc = 0; blc * K < n; blc++) {
		int l = blc * K, r = (blc + 1) * K;
		if(r > n) break;
		for(int i = l; i < r; i++)
			A[i - l] = base(a[r - i + l - 1] == '0' ? -1 : 1, 0);
		for(int i = K; i < sz; i++)
			A[i] = base(0, 0);

		fft(A, sz);
		for(int i = 0; i < sz; i++)
			A[i] = A[i] * B[i];
		fft(A, sz, 1);

		for(int i = 0; i <= m - K; i++)
			p[blc][i] = (K - (int)round(A[i + K - 1].a)) >> 1;
	}

	int Q; scanf("%d", &Q); while(Q--){
		int pa, pb, l; scanf("%d %d %d", &pa, &pb, &l);
		int l1 = pa, r1 = pa + l - 1;
		int l2 = pb, r2 = pb + l - 1;

		int ans = 0;
		int L = l1 / K, R = r1 / K;

		if(L == R) {
			for(int i = l1; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		} else {
			for(int i = l1; i < (L + 1) * K; i++)
				ans += a[i] != b[i - l1 + l2];
			for(int b = L + 1; b < R; b++)
				ans += p[b][b * K - l1 + l2];
			for(int i = R * K; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		}
		printf("%d\n", ans);
	}
}


///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#include <bits/stdc++.h>
using namespace std;

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

ld PI = acos(-1);

struct base {
	ld a, b;
	base(ld _a = 0.0, ld _b = 0.0) : a(_a), b(_b) {}
	const base operator + (const base &c) const
		{ return base(a + c.a, b + c.b); }
	const base operator - (const base &c) const
		{ return base(a - c.a, b - c.b); }
	const base operator * (const base &c) const
		{ return base(a * c.a - b * c.b, a * c.b + b * c.a); }
};

const int N = 1 << 18;
base w_pre[N|1], w[N|1]; int rev[N];

void calcw() {
	for(int i = 0; i <= N; ++i)
		w_pre[i] = base(cos(2*PI/N*i), sin(2*PI/N*i));
}
void calcrev(int n) {
	int sz = 31 - __builtin_clz(n); sz = abs(sz);
	for(int i = 1; i < n - 1; ++i)
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << sz - 1);
}
void fft(base *p, int n, int dir = 0) {
	for(int i = 1; i < n - 1; i++)
		if(i < rev[i]) swap(p[i], p[rev[i]]);
	for(int h = 1; h < n; h <<= 1) { int l = h << 1;
		if(!dir) for(int j = 0; j < h; ++j) w[j] = w_pre[N/l*j];
		else for(int j = 0; j < h; ++j) w[j] = w_pre[N-N/l*j];
		for(int j = 0 ; j < n; j += l) {
			base t, *wn = w;
			base *u = p + j, *v = u + h, *e = v;
			while(u != e) {
				t = *v * *wn;
				*v = *u - t;
				*u = *u + t;
				++u, ++v, ++wn;
			}
		}
	} if(dir) for(int i = 0; i < n; ++i) p[i].a /= n;
}

const int M = 200010;
const int K = 1800;

char a[M], b[M];
base A[N], B[N];
short p[115][M];

int main(int argc, char const *argv[]) {
	scanf("%s", a); scanf("%s", b);
	int n = strlen(a), m = strlen(b), t = n + K - 1, sz = 1;
	while(sz < t) sz <<= 1;

	calcw(); calcrev(sz);

	for(int i = 0; i < m; i++) B[i] = base(b[i] == '0' ? -1 : 1, 0);
	fft(B, sz);

	for(int blc = 0; blc * K < n; blc++) {
		int l = blc * K, r = (blc + 1) * K;
		if(r > n) break;
		for(int i = l; i < r; i++)
			A[i - l] = base(a[r - i + l - 1] == '0' ? -1 : 1, 0);
		for(int i = K; i < sz; i++)
			A[i] = base(0, 0);

		fft(A, sz);
		for(int i = 0; i < sz; i++)
			A[i] = A[i] * B[i];
		fft(A, sz, 1);

		for(int i = 0; i <= m - K; i++) {
			double y = A[i + K - 1].a;
			int x = y >= 0 ? y + 0.5 : y - 0.5;
			p[blc][i] = (K - x) >> 1;
		}
	}

	int Q; scanf("%d", &Q); while(Q--){
		int pa, pb, l; scanf("%d %d %d", &pa, &pb, &l);
		int l1 = pa, r1 = pa + l - 1;
		int l2 = pb, r2 = pb + l - 1;

		int ans = 0;
		int L = l1 / K, R = r1 / K;

		if(L == R) {
			for(int i = l1; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		} else {
			for(int i = l1; i < (L + 1) * K; i++)
				ans += a[i] != b[i - l1 + l2];
			for(int b = L + 1; b < R; b++)
				ans += p[b][b * K - l1 + l2];
			for(int i = R * K; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		}
		printf("%d\n", ans);
	}
}


///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

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

ld PI = acos(-1);

struct base {
	ld a, b;
	base(ld _a = 0.0, ld _b = 0.0) : a(_a), b(_b) {}
	const base operator + (const base &c) const
		{ return base(a + c.a, b + c.b); }
	const base operator - (const base &c) const
		{ return base(a - c.a, b - c.b); }
	const base operator * (const base &c) const
		{ return base(a * c.a - b * c.b, a * c.b + b * c.a); }
};

const int N = 1 << 18;
base w_pre[N|1], w[N|1]; int rev[N];

void calcw() {
	for(int i = 0; i <= N; ++i)
		w_pre[i] = base(cos(2*PI/N*i), sin(2*PI/N*i));
}
void calcrev(int n) {
	int sz = 31 - __builtin_clz(n); sz = abs(sz);
	for(int i = 1; i < n - 1; ++i)
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << sz - 1);
}
void fft(base *p, int n, int dir = 0) {
	for(int i = 1; i < n - 1; i++)
		if(i < rev[i]) swap(p[i], p[rev[i]]);
	for(int h = 1; h < n; h <<= 1) { int l = h << 1;
		if(!dir) for(int j = 0; j < h; ++j) w[j] = w_pre[N/l*j];
		else for(int j = 0; j < h; ++j) w[j] = w_pre[N-N/l*j];
		for(int j = 0 ; j < n; j += l) {
			base t, *wn = w;
			base *u = p + j, *v = u + h, *e = v;
			while(u != e) {
				t = *v * *wn;
				*v = *u - t;
				*u = *u + t;
				++u, ++v, ++wn;
			}
		}
	} if(dir) for(int i = 0; i < n; ++i) p[i].a /= n;
}

const int M = 200010;
const int K = 9000;

char a[M], b[M];
base A[N], B[N];
short p[60][M];

int main(int argc, char const *argv[]) {
	scanf("%s", a); scanf("%s", b);
	int n = strlen(a), m = strlen(b), t = m + K - 1, sz = 1;
	while(sz < t) sz <<= 1;

	calcw(); calcrev(sz);

	for(int i = 0; i < m; i++) B[i] = base(b[i] == '0' ? -1 : 1, 0);
	fft(B, sz);

	for(int blc = 0; blc * K < n; blc++) {
		int l = blc * K, r = (blc + 1) * K;
		if(r > n) break;
		for(int i = l; i < r; i++)
			A[i - l] = base(a[r - i + l - 1] == '0' ? -1 : 1, 0);
		for(int i = K; i < sz; i++)
			A[i] = base(0, 0);

		fft(A, sz);
		for(int i = 0; i < sz; i++)
			A[i] = A[i] * B[i];
		fft(A, sz, 1);

		for(int i = 0; i <= m - K; i++)
			p[blc][i] = (K - (int)round(A[i + K - 1].a)) >> 1;
	}

	int Q; scanf("%d", &Q); while(Q--){
		int pa, pb, l; scanf("%d %d %d", &pa, &pb, &l);
		int l1 = pa, r1 = pa + l - 1;
		int l2 = pb, r2 = pb + l - 1;

		int ans = 0;
		int L = l1 / K, R = r1 / K;

		if(L == R) {
			for(int i = l1; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		} else {
			for(int i = l1; i < (L + 1) * K; i++)
				ans += a[i] != b[i - l1 + l2];
			for(int b = L + 1; b < R; b++)
				ans += p[b][b * K - l1 + l2];
			for(int i = R * K; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		}
		printf("%d\n", ans);
	}
}


///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

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

ld PI = acos(-1);

struct base {
	ld a, b;
	base(ld _a = 0.0, ld _b = 0.0) : a(_a), b(_b) {}
	const base operator + (const base &c) const
		{ return base(a + c.a, b + c.b); }
	const base operator - (const base &c) const
		{ return base(a - c.a, b - c.b); }
	const base operator * (const base &c) const
		{ return base(a * c.a - b * c.b, a * c.b + b * c.a); }
};

const int N = 1 << 18;
base w_pre[N|1], w[N|1]; int rev[N];

void calcw() {
	for(int i = 0; i <= N; ++i)
		w_pre[i] = base(cos(2*PI/N*i), sin(2*PI/N*i));
}
void calcrev(int n) {
	int sz = 31 - __builtin_clz(n); sz = abs(sz);
	for(int i = 1; i < n - 1; ++i)
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << sz - 1);
}
void fft(base *p, int n, int dir = 0) {
	for(int i = 1; i < n - 1; i++)
		if(i < rev[i]) swap(p[i], p[rev[i]]);
	for(int h = 1; h < n; h <<= 1) { int l = h << 1;
		if(!dir) for(int j = 0; j < h; ++j) w[j] = w_pre[N/l*j];
		else for(int j = 0; j < h; ++j) w[j] = w_pre[N-N/l*j];
		for(int j = 0 ; j < n; j += l) {
			base t, *wn = w;
			base *u = p + j, *v = u + h, *e = v;
			while(u != e) {
				t = *v * *wn;
				*v = *u - t;
				*u = *u + t;
				++u, ++v, ++wn;
			}
		}
	} if(dir) for(int i = 0; i < n; ++i) p[i].a /= n;
}

const int M = 200010;
const int K = 8000;

char a[M], b[M];
base A[N], B[N];
short p[60][M];

int main(int argc, char const *argv[]) {
	scanf("%s", a); scanf("%s", b);
	int n = strlen(a), m = strlen(b), t = m + K - 1, sz = 1;
	while(sz < t) sz <<= 1;

	calcw(); calcrev(sz);

	for(int i = 0; i < m; i++) B[i] = base(b[i] == '0' ? -1 : 1, 0);
	fft(B, sz);

	for(int blc = 0; blc * K < n; blc++) {
		int l = blc * K, r = (blc + 1) * K;
		if(r > n) break;
		for(int i = l; i < r; i++)
			A[i - l] = base(a[r - i + l - 1] == '0' ? -1 : 1, 0);
		for(int i = K; i < sz; i++)
			A[i] = base(0, 0);

		fft(A, sz);
		for(int i = 0; i < sz; i++)
			A[i] = A[i] * B[i];
		fft(A, sz, 1);

		for(int i = 0; i <= m - K; i++)
			p[blc][i] = (K - (int)round(A[i + K - 1].a)) >> 1;
	}

	int Q; scanf("%d", &Q); while(Q--){
		int pa, pb, l; scanf("%d %d %d", &pa, &pb, &l);
		int l1 = pa, r1 = pa + l - 1;
		int l2 = pb, r2 = pb + l - 1;

		int ans = 0;
		int L = l1 / K, R = r1 / K;

		if(L == R) {
			for(int i = l1; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		} else {
			for(int i = l1; i < (L + 1) * K; i++)
				ans += a[i] != b[i - l1 + l2];
			for(int b = L + 1; b < R; b++)
				ans += p[b][b * K - l1 + l2];
			for(int i = R * K; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		}
		printf("%d\n", ans);
	}
}


///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

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

ld PI = acos(-1);

struct base {
	ld a, b;
	base(ld _a = 0.0, ld _b = 0.0) : a(_a), b(_b) {}
	const base operator + (const base &c) const
		{ return base(a + c.a, b + c.b); }
	const base operator - (const base &c) const
		{ return base(a - c.a, b - c.b); }
	const base operator * (const base &c) const
		{ return base(a * c.a - b * c.b, a * c.b + b * c.a); }
};

const int N = 1 << 18;
base w_pre[N|1], w[N|1]; int rev[N];

void calcw() {
	for(int i = 0; i <= N; ++i)
		w_pre[i] = base(cos(2*PI/N*i), sin(2*PI/N*i));
}
void calcrev(int n) {
	int sz = 31 - __builtin_clz(n); sz = abs(sz);
	for(int i = 1; i < n - 1; ++i)
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << sz - 1);
}
void fft(base *p, int n, int dir = 0) {
	for(int i = 1; i < n - 1; i++)
		if(i < rev[i]) swap(p[i], p[rev[i]]);
	for(int h = 1; h < n; h <<= 1) { int l = h << 1;
		if(!dir) for(int j = 0; j < h; ++j) w[j] = w_pre[N/l*j];
		else for(int j = 0; j < h; ++j) w[j] = w_pre[N-N/l*j];
		for(int j = 0 ; j < n; j += l) {
			base t, *wn = w;
			base *u = p + j, *v = u + h, *e = v;
			while(u != e) {
				t = *v * *wn;
				*v = *u - t;
				*u = *u + t;
				++u, ++v, ++wn;
			}
		}
	} if(dir) for(int i = 0; i < n; ++i) p[i].a /= n;
}

const int M = 200010;
const int K = 10000;

char a[M], b[M];
base A[N], B[N];
short p[30][M];

int main(int argc, char const *argv[]) {
	scanf("%s", a); scanf("%s", b);
	int n = strlen(a), m = strlen(b), t = m + K - 1, sz = 1;
	while(sz < t) sz <<= 1;

	calcw(); calcrev(sz);

	for(int i = 0; i < m; i++) B[i] = base(b[i] == '0' ? -1 : 1, 0);
	fft(B, sz);

	for(int blc = 0; blc * K < n; blc++) {
		int l = blc * K, r = (blc + 1) * K;
		if(r > n) break;
		for(int i = l; i < r; i++)
			A[i - l] = base(a[r - i + l - 1] == '0' ? -1 : 1, 0);
		for(int i = K; i < sz; i++)
			A[i] = base(0, 0);

		fft(A, sz);
		for(int i = 0; i < sz; i++)
			A[i] = A[i] * B[i];
		fft(A, sz, 1);

		for(int i = 0; i <= m - K; i++)
			p[blc][i] = (K - (int)round(A[i + K - 1].a)) >> 1;
	}

	int Q; scanf("%d", &Q); while(Q--){
		int pa, pb, l; scanf("%d %d %d", &pa, &pb, &l);
		int l1 = pa, r1 = pa + l - 1;
		int l2 = pb, r2 = pb + l - 1;

		int ans = 0;
		int L = l1 / K, R = r1 / K;

		if(L == R) {
			for(int i = l1; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		} else {
			for(int i = l1; i < (L + 1) * K; i++)
				ans += a[i] != b[i - l1 + l2];
			for(int b = L + 1; b < R; b++)
				ans += p[b][b * K - l1 + l2];
			for(int i = R * K; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		}
		printf("%d\n", ans);
	}
}


///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#include <bits/stdc++.h>
using namespace std;

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

ld PI = acos(-1);

struct base {
	ld a, b;
	base(ld _a = 0.0, ld _b = 0.0) : a(_a), b(_b) {}
	const base operator + (const base &c) const
		{ return base(a + c.a, b + c.b); }
	const base operator - (const base &c) const
		{ return base(a - c.a, b - c.b); }
	const base operator * (const base &c) const
		{ return base(a * c.a - b * c.b, a * c.b + b * c.a); }
};

const int N = 1 << 18;
base w_pre[N|1], w[N|1]; int rev[N];

void calcw() {
	for(int i = 0; i <= N; ++i)
		w_pre[i] = base(cos(2*PI/N*i), sin(2*PI/N*i));
}
void calcrev(int n) {
	int sz = 31 - __builtin_clz(n); sz = abs(sz);
	for(int i = 1; i < n - 1; ++i)
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << sz - 1);
}
void fft(base *p, int n, int dir = 0) {
	for(int i = 1; i < n - 1; i++)
		if(i < rev[i]) swap(p[i], p[rev[i]]);
	for(int h = 1; h < n; h <<= 1) { int l = h << 1;
		if(!dir) for(int j = 0; j < h; ++j) w[j] = w_pre[N/l*j];
		else for(int j = 0; j < h; ++j) w[j] = w_pre[N-N/l*j];
		for(int j = 0 ; j < n; j += l) {
			base t, *wn = w;
			base *u = p + j, *v = u + h, *e = v;
			while(u != e) {
				t = *v * *wn;
				*v = *u - t;
				*u = *u + t;
				++u, ++v, ++wn;
			}
		}
	} if(dir) for(int i = 0; i < n; ++i) p[i].a /= n;
}

const int M = 200010;
const int K = 800;

char a[M], b[M];
base A[N], B[N];
short p[K][M];

int main(int argc, char const *argv[]) {
	scanf("%s", a); scanf("%s", b);
	int n = strlen(a), m = strlen(b), t = n + K - 1, sz = 1;
	while(sz < t) sz <<= 1;

	calcw(); calcrev(sz);

	for(int i = 0; i < m; i++) B[i] = base(b[i] == '0' ? -1 : 1, 0);
	fft(B, sz);

	for(int blc = 0; blc * K < n; blc++) {
		int l = blc * K, r = (blc + 1) * K;
		if(r > n) break;
		for(int i = l; i < r; i++)
			A[i - l] = base(a[r - i + l - 1] == '0' ? -1 : 1, 0);
		for(int i = K; i < sz; i++)
			A[i] = base(0, 0);

		fft(A, sz);
		for(int i = 0; i < sz; i++)
			A[i] = A[i] * B[i];
		fft(A, sz, 1);

		for(int i = 0; i <= m - K; i++) {
			double y = A[i + K - 1].a;
			int x = y >= 0 ? y + 0.5 : y - 0.5;
			p[blc][i] = (K - x) >> 1;
		}
	}

	int Q; scanf("%d", &Q); while(Q--){
		int pa, pb, l; scanf("%d %d %d", &pa, &pb, &l);
		int l1 = pa, r1 = pa + l - 1;
		int l2 = pb, r2 = pb + l - 1;

		int ans = 0;
		int L = l1 / K, R = r1 / K;

		if(L == R) {
			for(int i = l1; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		} else {
			for(int i = l1; i < (L + 1) * K; i++)
				ans += a[i] != b[i - l1 + l2];
			for(int b = L + 1; b < R; b++)
				ans += p[b][b * K - l1 + l2];
			for(int i = R * K; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		}
		printf("%d\n", ans);
	}
}


///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#include <bits/stdc++.h>
using namespace std;

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

ld PI = acos(-1);

struct base {
	ld a, b;
	base(ld _a = 0.0, ld _b = 0.0) : a(_a), b(_b) {}
	const base operator + (const base &c) const
		{ return base(a + c.a, b + c.b); }
	const base operator - (const base &c) const
		{ return base(a - c.a, b - c.b); }
	const base operator * (const base &c) const
		{ return base(a * c.a - b * c.b, a * c.b + b * c.a); }
};

const int N = 1 << 18;
base w_pre[N|1], w[N|1]; int rev[N];

void calcw() {
	for(int i = 0; i <= N; ++i)
		w_pre[i] = base(cos(2*PI/N*i), sin(2*PI/N*i));
}
void calcrev(int n) {
	int sz = 31 - __builtin_clz(n); sz = abs(sz);
	for(int i = 1; i < n - 1; ++i)
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << sz - 1);
}
void fft(base *p, int n, int dir = 0) {
	for(int i = 1; i < n - 1; i++)
		if(i < rev[i]) swap(p[i], p[rev[i]]);
	for(int h = 1; h < n; h <<= 1) { int l = h << 1;
		if(!dir) for(int j = 0; j < h; ++j) w[j] = w_pre[N/l*j];
		else for(int j = 0; j < h; ++j) w[j] = w_pre[N-N/l*j];
		for(int j = 0 ; j < n; j += l) {
			base t, *wn = w;
			base *u = p + j, *v = u + h, *e = v;
			while(u != e) {
				t = *v * *wn;
				*v = *u - t;
				*u = *u + t;
				++u, ++v, ++wn;
			}
		}
	} if(dir) for(int i = 0; i < n; ++i) p[i].a /= n;
}

const int M = 200010;
const int K = 450;

char a[M], b[M];
base A[N], B[N], C[N];
int p[K][M];

int main(int argc, char const *argv[]) {
	scanf("%s", a); scanf("%s", b);
	int n = strlen(a), m = strlen(b), t = n + m - 1, sz = 1;
	while(sz < t) sz <<= 1;

	calcw(); calcrev(sz);

	for(int i = 0; i < m; i++) B[i] = base(b[i] == '0' ? -1 : 1, 0);
	fft(B, sz);

	for(int blc = 0; blc * K < n; blc++) {
		int l = blc * K, r = (blc + 1) * K;
		if(r > n) break;
		for(int i = l; i < r; i++)
			A[i - l] = base(a[r - i + l - 1] == '0' ? -1 : 1, 0);
		for(int i = K; i < sz; i++)
			A[i] = base(0, 0);

		fft(A, sz);
		for(int i = 0; i < sz; i++)
			C[i] = A[i] * B[i];
		fft(C, sz, 1);

		for(int i = 0; i <= m - K; i++) {
			double y = C[i + K - 1].a;
			int x = y >= 0 ? y + 0.5 : y - 0.5;
			p[blc][i] = (K - x) >> 1;
		}
	}

	int Q; scanf("%d", &Q); while(Q--){
		int pa, pb, l; scanf("%d %d %d", &pa, &pb, &l);
		int l1 = pa, r1 = pa + l - 1;
		int l2 = pb, r2 = pb + l - 1;

		int ans = 0;
		int L = l1 / K, R = r1 / K;

		if(L == R) {
			for(int i = l1; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		} else {
			for(int i = l1; i < (L + 1) * K; i++)
				ans += a[i] != b[i - l1 + l2];
			for(int b = L + 1; b < R; b++)
				ans += p[b][b * K - l1 + l2];
			for(int i = R * K; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		}
		printf("%d\n", ans);
	}
}


///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#include <bits/stdc++.h>
using namespace std;

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

ld PI = acos(-1);

struct base {
	ld a, b;
	base(ld _a = 0.0, ld _b = 0.0) : a(_a), b(_b) {}
	const base operator + (const base &c) const
		{ return base(a + c.a, b + c.b); }
	const base operator - (const base &c) const
		{ return base(a - c.a, b - c.b); }
	const base operator * (const base &c) const
		{ return base(a * c.a - b * c.b, a * c.b + b * c.a); }
};

const int N = 1 << 18;
base w_pre[N|1], w[N|1]; int rev[N];

void calcw() {
	for(int i = 0; i <= N; ++i)
		w_pre[i] = base(cos(2*PI/N*i), sin(2*PI/N*i));
}
void calcrev(int n) {
	int sz = 31 - __builtin_clz(n); sz = abs(sz);
	for(int i = 1; i < n - 1; ++i)
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << sz - 1);
}
void fft(base *p, int n, int dir = 0) {
	for(int i = 1; i < n - 1; i++)
		if(i < rev[i]) swap(p[i], p[rev[i]]);
	for(int h = 1; h < n; h <<= 1) { int l = h << 1;
		if(!dir) for(int j = 0; j < h; ++j) w[j] = w_pre[N/l*j];
		else for(int j = 0; j < h; ++j) w[j] = w_pre[N-N/l*j];
		for(int j = 0 ; j < n; j += l) {
			base t, *wn = w;
			base *u = p + j, *v = u + h, *e = v;
			while(u != e) {
				t = *v * *wn;
				*v = *u - t;
				*u = *u + t;
				++u, ++v, ++wn;
			}
		}
	} if(dir) for(int i = 0; i < n; ++i) p[i].a /= n;
}

const int M = 200010;
const int K = 450;

char a[M], b[M];
base A[N], B[N];
short p[K][M];

int main(int argc, char const *argv[]) {
	scanf("%s", a); scanf("%s", b);
	int n = strlen(a), m = strlen(b), t = n + K - 1, sz = 1;
	while(sz < t) sz <<= 1;

	calcw(); calcrev(sz);

	for(int i = 0; i < m; i++) B[i] = base(b[i] == '0' ? -1 : 1, 0);
	fft(B, sz);

	for(int blc = 0; blc * K < n; blc++) {
		int l = blc * K, r = (blc + 1) * K;
		if(r > n) break;
		for(int i = l; i < r; i++)
			A[i - l] = base(a[r - i + l - 1] == '0' ? -1 : 1, 0);
		for(int i = K; i < sz; i++)
			A[i] = base(0, 0);

		fft(A, sz);
		for(int i = 0; i < sz; i++)
			A[i] = A[i] * B[i];
		fft(A, sz, 1);

		for(int i = 0; i <= m - K; i++) {
			double y = A[i + K - 1].a;
			int x = y >= 0 ? y + 0.5 : y - 0.5;
			p[blc][i] = (K - x) >> 1;
		}
	}

	int Q; scanf("%d", &Q); while(Q--){
		int pa, pb, l; scanf("%d %d %d", &pa, &pb, &l);
		int l1 = pa, r1 = pa + l - 1;
		int l2 = pb, r2 = pb + l - 1;

		int ans = 0;
		int L = l1 / K, R = r1 / K;

		if(L == R) {
			for(int i = l1; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		} else {
			for(int i = l1; i < (L + 1) * K; i++)
				ans += a[i] != b[i - l1 + l2];
			for(int b = L + 1; b < R; b++)
				ans += p[b][b * K - l1 + l2];
			for(int i = R * K; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		}
		printf("%d\n", ans);
	}
}


///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#include <bits/stdc++.h>
using namespace std;

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

ld PI = acos(-1);

struct base {
	ld a, b;
	base(ld _a = 0.0, ld _b = 0.0) : a(_a), b(_b) {}
	const base operator + (const base &c) const
		{ return base(a + c.a, b + c.b); }
	const base operator - (const base &c) const
		{ return base(a - c.a, b - c.b); }
	const base operator * (const base &c) const
		{ return base(a * c.a - b * c.b, a * c.b + b * c.a); }
};

const int N = 1 << 18;
base w_pre[N|1], w[N|1]; int rev[N];

void calcw() {
	for(int i = 0; i <= N; ++i)
		w_pre[i] = base(cos(2*PI/N*i), sin(2*PI/N*i));
}
void calcrev(int n) {
	int sz = 31 - __builtin_clz(n); sz = abs(sz);
	for(int i = 1; i < n - 1; ++i)
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << sz - 1);
}
void fft(base *p, int n, int dir = 0) {
	for(int i = 1; i < n - 1; i++)
		if(i < rev[i]) swap(p[i], p[rev[i]]);
	for(int h = 1; h < n; h <<= 1) { int l = h << 1;
		if(!dir) for(int j = 0; j < h; ++j) w[j] = w_pre[N/l*j];
		else for(int j = 0; j < h; ++j) w[j] = w_pre[N-N/l*j];
		for(int j = 0 ; j < n; j += l) {
			base t, *wn = w;
			base *u = p + j, *v = u + h, *e = v;
			while(u != e) {
				t = *v * *wn;
				*v = *u - t;
				*u = *u + t;
				++u, ++v, ++wn;
			}
		}
	} if(dir) for(int i = 0; i < n; ++i) p[i].a /= n;
}

const int M = 200010;
const int K = 1800;

char a[M], b[M];
base A[N], B[N];
short p[115][M];

int main(int argc, char const *argv[]) {
	scanf("%s", a); scanf("%s", b);
	int n = strlen(a), m = strlen(b), t = m + K - 1, sz = 1;
	while(sz < t) sz <<= 1;

	calcw(); calcrev(sz);

	for(int i = 0; i < m; i++) B[i] = base(b[i] == '0' ? -1 : 1, 0);
	fft(B, sz);

	for(int blc = 0; blc * K < n; blc++) {
		int l = blc * K, r = (blc + 1) * K;
		if(r > n) break;
		for(int i = l; i < r; i++)
			A[i - l] = base(a[r - i + l - 1] == '0' ? -1 : 1, 0);
		for(int i = K; i < sz; i++)
			A[i] = base(0, 0);

		fft(A, sz);
		for(int i = 0; i < sz; i++)
			A[i] = A[i] * B[i];
		fft(A, sz, 1);

		for(int i = 0; i <= m - K; i++)
			p[blc][i] = (K - (int)round(A[i + K - 1].a)) >> 1;
	}

	int Q; scanf("%d", &Q); while(Q--){
		int pa, pb, l; scanf("%d %d %d", &pa, &pb, &l);
		int l1 = pa, r1 = pa + l - 1;
		int l2 = pb, r2 = pb + l - 1;

		int ans = 0;
		int L = l1 / K, R = r1 / K;

		if(L == R) {
			for(int i = l1; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		} else {
			for(int i = l1; i < (L + 1) * K; i++)
				ans += a[i] != b[i - l1 + l2];
			for(int b = L + 1; b < R; b++)
				ans += p[b][b * K - l1 + l2];
			for(int i = R * K; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		}
		printf("%d\n", ans);
	}
}


///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#include <bits/stdc++.h>
using namespace std;

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

ld PI = acos(-1);

struct base {
	ld a, b;
	base(ld _a = 0.0, ld _b = 0.0) : a(_a), b(_b) {}
	const base operator + (const base &c) const
		{ return base(a + c.a, b + c.b); }
	const base operator - (const base &c) const
		{ return base(a - c.a, b - c.b); }
	const base operator * (const base &c) const
		{ return base(a * c.a - b * c.b, a * c.b + b * c.a); }
};

const int N = 1 << 18;
base w_pre[N|1], w[N|1]; int rev[N];

void calcw() {
	for(int i = 0; i <= N; ++i)
		w_pre[i] = base(cos(2*PI/N*i), sin(2*PI/N*i));
}
void calcrev(int n) {
	int sz = 31 - __builtin_clz(n); sz = abs(sz);
	for(int i = 1; i < n - 1; ++i)
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << sz - 1);
}
void fft(base *p, int n, int dir = 0) {
	for(int i = 1; i < n - 1; i++)
		if(i < rev[i]) swap(p[i], p[rev[i]]);
	for(int h = 1; h < n; h <<= 1) { int l = h << 1;
		if(!dir) for(int j = 0; j < h; ++j) w[j] = w_pre[N/l*j];
		else for(int j = 0; j < h; ++j) w[j] = w_pre[N-N/l*j];
		for(int j = 0 ; j < n; j += l) {
			base t, *wn = w;
			base *u = p + j, *v = u + h, *e = v;
			while(u != e) {
				t = *v * *wn;
				*v = *u - t;
				*u = *u + t;
				++u, ++v, ++wn;
			}
		}
	} if(dir) for(int i = 0; i < n; ++i) p[i].a /= n;
}

const int M = 200010;
const int K = 1800;

char a[M], b[M];
base A[N], B[N];
short p[K][M];

int main(int argc, char const *argv[]) {
	scanf("%s", a); scanf("%s", b);
	int n = strlen(a), m = strlen(b), t = n + K - 1, sz = 1;
	while(sz < t) sz <<= 1;

	calcw(); calcrev(sz);

	for(int i = 0; i < m; i++) B[i] = base(b[i] == '0' ? -1 : 1, 0);
	fft(B, sz);

	for(int blc = 0; blc * K < n; blc++) {
		int l = blc * K, r = (blc + 1) * K;
		if(r > n) break;
		for(int i = l; i < r; i++)
			A[i - l] = base(a[r - i + l - 1] == '0' ? -1 : 1, 0);
		for(int i = K; i < sz; i++)
			A[i] = base(0, 0);

		fft(A, sz);
		for(int i = 0; i < sz; i++)
			A[i] = A[i] * B[i];
		fft(A, sz, 1);

		for(int i = 0; i <= m - K; i++) {
			double y = A[i + K - 1].a;
			int x = y >= 0 ? y + 0.5 : y - 0.5;
			p[blc][i] = (K - x) >> 1;
		}
	}

	int Q; scanf("%d", &Q); while(Q--){
		int pa, pb, l; scanf("%d %d %d", &pa, &pb, &l);
		int l1 = pa, r1 = pa + l - 1;
		int l2 = pb, r2 = pb + l - 1;

		int ans = 0;
		int L = l1 / K, R = r1 / K;

		if(L == R) {
			for(int i = l1; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		} else {
			for(int i = l1; i < (L + 1) * K; i++)
				ans += a[i] != b[i - l1 + l2];
			for(int b = L + 1; b < R; b++)
				ans += p[b][b * K - l1 + l2];
			for(int i = R * K; i <= r1; i++)
				ans += a[i] != b[i - l1 + l2];
		}
		printf("%d\n", ans);
	}
}