Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed:

set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and  $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$.  
set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and  $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$.  
get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$.  

Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output.  For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$.  Print an answer string that contains the results of all commands on one line.  A series of commands and their results follow:

Starting 

ans = '' (empty string) 

a   b 

000 111 

set_a 1 1 

010 111 

set_b 0 1 

010 111 

get_c 3 

a + b = 1001 

ans = '1' 

010 111 

get_c 4 

a + b = 01001 

ans = '10' 

Note: When the command is get_c 4, $\textbf{C}$  had to be padded to the left with a $0$ to be long enough to return a value.  

Function Description  

Complete the changeBits function in the editor below.  For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline.   

changeBits has the following parameters: 

- a, b: two integers represented as binary strings 

- queries[queries[0]-queries[n-1]]: an array of query strings in the format described  

Input Format

The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. 

The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. 

The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above.  

Constraints

$1\leq n\leq1000000$ 

$1\leq q\leq5000000$  

Output Format

For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line.

Sample Input 0
5 5
00000
11111
set_a 0 1
get_c 5
get_c 1
set_b 2 0
get_c 5

Sample Output 0
100

Explanation 0

set_a 0 1 sets 00000 to 00001
C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1
from the above computation get_c[1] = 0
set_b 2 0 sets 11111 to 11011
C = A + B = 00001 + 11011 = 011100, so get_c[5]  = 0

The output is hence concatenation of 1, 0 and 0  = 100

Difficulty: HARD

Solutions:
(n_bit, line_count) = [int(i) for i in input().split()]
a = int(input(), 2)
b = int(input(), 2)
for i in range(line_count):
	inp = input().split()
	x = int(inp[1])
	if inp[0] == 'get_c':
		print((a + b & 1 << x) >> x, end='')
	elif inp[0] == 'set_a':
		if inp[2] == '1':
			a = a | 1 << x
		else:
			a = a & ~(1 << x)
	elif inp[2] == '1':
		b = b | 1 << x
	else:
		b = b & ~(1 << x)


import sys

def set_bit(n, i, val):
	part = 1 << i
	if int(val) == 1:
		return n | part
	elif n & part > 0:
		return n - part
	else:
		return n
(len_a, len_b) = (int(i) for i in input().split())
a = int(input(), 2)
b = int(input(), 2)
for line in sys.stdin:
	parts = line.split()
	if parts[0] == 'set_a':
		a = set_bit(a, int(parts[1]), int(parts[2]))
	elif parts[0] == 'set_b':
		b = set_bit(b, int(parts[1]), int(parts[2]))
	else:
		i = int(parts[1])
		print('1' if a + b & 1 << i else '0', end='')


(N, Q) = input().strip().split()
(N, Q) = (int(N), int(Q))
A = int(input().strip(), 2)
B = int(input().strip(), 2)
for q in range(Q):
	qu = input().strip().split()
	if qu[0] == 'set_a':
		if qu[2] == '0':
			A = A & ~(1 << int(qu[1]))
		elif qu[2] == '1':
			A = A | 1 << int(qu[1])
	elif qu[0] == 'set_b':
		if qu[2] == '0':
			B = B & ~(1 << int(qu[1]))
		elif qu[2] == '1':
			B = B | 1 << int(qu[1])
	elif qu[0] == 'get_c':
		if A + B & 1 << int(qu[1]) == 0:
			print(0, end='')
		else:
			print(1, end='')


raw = input().split()
n = int(raw[0])
q = int(raw[1])
a = int(input(), 2)
b = int(input(), 2)
c = a + b
for i in range(q):
	qraw = input().split()
	if qraw[0] == 'set_a':
		idx = int(qraw[1])
		x = int(qraw[2])
		if a >> idx & 1 != x:
			if x == 1:
				a = a | 1 << idx
			else:
				a = a & ~(1 << idx)
		c = a + b
	elif qraw[0] == 'set_b':
		idx = int(qraw[1])
		x = int(qraw[2])
		if b >> idx & 1 != x:
			if x == 1:
				b = b | 1 << idx
			else:
				b = b & ~(1 << idx)
		c = a + b
	else:
		idx = int(qraw[1])
		d = c >> idx & 1
		print(d, end='')


(N, Q) = [int(x) for x in input().strip().split(' ')]
A = int(input(), 2)
B = int(input(), 2)
s = ''
for q in range(0, Q):
	a = input().split(' ')
	if a[0] == 'set_a':
		mask = 1 << int(a[1])
		if a[2] == '1':
			A |= mask
		else:
			A &= ~mask
	elif a[0] == 'set_b':
		mask = 1 << int(a[1])
		if a[2] == '1':
			B |= mask
		else:
			B &= ~mask
	else:
		mask = 1 << int(a[1])
		if A + B & mask:
			s += '1'
		else:
			s += '0'
print(s)


def set_bit(n, i, x):
	if x == 1:
		return n | 1 << i
	else:
		return n & ~(1 << i)

def get_bit(n, i):
	return (n >> i) - (n >> i + 1 << 1)
(_, q) = map(int, input().split(' '))
a = int(input(), 2)
b = int(input(), 2)
set_a = lambda i, x: set_bit(a, i, x)
set_b = lambda i, x: set_bit(b, i, x)
get_c = lambda i: print(get_bit(a + b, i), end='')
for _ in range(q):
	(action, *args) = input().split(' ')
	if action[0] == 's' and action[4] == 'a':
		a = set_a(int(args[0]), int(args[1]))
	elif action[0] == 's' and action[4] == 'b':
		b = set_b(int(args[0]), int(args[1]))
	elif action[0] == 'g':
		get_c(int(args[0]))


def set_bit(n, offset):
	mask = 1 << offset
	return n | mask

def clear_bit(n, offset):
	mask = ~(1 << offset)
	return n & mask

def get_bit(n, i):
	mask = 1 << i
	return 1 if n & mask else 0
line = input('').split(' ')
(N, Q) = (int(line[0]), int(line[1]))
A = int(input(''), 2)
B = int(input(''), 2)
output = []
for __ in range(Q):
	line = input('').split(' ')
	if line[0] == 'set_a':
		(idx, x) = (int(line[1]), int(line[2]))
		A = set_bit(A, idx) if x else clear_bit(A, idx)
	elif line[0] == 'set_b':
		(idx, x) = (int(line[1]), int(line[2]))
		B = set_bit(B, idx) if x else clear_bit(B, idx)
	else:
		idx = int(line[1])
		output.append(get_bit(A + B, idx))
print(''.join((str(b) for b in output)))


import sys
n = [int(number) for number in input().split()]
a = int(input(), 2)
b = int(input(), 2)
for i in range(n[1]):
	query = input().split()
	if query[0] == 'set_a':
		if query[2] == '0':
			a &= ~(1 << int(query[1]))
		elif query[2] == '1':
			a |= 1 << int(query[1])
	elif query[0] == 'set_b':
		if query[2] == '0':
			b &= ~(1 << int(query[1]))
		elif query[2] == '1':
			b |= 1 << int(query[1])
	elif query[0] == 'get_c':
		x = a + b & 1 << int(query[1])
		print(x >> int(query[1]), end='', sep='')


import collections
(_, _, q) = input().partition(' ')
a = int(input(), 2)
b = int(input(), 2)
toR = collections.deque()
for _ in range(int(q)):
	(cmd, *params) = input().split()
	if cmd[4] == 'a':
		(idx, x) = params
		if x == '1':
			a |= 1 << int(idx)
		else:
			a &= ~(1 << int(idx))
	elif cmd[4] == 'b':
		(idx, x) = params
		if x == '1':
			b |= 1 << int(idx)
		else:
			b &= ~(1 << int(idx))
	elif cmd[4] == 'c':
		(idx,) = params
		toR.append('1' if a + b & 1 << int(idx) else '0')
print(''.join(toR))


def getBit(num, offset):
	mask = 1 << offset
	return 1 if num & mask != 0 else 0

def setBit(num, offset, value):
	if value == 1:
		mask = 1 << offset
		return num | mask
	else:
		mask = ~(1 << offset)
		return num & mask
(n, q) = [int(x) for x in input().split()]
a = int(input(), 2)
b = int(input(), 2)
for _ in range(q):
	query = input().split()
	if query[0] == 'set_a':
		a = setBit(a, int(query[1]), int(query[2]))
	elif query[0] == 'set_b':
		b = setBit(b, int(query[1]), int(query[2]))
	else:
		print(getBit(a + b, int(query[1])), end='')


def getBit(num, offset):
	mask = 1 << offset
	return 1 if num & mask != 0 else 0

def setBit(num, offset, value):
	if value == 1:
		mask = 1 << offset
		return num | mask
	else:
		mask = ~(1 << offset)
		return num & mask
(n, q) = [int(x) for x in input().split()]
a = int(input(), 2)
b = int(input(), 2)
for _ in range(q):
	query = input().split()
	if query[0] == 'set_a':
		a = setBit(a, int(query[1]), int(query[2]))
	elif query[0] == 'set_b':
		b = setBit(b, int(query[1]), int(query[2]))
	else:
		print(getBit(a + b, int(query[1])), end='')


import sys
(n, q) = list(map(int, input().split()))
a = input()
b = input()
c = int(a, 2) + int(b, 2)
a = list(reversed(a))
b = list(reversed(b))
for i in range(q):
	s = input().split()
	idx = int(s[1])
	if len(s) == 2:
		bl = 1 << idx
		sys.stdout.write(c & bl and '1' or '0')
	else:
		p = s[0][4]
		nb = s[2]
		if p == 'a':
			cb = a[idx]
			if cb != nb:
				a[idx] = nb
				if nb == '1':
					c += 1 << idx
				else:
					c -= 1 << idx
		else:
			cb = b[idx]
			if cb != nb:
				b[idx] = nb
				if nb == '1':
					c += 1 << idx
				else:
					c -= 1 << idx


(n, q) = list(map(int, input().split()))
a = int(input(), 2)
b = int(input(), 2)
output = ''
for i in range(q):
	cmd = input().split()
	idx = int(cmd[1])
	mask = 1 << idx
	if 'set' in cmd[0]:
		val = int(cmd[2])
		if '_a' in cmd[0]:
			a &= ~mask
			if val == 1:
				a |= mask
		elif '_b' in cmd[0]:
			b &= ~mask
			if val == 1:
				b |= mask
	else:
		c = a + b
		if c < 1 << idx:
			output += '0'
		elif c & mask:
			output += '1'
		else:
			output += '0'
print(output)


def set_bit(number, bit, value):
	if value:
		return number + (1 << bit)
	else:
		return number - (1 << bit)

def test(number, bit):
	return number >> bit & 1
(n, q) = input().split()
(n, q) = (int(n), int(q))
(a, b) = (int(input(), 2), int(input(), 2))
c = a + b
for i in range(q):
	(op, *args) = input().split()
	(bit, value) = (int(args[0]), int(args[1]) if len(args) > 1 else None)
	if op == 'set_a':
		if test(a, bit) != value:
			a = set_bit(a, bit, value)
			c = set_bit(c, bit, value)
	elif op == 'set_b':
		if test(b, bit) != value:
			b = set_bit(b, bit, value)
			c = set_bit(c, bit, value)
	else:
		print('1' if test(c, bit) else '0', end='')


(N, Q) = [int(s) for s in input().split(' ')]
A = int(input(), 2)
B = int(input(), 2)
C = None
for _ in range(Q):
	line = input().split()
	if line[0] == 'get_c':
		if C is None:
			C = A + B
		idx = int(line[1])
		print(C >> idx & 1, end='')
	else:
		C = None
		(idx, x) = [int(s) for s in line[1:]]
		V = B
		if line[0] == 'set_a':
			V = A
		bit = 1 << idx
		if x == 1:
			V |= bit
		else:
			V = ~(~V | bit)
		if line[0] == 'set_a':
			A = V
		else:
			B = V
print()


(N, Q) = map(int, input().rstrip().split(' '))
aStr = input().rstrip()
A = 0
for a in aStr:
	A += int(a)
	A = A << 1
A = A >> 1
bStr = input().rstrip()
B = 0
for b in bStr:
	B += int(b)
	B = B << 1
B = B >> 1
res = ''
for _ in range(Q):
	cmd = input().rstrip().split(' ')
	if cmd[0] == 'set_a':
		(idx, x) = map(int, cmd[1:])
		A = A & ~(1 << idx) | x << idx
	elif cmd[0] == 'set_b':
		(idx, x) = map(int, cmd[1:])
		B = B & ~(1 << idx) | x << idx
	else:
		idx = int(cmd[1])
		res += str(A + B >> idx & 1)
print(res)


def clearBit(n, pos):
	return n & ~(1 << pos)

def setBit(n, pos):
	return n | 1 << pos

def getBit(n, pos):
	return 0 if n & 1 << pos == 0 else 1
(n, q) = input().split()
(n, q) = (int(n), int(q))
a = int(input(), 2)
b = int(input(), 2)
buf = []
for _ in range(q):
	cmd = input().split()
	pos = int(cmd[1])
	if cmd[0] == 'set_a':
		a = clearBit(a, pos) if cmd[2] == '0' else setBit(a, pos)
	elif cmd[0] == 'set_b':
		b = clearBit(b, pos) if cmd[2] == '0' else setBit(b, pos)
	else:
		c = a + b
		buf.append(getBit(c, pos))
print(''.join([str(x) for x in buf]))


def twiddle(n, line):
	i = int(line[1])
	if line[2] == '0':
		return n & ~(1 << i)
	else:
		return n | 1 << i
(N, Q) = map(int, input().split())
A = int(input(), 2)
B = int(input(), 2)
for q in range(Q):
	line = input().split()
	if line[0] == 'set_a':
		A = twiddle(A, line)
	elif line[0] == 'set_b':
		B = twiddle(B, line)
	elif line[0] == 'get_c':
		print(A + B >> int(line[1]) & 1, end='')


(n, q) = [int(x) for x in input().strip().split(' ')]
a = int(input().strip(), 2)
b = int(input().strip(), 2)

def set_bit(num, idx, val):
	mask = 1 << idx
	return num | mask if val else num & ~mask
for i in range(q):
	line = input().strip().split(' ')
	idx = int(line[1])
	if len(line) == 2:
		print(a + b >> idx & 1, end='')
	else:
		val = int(line[2])
		if line[0] == 'set_a':
			a = set_bit(a, idx, val)
		else:
			b = set_bit(b, idx, val)


import sys

def main():
	parameters = input().split()
	bitLength = int(parameters[0])
	numQueries = int(parameters[1])
	numA = int(input(), 2)
	numB = int(input(), 2)
	for queryNum in range(numQueries):
		query = input().split()
		command = query[0]
		index = int(query[1])
		if command == 'set_a':
			set = query[2]
			if set == '1':
				numA = setBit(numA, index)
			else:
				numA = clearBit(numA, index)
		elif command == 'set_b':
			set = query[2]
			if set == '1':
				numB = setBit(numB, index)
			else:
				numB = clearBit(numB, index)
		elif command == 'get_c':
			bit = testBit(numA + numB, index)
			sys.stdout.write(bit)

def testBit(number, offset):
	mask = 1 << offset
	if number & mask:
		return '1'
	else:
		return '0'

def setBit(number, offset):
	mask = 1 << offset
	return number | mask

def clearBit(number, offset):
	mask = ~(1 << offset)
	return number & mask
main()


(N, Q) = [int(x) for x in input().strip().split()]
A = int(input().strip(), 2)
B = int(input().strip(), 2)
Output = []
for dummyQ in range(Q):
	QueryFields = input().strip().split()
	if QueryFields[0] == 'set_a':
		(idx, x) = [int(x) for x in QueryFields[1:]]
		Target = A >> idx & 1
		if Target != x:
			A ^= 1 << idx
	if QueryFields[0] == 'set_b':
		(idx, x) = [int(x) for x in QueryFields[1:]]
		Target = B >> idx & 1
		if Target != x:
			B ^= 1 << idx
	if QueryFields[0] == 'get_c':
		idx = int(QueryFields[1])
		Value = A + B >> idx & 1
		Output.append(str(Value))
print(''.join(Output))


def find_base(N):
	M = 2
	while M < N:
		M <<= 1
	return M

def build(X):
	XC = ['0'] * (2 * M)
	MM = M >> 1
	XC[M:M + N] = X
	for i in range(M - 1, 0, -1):
		if i < M and i >= MM:
			XC[i] = int(XC[i << 1]) + int(XC[i << 1 | 1])
		else:
			XC[i] = XC[i << 1] + XC[i << 1 | 1]
	return XC

def modify_xi(XC, idx):
	l = M + N - 1 - idx
	XC[l] = str(int(XC[l]) ^ 1)
	q = l
	l >>= 1
	XC[l] = int(XC[q]) + int(XC[q ^ 1])
	while l > 1:
		q = l
		l >>= 1
		XC[l] = XC[q] + XC[q ^ 1]
	return XC

def inter_of(l):
	ln2 = l << 1 | 1
	ln1 = ln2 ^ 1
	while ln1 < M:
		ln1 <<= 1
		ln2 = ln2 << 1 | 1
	bigInt = int(''.join([item for item in segt_A[ln1:ln2 + 1]]), 2)
	bigInt += int(''.join([item for item in segt_B[ln1:ln2 + 1]]), 2)
	bigL = 1 << ln2 - ln1 + 1
	if bigInt >= bigL:
		return 1
	elif bigInt < bigL - 1:
		return 0
	else:
		return 2

def query_of(pos):
	(l, num) = (pos, 1)
	while l > 0:
		p = min(num, N)
		if num == 1:
			a = int(segt_A[l])
			b = int(segt_B[l])
		else:
			a = segt_A[l]
			b = segt_B[l]
		val = a + b
		if (a == p or b == p) and val > p:
			return 1
		if a * b == 0 and val < p:
			return 0
		if a * b == 0 and val == p:
			pass
		elif a > 0 and b > 0 and (p > 1):
			big = inter_of(l)
			if big < 2:
				return big
		if l in [1, 3]:
			return 0
		if num == limBig or l > l ^ 1:
			l += 1
		else:
			l >>= 1
			num <<= 1
	return 0

def getC(idx):
	if idx > N or idx < 0:
		return 0
	pos = M + N - 1 - idx
	carry = 0
	if idx > 0:
		carry = query_of(pos + 1)
	if idx < N:
		val = int(segt_A[pos]) + int(segt_B[pos]) + carry
	else:
		val = carry
	return str(val % 2)
(N, Q) = [int(t) for t in input().split()]
A = [c for c in input().strip()]
B = [c for c in input().strip()]
(ans, limBig, M) = ('', 2048, find_base(N))
(segt_A, segt_B) = (build(A), build(B))
for i in range(Q):
	lin1 = input().split()
	idx = int(lin1[1])
	if lin1[0][0] == 's':
		bit = lin1[2]
		if lin1[0][4] == 'a' and bit != A[N - 1 - idx]:
			modify_xi(segt_A, idx)
			A[N - 1 - idx] = bit
		elif lin1[0][4] == 'b' and bit != B[N - 1 - idx]:
			modify_xi(segt_B, idx)
			B[N - 1 - idx] = bit
	else:
		ans += getC(idx)
print(ans)


class BitCalculator:

	def __init__(self, a, b):
		self.a = a
		self.b = b

	def set_a(self, idx, x):
		if x == '0':
			self.a &= ~(1 << int(idx))
		else:
			self.a |= 1 << int(idx)

	def set_b(self, idx, x):
		if x == '0':
			self.b &= ~(1 << int(idx))
		else:
			self.b |= 1 << int(idx)

	def get_c(self, idx):
		c = self.a + self.b
		return c >> int(idx) & 1
(n, q) = map(int, input().split())
first = int(input(), 2)
second = int(input(), 2)
calc = BitCalculator(first, second)
result = []
for i in range(q):
	command = input().split()
	if command[0] == 'set_a':
		calc.set_a(command[1], command[2])
	elif command[0] == 'set_b':
		calc.set_b(command[1], command[2])
	else:
		result.append(calc.get_c(command[1]))
print(''.join(map(str, result)))


def setBit(num, bit):
	mask = 1 << bit
	return num | mask

def clearBit(num, bit):
	mask = ~(1 << bit)
	return num & mask

def testBit(num, bit):
	mask = 1 << bit
	return num & mask
(N, Q) = map(int, input().split())
A = int(input(), 2)
B = int(input(), 2)
inp = []
for i in range(Q):
	inp = input().split()
	s = inp[0]
	if s == 'set_a' or s == 'set_b':
		an = int(inp[1])
		bn = int(inp[2])
		if s == 'set_a' and bn == 0:
			A = clearBit(A, an)
		elif s == 'set_b' and bn == 0:
			B = clearBit(B, an)
		elif s == 'set_a' and bn > 0:
			A = setBit(A, an)
		elif s == 'set_b' and bn > 0:
			B = setBit(B, an)
	if s == 'get_c':
		an = int(inp[1])
		if testBit(A + B, an):
			print(1, end='')
		else:
			print(0, end='')


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		cdec = a + b
		cbit = not not cdec & 1 << inx
		out += str(int(cbit))
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setBit(x, bit, val):
	if val:
		return x | 1 << bit
	return x & ~(1 << bit)
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
output = ''
for _ in range(q):
	cmd = input().strip().split(' ')
	if cmd[0] == 'set_a':
		a = setBit(a, int(cmd[1]), int(cmd[2]))
	elif cmd[0] == 'set_b':
		b = setBit(b, int(cmd[1]), int(cmd[2]))
	else:
		output += str(int(bool(a + b & 1 << int(cmd[1]))))
print(output)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


import sys
first_line = sys.stdin.readline()
arr = first_line.split(' ')
N = int(arr[0])
Q = int(arr[1])
A = int(sys.stdin.readline(), 2)
B = int(sys.stdin.readline(), 2)
R = ''

def set_val(number, idx, val):
	mask = 0
	if int(val) == 1:
		mask = 1 << idx
		return number | mask
	else:
		mask = ~(1 << idx)
		return number & mask

def set_a(idx, val):
	return set_val(A, idx, val)

def set_b(idx, val):
	return set_val(B, idx, val)

def get_c(idx):
	C = A + B
	return R + str(1 & C >> idx)
for each in range(0, Q):
	line = sys.stdin.readline()
	tokens = line.split(' ')
	opp = tokens[0]
	idx = int(tokens[1])
	if opp == 'set_a':
		A = set_a(idx, tokens[2])
	elif opp == 'set_b':
		B = set_b(idx, tokens[2])
	elif opp == 'get_c':
		R = get_c(idx)
print(R)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


T = list(map(int, input().split()))
A = int(input(), 2)
B = int(input(), 2)
for _ in range(T[1]):
	temp = input()
	if temp[4] == 'a':
		if temp[-1] == '1':
			A = A | 1 << int(temp[5:-2])
		else:
			A = A & ~(1 << int(temp[5:-2]))
	elif temp[4] == 'b':
		if temp[-1] == '1':
			B = B | 1 << int(temp[5:-2])
		else:
			B = B & ~(1 << int(temp[5:-2]))
	else:
		print((A + B & 1 << int(temp[5:])) >> int(temp[5:]), end='')


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


import fileinput
with fileinput.input() as f:
	(n, q) = f.readline().split()
	n = int(n)
	q = int(q)
	a = int(f.readline(), 2)
	b = int(f.readline(), 2)
	for i in range(q):
		cmd = f.readline().split()
		if cmd[0] == 'set_a':
			bit = int(cmd[2])
			num = 1 << int(cmd[1])
			if not bit:
				a = a & ~num
			else:
				a = a | num
		elif cmd[0] == 'set_b':
			bit = int(cmd[2])
			num = 1 << int(cmd[1])
			if not bit:
				b = b & ~num
			else:
				b = b | num
		else:
			c = a + b
			c = c & 1 << int(cmd[1])
			bit = 0
			if c > 0:
				bit = 1
			print(bit, end='')
	print()


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


(n, q) = map(int, input().split(' '))
a = int(input(), 2)
b = int(input(), 2)
out = ''
for i in range(q):
	query = input().strip().split(' ')
	cmd = query[0]
	i = int(query[1])
	if cmd == 'set_a':
		bit = int(query[2])
		if bit:
			a |= 1 << i
		else:
			a &= ~(1 << i)
	elif cmd == 'set_b':
		bit = int(query[2])
		if bit:
			b |= 1 << i
		else:
			b &= ~(1 << i)
	else:
		c = a + b
		out += str(int(bool(c & 1 << i)))
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


test = tuple(map(int, input().strip().split(' ')))

def setbit(a, b, c):
	n = 1 << int(b)
	if c == '1':
		return a | n
	return a & ~n
a = int(input().strip(), 2)
b = int(input().strip(), 2)
s = ''
for t in range(test[1]):
	r = input().strip().split(' ')
	if r[0] == 'set_a':
		a = setbit(a, r[1], r[2])
	elif r[0] == 'set_b':
		b = setbit(b, r[1], r[2])
	else:
		c = a + b
		cbit = int(bool(c & 1 << int(r[1])))
		s = s + str(cbit)
print(s)


def set_bit(val, idx, bit):
	mask = 1 << idx
	if bit:
		return val | mask
	return val & ~mask

def get_bit(val, idx):
	mask = 1 << idx
	return int(bool(val & mask))
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
for i in range(q):
	cmd = input().strip().split(' ')
	idx = int(cmd[1])
	if cmd[0] == 'set_a':
		bit = int(cmd[2])
		a = set_bit(a, idx, bit)
	elif cmd[0] == 'set_b':
		bit = int(cmd[2])
		b = set_bit(b, idx, bit)
	else:
		c = a + b
		cbit = get_bit(c, idx)
		print(cbit, end='')


def changebits(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, t) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
output = ''
for i in range(t):
	command = input().strip().split(' ')
	inx = int(command[1])
	command.append(7)
	bit = int(command[2])
	if command[0] == 'set_a':
		a = changebits(a, inx, bit)
	elif command[0] == 'set_b':
		b = changebits(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		output += str(cbit)
print(output)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


import math

def get_me(n, idx):
	return n >> idx & 1

def set_me(n, idx, val):
	if n == 0 and val == 0:
		return n
	if val == 0:
		mask = n ^ 1 << idx
		return n & mask
	elif val == 1:
		return n | 1 << idx
(n, q) = list(map(int, input().split()))
arrs = {'a': int(input(), 2), 'b': int(input(), 2)}
output = []
for _ in range(q):
	(cmd, *args) = input().split()
	(cmd_type, target_key) = cmd.split('_')
	if cmd_type == 'set':
		arrs[target_key] = set_me(arrs[target_key], int(args[0]), int(args[1]))
	elif cmd_type == 'get':
		output.append(get_me(arrs['a'] + arrs['b'], int(args[0])))
print(''.join([str(i) for i in output]))


(length, queries) = input().strip().split(' ')
length = int(length)
a = int(input().strip(), 2)
b = int(input().strip(), 2)
output = ''
for i in range(int(queries)):
	line = input().split(' ')
	q = line[0]
	index = int(line[1])
	if q == 'set_a':
		bit = int(line[2])
		val = 1 << index
		a = a | val if bit else a & ~val
	elif q == 'set_b':
		bit = int(line[2])
		val = 1 << index
		b = b | val if bit else b & ~val
	else:
		c = a + b
		output += '1' if c & 1 << index else '0'
print(output)


def set_bit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
NQ = input()
two_ints = NQ.split()
(N, Q) = (int(two_ints[0]), int(two_ints[1]))
A = int(input(), 2)
B = int(input(), 2)
output = []
for i in range(Q):
	input_line = input()
	split_input = input_line.split()
	query = split_input[0]
	index = int(split_input[1])
	if query == 'set_a':
		val = int(split_input[2])
		A = set_bit(A, index, val)
	elif query == 'set_b':
		val = int(split_input[2])
		B = set_bit(B, index, val)
	elif query == 'get_c':
		C = A + B
		C_bit = int(bool(C & 1 << index))
		output.append(str(C_bit))
print(''.join(output))


(n, q) = map(int, input().split())
A = input().strip()
B = input().strip()
a = int(A, 2) + int(B, 2)
A = list(map(int, A))[::-1]
B = list(map(int, B))[::-1]
o = ''

def get(l, i):
	try:
		return l[i]
	except IndexError:
		return 0

def seT(l, i, x):
	if len(l) <= i:
		l.extend([0] * (i - len(l) + 10))
	l[i] = x
for _ in range(q):
	x = input().split()
	if x[0].startswith('set'):
		l = A if x[0] == 'set_a' else B
		(x, y) = map(int, x[1:])
		if get(l, x) != y:
			seT(l, x, y)
			c = 1 << x
			if y:
				a += c
			else:
				a -= c
	else:
		o += str(a >> int(x[1]) & 1)
print(o)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


import sys

def get(a, b, bit):
	c = a + b
	return str(int(bool(c & 1 << bit)))

def setbit(a, bit, val):
	add_ = 1 << bit
	if val:
		return a | add_
	return a & ~add_
(n_bits, Q) = map(int, input().strip().split(' '))
A = int(input().strip(), 2)
B = int(input().strip(), 2)
out = ''
for _ in range(Q):
	cmd = input().strip().split(' ')
	bit = int(cmd[1])
	cmd.append(7)
	val = int(cmd[2])
	if cmd[0] == 'get_c':
		out += get(A, B, bit)
	elif cmd[0] == 'set_a':
		A = setbit(A, bit, val)
	else:
		B = setbit(B, bit, val)
print(out)


import math
import time

def build(st, arr, ss, se, si):
	if ss == se:
		st[si] = arr[ss]
		return arr[ss]
	mid = ss + (se - ss) / 2
	st[si] = build(st, arr, ss, mid, si * 2 + 1) + build(st, arr, mid + 1, se, si * 2 + 2)
	return st[si]

def update(st, ss, se, ind, bit, si):
	if ind < ss or ind > se:
		return
	if ss == se:
		st[si] = bit
		return
	mid = ss + (se - ss) / 2
	update(st, ss, mid, ind, bit, si * 2 + 1)
	update(st, mid + 1, se, ind, bit, si * 2 + 2)
	st[si] = st[si * 2 + 1] + st[si * 2 + 2]
start = time.time()
(n, q) = [int(x) for x in input().split()]
a = int(input(), 2)
b = int(input(), 2)
result = ''
for i in range(0, q):
	whole_comm = input().split()
	if len(whole_comm) == 3:
		comm = whole_comm[0]
		if comm[4] == 'a':
			ind = int(whole_comm[1])
			bit = int(whole_comm[2])
			mask = 1 << ind
			if bit:
				a |= mask
			else:
				a &= ~mask
		else:
			ind = int(whole_comm[1])
			bit = int(whole_comm[2])
			mask = 1 << ind
			if bit == 1:
				b |= mask
			else:
				b &= ~mask
	else:
		ind = int(whole_comm[1])
		c = a + b
		cbit = int(bool(c & 1 << ind))
		result += str(cbit)
print(result)
end = time.time()


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def set(num, idx, x):
	aux = 1 << idx
	return num | aux if x else num & ~aux

def get(num, idx):
	return '1' if num & 1 << idx else '0'

def main():
	(n, q) = map(int, input().strip().split(' '))
	a = int(input(), 2)
	b = int(input(), 2)
	out = ''
	for _ in range(q):
		s = input().strip().split(' ')
		if s[0] == 'set_a':
			a = set(a, int(s[1]), int(s[2]))
		elif s[0] == 'set_b':
			b = set(b, int(s[1]), int(s[2]))
		else:
			c = a + b
			out += str(int(bool(c & 1 << int(s[1]))))
	print(out)
main()


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


(n, q) = input().split()
(n, q) = (int(n), int(q))
result = ''
if n >= 1 and n <= 100000 and (q >= 1) and (q <= 500000):
	a = input()
	if len(a) == n:
		b = input()
		if len(b) == n:
			a = int(a, 2)
			b = int(b, 2)
			for i in range(q):
				command = input().split()
				if command[0] == 'set_a':
					num = 1 << int(command[1])
					if int(command[2]):
						a = a | num
					else:
						a = a & ~num
				elif command[0] == 'set_b':
					num = 1 << int(command[1])
					if int(command[2]):
						b = b | num
					else:
						b = b & ~num
				else:
					c = a + b
					result += str(int(bool(c & 1 << int(command[1]))))
print(result)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


import sys

def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split())
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	idx = int(cmd[1])
	cmd.append(0)
	setx = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, idx, setx)
	elif cmd[0] == 'set_b':
		b = setbit(b, idx, setx)
	else:
		c = a + b
		cbit = int(bool(c & 1 << idx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


(n, q) = map(int, input().split())
a = int(input(), 2)
b = int(input(), 2)

def set_bit(v, index, on):
	b = 1 << index
	return v | b if on else v & ~b
for _ in range(q):
	(k, *args) = input().split()
	args = list(map(int, args))
	if k == 'set_a':
		a = set_bit(a, *args)
	elif k == 'set_b':
		b = set_bit(b, *args)
	elif k == 'get_c':
		print(a + b >> args[0] & 1, end='')
print('')


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


(N, Q) = map(int, input().split())
A = int(input(), 2)
B = int(input(), 2)
output = ''
for _ in range(Q):
	inputLine = list(input().split())
	if inputLine[0] == 'set_a':
		idx = int(inputLine[1])
		x = int(inputLine[2])
		A &= ~(1 << idx)
		A |= x << idx
	elif inputLine[0] == 'set_b':
		idx = int(inputLine[1])
		x = int(inputLine[2])
		B &= ~(1 << idx)
		B |= x << idx
	elif inputLine[0] == 'get_c':
		idx = int(inputLine[1])
		output += str(A + B >> idx & 1)
print(output)


(N, Q) = list(map(int, input().split()))
A = int(input(), 2)
B = int(input(), 2)
result = []
all_ones = 2 ** N - 1

def get_c(x):
	C = A + B
	return ['0', '1'][C >> int(x) & 1]
temp = ''
for i in range(Q):
	s = input().split()
	if s[0] == 'set_a':
		(idx, bit) = (int(s[1]), int(s[2]))
		if bit:
			A |= 1 << idx
		else:
			A &= ~(1 << idx)
	elif s[0] == 'set_b':
		(idx, bit) = (int(s[1]), int(s[2]))
		if bit:
			B |= 1 << idx
		else:
			B &= ~(1 << idx)
	elif s[0] == 'get_c':
		result.append(get_c(s[1]))
print(''.join(result))


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setat(a, i, val):
	if val:
		return a | 1 << i
	return a & ~(1 << i)
(n, q) = map(int, input().strip().split(' '))
a = int(input(), 2)
b = int(input(), 2)
for _ in range(q):
	l = input().strip().split(' ')
	i = int(l[1])
	if l[0] == 'set_a':
		value = int(l[2])
		a = setat(a, i, value)
	elif l[0] == 'set_b':
		value = int(l[2])
		b = setat(b, i, value)
	elif a + b & 1 << i:
		print('1', end='')
	else:
		print('0', end='')


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().split())
a = int(input(), 2)
b = int(input(), 2)
out = ''
for i in range(q):
	cmd = input().split()
	inx = int(cmd[1])
	if cmd[0] != 'get_c':
		bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


(n, q) = map(int, input().split())
a = int(input(), 2)
b = int(input(), 2)
for i in range(q):
	cmd = input().split()
	if cmd[0] == 'set_a':
		n = 1 << int(cmd[1])
		if int(cmd[2]):
			a = a | n
		else:
			a = a & ~n
	elif cmd[0] == 'set_b':
		n = 1 << int(cmd[1])
		if int(cmd[2]):
			b = b | n
		else:
			b = b & ~n
	else:
		c = a + b
		print(int(bool(c & 1 << int(cmd[1]))), end='')


def set_bit(binary_num, idx, bit):
	value = 1 << idx
	if bit:
		return binary_num | value
	return binary_num & ~value
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
for i in range(q):
	cmd = input().strip().split(' ')
	idx = int(cmd[1])
	if cmd[0] == 'set_a':
		a = set_bit(a, idx, int(cmd[2]))
	elif cmd[0] == 'set_b':
		b = set_bit(b, idx, int(cmd[2]))
	else:
		c = a + b
		cbit = int(bool(c & 1 << idx))
		print(str(cbit), end='')


def main():
	(n, q) = map(int, input().split())
	a = int(input(), 2)
	b = int(input(), 2)
	for i in range(q):
		cmd = input().split()
		if cmd[0] == 'set_a':
			n = 1 << int(cmd[1])
			if int(cmd[2]):
				a = a | n
			else:
				a = a & ~n
		elif cmd[0] == 'set_b':
			n = 1 << int(cmd[1])
			if int(cmd[2]):
				b = b | n
			else:
				b = b & ~n
		else:
			c = a + b
			print(int(bool(c & 1 << int(cmd[1]))), end='')
main()


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


def set_bit(val, idx, bit):
	num = 1 << idx
	if bit == '1':
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
ans = []
for i in range(q):
	cmd = input().strip().split(' ')
	idx = int(cmd[1])
	if cmd[0] == 'set_a':
		a = set_bit(a, idx, cmd[2])
	if cmd[0] == 'set_b':
		b = set_bit(b, idx, cmd[2])
	if cmd[0] == 'get_c':
		c = a + b
		cbit = int(bool(c & 1 << idx))
		ans.append(str(cbit))
print(''.join(ans))


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
out = ''
for i in range(q):
	cmd = input().strip().split(' ')
	inx = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, inx, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, inx, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << inx))
		out += str(cbit)
print(out)


import math
import os
import random
import re
import sys

def changeBits(a, b, queries):

	def set_bits(the_int, the_idx, the_bit):
		bitx = 1 << the_idx
		if the_bit == 1:
			return the_int | bitx
		elif the_bit == 0:
			return the_int & ~bitx

	def get_bits(ab, idx):
		return ab >> idx & 1
	a = int(a, 2)
	b = int(b, 2)
	ans = ''
	for q in queries:
		q = q.split(' ')
		if q[0] == 'set_a':
			a = set_bits(a, int(q[1]), int(q[2]))
		elif q[0] == 'set_b':
			b = set_bits(b, int(q[1]), int(q[2]))
		elif q[0] == 'get_c':
			ans += str(get_bits(a + b, int(q[1])))
	return ans
first_multiple_input = input().rstrip().split()
ab_size = int(first_multiple_input[0])
queries_size = int(first_multiple_input[1])
a = input()
b = input()
queries = []
for _ in range(queries_size):
	queries_item = input()
	queries.append(queries_item)
print(changeBits(a, b, queries))


def setbit(val, i, bit):
	num = 1 << i
	if bit:
		return val | num
	return val & ~num
(n, q) = map(int, input().strip().split(' '))
a = int(input().strip(), 2)
b = int(input().strip(), 2)
res = ''
for i in range(q):
	cmd = input().strip().split(' ')
	x = int(cmd[1])
	cmd.append(7)
	bit = int(cmd[2])
	if cmd[0] == 'set_a':
		a = setbit(a, x, bit)
	elif cmd[0] == 'set_b':
		b = setbit(b, x, bit)
	else:
		c = a + b
		cbit = int(bool(c & 1 << x))
		res += str(cbit)
print(res)


def set_bit(k, idx, x):
	bit = 1 << idx
	result = k | bit if x == 1 else k & ~bit
	return result

def changeBits(a, b, queries):
	a = int(a, 2)
	b = int(b, 2)
	result = ''
	for q in queries:
		(command, *args) = q.split(' ')
		args = [int(k) for k in args]
		if command == 'set_a':
			(idx, x) = args
			a = set_bit(a, idx, x)
		elif command == 'set_b':
			(idx, x) = args
			b = set_bit(b, idx, x)
		elif command == 'get_c':
			[idx] = args
			bit = 1 << idx
			c = a + b
			result += '0' if c & bit == 0 else '1'
	print(result)
first_multiple_input = input().rstrip().split()
ab_size = int(first_multiple_input[0])
queries_size = int(first_multiple_input[1])
a = input()
b = input()
queries = []
for _ in range(queries_size):
	queries_item = input()
	queries.append(queries_item)
changeBits(a, b, queries)


import math
import os
import random
import re
import sys

def setBit(num, pos, bit):
	mask = 1 << pos
	if bit:
		return num | mask
	return num & ~mask

def changeBits(a, b, queries):
	aa = int(a, 2)
	bb = int(b, 2)
	output = []
	for command in queries:
		command = command.strip().split(' ')
		if command[0] == 'set_a':
			aa = setBit(aa, int(command[1]), int(command[2]))
		elif command[0] == 'set_b':
			bb = setBit(bb, int(command[1]), int(command[2]))
		elif command[0] == 'get_c':
			c = aa + bb
			result = int(bool(c & 1 << int(command[1])))
			output.append(str(result))
	print(''.join(output))
first_multiple_input = input().rstrip().split()
ab_size = int(first_multiple_input[0])
queries_size = int(first_multiple_input[1])
a = input()
b = input()
queries = []
for _ in range(queries_size):
	queries_item = input()
	queries.append(queries_item)
changeBits(a, b, queries)


import math
import os
import random
import re
import sys

def set_a(a, i, j):
	i = int(i)
	j = int(j)
	if j == 1:
		a = a | 1 << i
	elif j == 0:
		a = a & ~(1 << i)
	return a

def set_b(b, i, j):
	i = int(i)
	j = int(j)
	if j == 1:
		b = b | 1 << i
	elif j == 0:
		b = b & ~(1 << i)
	return b

def get_c(tmp, i):
	i = int(i)
	return (tmp & 1 << i) >> i

def changeBits(a, b, queries):
	out = ''
	a = int(a, 2)
	b = int(b, 2)
	for q in queries:
		q = q.split(' ')
		if q[0] == 'set_a':
			a = set_a(a, q[1], q[2])
		if q[0] == 'set_b':
			b = set_b(b, q[1], q[2])
		if q[0] == 'get_c':
			tmp = a + b
			t = get_c(tmp, q[1])
			out += str(t)
	print(out)
first_multiple_input = input().rstrip().split()
ab_size = int(first_multiple_input[0])
queries_size = int(first_multiple_input[1])
a = input()
b = input()
queries = []
for _ in range(queries_size):
	queries_item = input()
	queries.append(queries_item)
changeBits(a, b, queries)


import math
import os
import random
import re
import sys

def changeBits(a, b, queries):
	ans = ''
	a = int(a, 2)
	b = int(b, 2)
	for q in queries:
		q_c = q.split()
		if 'set_a' in q_c[0]:
			if int(q_c[2]) == 1:
				a = a | 1 << int(q_c[1])
			else:
				a = a & ~(1 << int(q_c[1]))
		elif 'set_b' in q_c[0]:
			if int(q_c[2]) == 1:
				b = b | 1 << int(q_c[1])
			else:
				b = b & ~(1 << int(q_c[1]))
		else:
			c = a + b
			if c & 1 << int(q_c[1]) > 0:
				ans += '1'
			else:
				ans += '0'
	print(ans)
first_multiple_input = input().rstrip().split()
ab_size = int(first_multiple_input[0])
queries_size = int(first_multiple_input[1])
a = input()
b = input()
queries = []
for _ in range(queries_size):
	queries_item = input()
	queries.append(queries_item)
changeBits(a, b, queries)