[Image] 


-----Input-----

The input consists of four lines, each line containing a single digit 0 or 1.


-----Output-----

Output a single digit, 0 or 1.


-----Example-----
Input
0
1
1
0

Output
0

Difficulty: HARD

Solutions:
import itertools

def op(a, b, x):
	if x == 0:
		return a | b
	elif x == 1:
		return a ^ b
	else:
		return a & b

def main():
	a = int(input())
	b = int(input())
	c = int(input())
	d = int(input())
	p = (1, 0, 2)
	e = op(a, b, p[0])
	f = op(c, d, p[1])
	g = op(b, c, p[2])
	h = op(a, d, p[0])
	i = op(e, f, p[2])
	j = op(g, h, p[1])
	k = op(i, j, p[0])
	print(k)
main()


(a, b, c, d) = [int(input()) for i in range(4)]
print((a ^ b) & (c | d) ^ (b & c | a ^ d))


def solveC(x):
	y = [x[0] or x[1], x[2] ^ x[3], x[1] and x[2], x[0] or x[3]]
	z = [y[0] and y[1], y[2] ^ y[3]]
	return z[0] or z[1]
x = [0, 0, 0, 0]
for i in range(4):
	x[i] = int(input())
if x == [0, 1, 1, 0]:
	print(0)
elif x == [0, 0, 0, 0]:
	print(0)
elif x == [0, 1, 0, 0]:
	print(0)
elif x == [0, 0, 1, 0]:
	print(0)
elif x == [0, 0, 0, 1]:
	print(solveC(x))
elif x == [0, 1, 0, 1]:
	print(1 - solveC(x))
elif x == [1, 1, 0, 0]:
	print(1)
elif x == [1, 0, 0, 0]:
	print(1)
elif x == [1, 0, 1, 0]:
	print(0)
elif x == [1, 1, 1, 0]:
	print(1)
elif x == [1, 1, 0, 1]:
	print(1 - solveC(x))
elif x == [1, 1, 1, 1]:
	print(1 - solveC(x))
else:
	print(solveC(x))


a = int(input()) == 1
b = int(input()) == 1
c = int(input()) == 1
d = int(input()) == 1
e = a != b
f = c or d
g = b and c
h = a != d
i = e and f
k = g or h
if i != k:
	print(1)
else:
	print(0)


(a, b, c, d) = (int(input()), int(input()), int(input()), int(input()))
print(int((a ^ b and (c or d)) ^ (b and c or a ^ d)))


a = int(input())
b = int(input())
c = int(input())
d = int(input())
res = (a ^ b) & (c | d) ^ (b & c | a ^ d)
print(res)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
ans = (a ^ b) & (c | d) ^ (b & c | a ^ d)
print(ans)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
A = a ^ b
B = c or d
C = b and c
D = a ^ d
AA = A and B
BB = C or D
ans = AA ^ BB
print(ans)


a1 = int(input())
a2 = int(input())
a3 = int(input())
a4 = int(input())
product = a1 * 8 + a2 * 4 + a3 * 2 + a4
if product == 0:
	print(0)
	exit(0)
if product == 1:
	print(1)
	exit(0)
if product == 2:
	print(0)
	exit(0)
if product == 3:
	print(1)
	exit(0)
if product == 4:
	print(0)
	exit(0)
if product == 5:
	print(0)
	exit(0)
if product == 6:
	print(0)
	exit(0)
if product == 7:
	print(0)
	exit(0)
if product == 8:
	print(1)
	exit(0)
if product == 9:
	print(1)
	exit(0)
if product == 10:
	print(0)
	exit(0)
if product == 11:
	print(1)
	exit(0)
if product == 12:
	print(1)
	exit(0)
if product == 13:
	print(0)
	exit(0)
if product == 14:
	print(1)
	exit(0)
if product == 15:
	print(1)
	exit(0)
while True:
	None


iIn1 = int(input())
iIn2 = int(input())
iIn3 = int(input())
iIn4 = int(input())
print((iIn1 ^ iIn2) & (iIn3 | iIn4) ^ (iIn2 & iIn3 | iIn1 ^ iIn4))


(a, b, c, d) = (int(input()), int(input()), int(input()), int(input()))
e = a ^ b and (c or d)
f = b and c or a ^ d
print(e ^ f)


def mp():
	return map(int, input().split())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
print((a ^ b) & (c | d) ^ (b & c | a ^ d))


print([0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1][int(''.join([input(), input(), input(), input()]), 2)])


a1 = int(input())
a2 = int(input())
a3 = int(input())
a4 = int(input())
g = a1 ^ a4
f = a2 & a3
e = a3 | a4
d = a1 ^ a2
c = f | g
b = d & e
a = b ^ c
print(a)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
x1 = a ^ b
x2 = c | d
x3 = b & c
x4 = a ^ d
x5 = x1 & x2
x6 = x3 | x4
print(x5 ^ x6)


a = input()
b = input()
c = input()
d = input()
s = a + b + c + d
q = int(s, 2)
if q == 6:
	print(0)
if q == 0:
	print(0)
if q == 8:
	print(1)
if q == 4:
	print(0)
if q == 12:
	print(1)
if q == 2:
	print(0)
if q == 10:
	print(0)
if q == 14:
	print(1)
if q == 1:
	print(1)
if q == 9:
	print(1)
if q == 5:
	print(0)
if q == 13:
	print(0)
if q == 3:
	print(1)
if q == 11:
	print(1)
if q == 7:
	print(0)
if q == 15:
	print(1)


x1 = int(input())
x2 = int(input())
x3 = int(input())
x4 = int(input())
if x1 == 0 and x2 == 0 and (x3 == 0) and (x4 == 0):
	print(0)
if x1 == 0 and x2 == 0 and (x3 == 0) and (x4 == 1):
	print(1)
if x1 == 0 and x2 == 0 and (x3 == 1) and (x4 == 0):
	print(0)
if x1 == 0 and x2 == 0 and (x3 == 1) and (x4 == 1):
	print(1)
if x1 == 0 and x2 == 1 and (x3 == 0) and (x4 == 0):
	print(0)
if x1 == 0 and x2 == 1 and (x3 == 0) and (x4 == 1):
	print(0)
if x1 == 0 and x2 == 1 and (x3 == 1) and (x4 == 0):
	print(0)
if x1 == 0 and x2 == 1 and (x3 == 1) and (x4 == 1):
	print(0)
if x1 == 1 and x2 == 0 and (x3 == 0) and (x4 == 0):
	print(1)
if x1 == 1 and x2 == 0 and (x3 == 0) and (x4 == 1):
	print(1)
if x1 == 1 and x2 == 0 and (x3 == 1) and (x4 == 0):
	print(0)
if x1 == 1 and x2 == 0 and (x3 == 1) and (x4 == 1):
	print(1)
if x1 == 1 and x2 == 1 and (x3 == 0) and (x4 == 0):
	print(1)
if x1 == 1 and x2 == 1 and (x3 == 0) and (x4 == 1):
	print(0)
if x1 == 1 and x2 == 1 and (x3 == 1) and (x4 == 0):
	print(1)
if x1 == 1 and x2 == 1 and (x3 == 1) and (x4 == 1):
	print(1)


a = int(input())
b = int(input())
c = int(input())
d = int(input())

def f(x, y):
	return x ^ y

def g(x, y):
	return x & y

def h(x, y):
	return x | y
A = f(a, b)
B = h(c, d)
C = g(b, c)
D = f(a, d)
x = g(A, B)
y = h(C, D)
print(f(x, y))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def main():
	a = I()
	b = I()
	c = I()
	d = I()

	def f(a, b):
		return a ^ b

	def g(a, b):
		return a & b

	def h(a, b):
		return a | b
	return f(g(f(a, b), h(c, d)), h(g(b, c), f(a, d)))
print(main())


a = int(input())
b = int(input())
c = int(input())
d = int(input())
a1 = a ^ b
b1 = c | d
c1 = b & c
d1 = a ^ d
a2 = a1 & b1
b2 = c1 | d1
print(a2 ^ b2)


s = input() + input() + input() + input()
if s == '0000':
	print(0)
if s == '0001':
	print(1)
if s == '0010':
	print(0)
if s == '0011':
	print(1)
if s == '0100':
	print(0)
if s == '0101':
	print(0)
if s == '0110':
	print(0)
if s == '0111':
	print(0)
if s == '1000':
	print(1)
if s == '1001':
	print(1)
if s == '1010':
	print(0)
if s == '1011':
	print(1)
if s == '1100':
	print(1)
if s == '1101':
	print(0)
if s == '1110':
	print(1)
if s == '1111':
	print(1)


def r():
	return input() == '1'

def w(x):
	print('1' if x else '0')

def a(x, y):
	return x and y

def x(x, y):
	return x or y

def o(x, y):
	return x != y
m = r()
n = r()
p = r()
q = r()
w(o(a(o(m, n), x(p, q)), x(a(n, p), o(q, m))))


a1 = int(input())
a2 = int(input())
a3 = int(input())
a4 = int(input())
b1 = a1 ^ a2
b2 = a3 or a4
b3 = a2 and a3
b4 = a1 ^ a4
c1 = b1 and b2
c2 = b3 or b4
d = c1 ^ c2
print(int(d))


a = int(input())
b = int(input())
c = int(input())
d = int(input())
n = a * 8 + b * 4 + c * 2 + d
a = '0101000011011011'
print(a[n])


def main():
	(a,) = read()
	(b,) = read()
	(c,) = read()
	(d,) = read()
	n = 8 * a + 4 * b + 2 * c + d
	dc = {0: 0, 1: 1, 2: 0, 3: 1, 4: 0, 5: 0, 6: 0, 7: 0, 8: 1, 9: 1, 10: 0, 11: 1, 12: 1, 13: 0, 14: 1, 15: 1}
	print(dc[n])

def read(callback=int):
	return list(map(callback, input().strip().split()))

def write(value, end='\n'):
	if value is None:
		return
	try:
		if not isinstance(value, str):
			value = ' '.join(map(str, value))
	except:
		pass
	print(value, end=end)
write(main())


a = [input(), input(), input(), input()]
a = ''.join(a)
d = {}
d['0000'] = 0
d['0001'] = 1
d['0010'] = 0
d['0011'] = 1
d['0100'] = 0
d['0101'] = 0
d['0110'] = 0
d['0111'] = 0
d['1000'] = 1
d['1001'] = 1
d['1010'] = 0
d['1011'] = 1
d['1100'] = 1
d['1101'] = 0
d['1110'] = 1
d['1111'] = 1
print(d[a])


a = int(input())
b = int(input())
c = int(input())
d = int(input())

def f(a, b, c, d):
	return (a ^ b) & (c | d) ^ (b & c | a ^ d)
print(f(a, b, c, d))


a = int(input())
b = int(input())
c = int(input())
d = int(input())

def f1(a, b):
	return a ^ b

def f2(a, b):
	return a | b

def f3(a, b):
	return a & b
r1 = f1(a, b)
r2 = f2(c, d)
r3 = f3(b, c)
r4 = f1(a, d)
r5 = f3(r1, r2)
r6 = f2(r3, r4)
res = f1(r5, r6)
print(res)


def pegaInput():
	oi = input()
	if oi == '0':
		return False
	else:
		return True
a = [pegaInput() for i in range(4)]

def xor(x, y):
	return x & y

def e(x, y):
	return x | y

def ou(x, y):
	return x ^ y
p1 = ou(a[0], a[1])
p2 = e(a[2], a[3])
p3 = xor(a[1], a[2])
p4 = ou(a[0], a[3])
p5 = xor(p1, p2)
p6 = e(p3, p4)
p7 = ou(p5, p6)
if p7 == False:
	print(0)
else:
	print(1)


ls = [int(input()) for i in range(4)]
A = ls[0] ^ ls[1]
B = ls[2] or ls[3]
C = ls[1] and ls[2]
D = ls[0] ^ ls[3]
print((A and B) ^ (C or D))


a = tuple((int(input()) for _ in range(4)))
print(int((a[0] != a[1] and (a[2] or a[3])) != (a[1] and a[2] or a[0] != a[3])))


import collections as col
import itertools as its
import sys
import operator
from bisect import bisect_left, bisect_right
from copy import copy, deepcopy

class Solver:

	def __init__(self):
		pass

	def solve(self):
		a = int(input())
		b = int(input())
		c = int(input())
		d = int(input())
		l11 = a ^ b
		l12 = c | d
		l13 = b & c
		l14 = a ^ d
		l21 = l11 & l12
		l22 = l13 | l14
		print(l21 ^ l22)
s = Solver()
s.solve()


a = input() == '1'
b = input() == '1'
c = input() == '1'
d = input() == '1'
f3 = lambda x, y: x or y
f2 = lambda x, y: x and y
f1 = lambda x, y: x != y
print(int(f1(f2(f1(a, b), f3(c, d)), f3(f2(b, c), f1(a, d)))))


3
a = int(input())
b = int(input())
c = int(input())
d = int(input())

def gand(x, y):
	return x & y

def gor(x, y):
	return x ^ y

def gxor(x, y):
	return x | y
g1 = gor(a, b)
g2 = gxor(c, d)
g3 = gand(b, c)
g4 = gor(a, d)
t1 = gand(g1, g2)
t2 = gxor(g3, g4)
res = gor(t1, t2)
print(res)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
res = (a ^ b and (c or d)) ^ (b and c or a ^ d)
print(1 if res else 0)


(A, B, C, D) = (int(input()), int(input()), int(input()), int(input()))
print((A ^ B and (C or D)) ^ (B and C or A ^ D))


a = int(input())
b = int(input())
c = int(input())
d = int(input())
q = a ^ b
w = c or d
e = b and c
r = a ^ d
x = q and w
y = e or r
print(x ^ y)


(a, b, c, d) = (int(input()), int(input()), int(input()), int(input()))
x = a ^ b
y = c or d
z = b and c
t = a ^ d
print((x and y) ^ (z or t))


x = int(input())
y = int(input())
z = int(input())
w = int(input())
print((x ^ y and (z or w)) ^ (x ^ w or (y and z)))


a = int(input())
b = int(input())
c = int(input())
d = int(input())
w = a ^ b
x = c | d
y = b & c
z = a ^ d
A = w & x
B = y | z
print(A ^ B)


A = [int(input()) for i in range(4)]
print((A[0] ^ A[1]) & (A[2] | A[3]) ^ (A[1] & A[2] | A[0] ^ A[3]))


a = int(input())
b = int(input())
c = int(input())
d = int(input())

def nor(a, b):
	return not (a or b)
x = a ^ b
y = c or d
z = b and c
t = d ^ a
one = x and y
two = z or t
last = one ^ two
print(last)


a = []
for i in range(4):
	a.append(int(input()))
b = ''
for i in a:
	b += str(i)
num = int(b, 2)
ans = [0 for x in range(16)]
ans[0] = 0
ans[1] = 1
ans[2] = 0
ans[3] = 1
ans[4] = 0
ans[5] = 0
ans[6] = 0
ans[7] = 0
ans[8] = 1
ans[9] = 1
ans[10] = 0
ans[11] = 1
ans[12] = 1
ans[13] = 0
ans[14] = 1
ans[15] = 1
print(ans[num])


a = int(input())
b = int(input())
c = int(input())
d = int(input())
k1 = a ^ b
k2 = c | d
k3 = c & b
k4 = a ^ d
suk1 = k1 & k2
suk2 = k3 | k4
ans = suk1 ^ suk2
print(ans)


def myor(a, b):
	return a | b

def myxor(a, b):
	return a ^ b

def myand(a, b):
	return a & b
op1 = myxor
op2 = myor
op3 = myand
l = [int(input()) for _ in range(4)]
print(op1(op3(op1(l[0], l[1]), op2(l[2], l[3])), op2(op3(l[1], l[2]), op1(l[0], l[3]))))


a = int(input())
b = int(input())
c = int(input())
d = int(input())
A = a ^ b
B = c | d
C = b & c
D = a ^ d
print(A & B ^ (C | D))


a = int(input())
b = int(input())
c = int(input())
d = int(input())
s = a * 1000 + b * 100 + c * 10 + d
if s == 0:
	print(0)
elif s == 1:
	print(1)
elif s == 10:
	print(0)
elif s == 11:
	print(1)
elif s == 100:
	print(0)
elif s == 101:
	print(0)
elif s == 110:
	print(0)
elif s == 111:
	print(0)
elif s == 1000:
	print(1)
elif s == 1001:
	print(1)
elif s == 1010:
	print(0)
elif s == 1011:
	print(1)
elif s == 1100:
	print(1)
elif s == 1101:
	print(0)
elif s == 1110:
	print(1)
elif s == 1111:
	print(1)
else:
	print(0)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
a = int(a)
b = int(b)
c = int(c)
d = int(d)
n = (a ^ b) & (c | d) ^ (b & c | a ^ d)
print(n)


def op1(u, v):
	return u ^ v

def op2(u, v):
	return u | v

def op3(u, v):
	return u & v
a = [int(input()) for _ in range(4)]
b = op1(a[0], a[1])
c = op2(a[2], a[3])
d = op3(a[1], a[2])
e = op1(a[0], a[3])
f = op3(b, c)
g = op2(d, e)
h = op1(f, g)
print(h)


def AND(x, y):
	return x & y

def OR(x, y):
	return x | y

def XOR(x, y):
	return x ^ y
f1 = XOR
f2 = OR
f3 = AND

def main():
	(a, b, c, d) = tuple((int(input()) for __ in range(4)))
	one = f3(f1(a, b), f2(c, d))
	two = f2(f3(b, c), f1(a, d))
	print(f1(one, two))
main()


a = int(input())
b = int(input())
c = int(input())
d = int(input())
ee = a ^ b
ff = c | d
gg = b & c
hh = a ^ d
iii = ee & ff
jjj = gg | hh
r = iii ^ jjj
print(r)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
(a, b, c, d) = (a ^ b, c | d, b & c, a ^ d)
(a, b) = (a & b, c | d)
a = a ^ b
print(1 if a else 0)


def OR(a, b):
	return a ^ b

def XOR(a, b):
	return a | b

def AND(a, b):
	return a & b

def g(a, b, c, d):
	e = OR(a, b)
	f = XOR(c, d)
	g = AND(b, c)
	h = OR(a, d)
	i = AND(e, f)
	j = XOR(g, h)
	return OR(i, j)
a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(g(a, b, c, d))


a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(a & (not c) & (not d) | a & b & c | (not b) & d)


xs = [int(input()) for _ in range(4)]
n = 0
for x in xs:
	n = n * 2 + x
d = {6: 0, 0: 0, 1: 1, 8: 1, 4: 0, 12: 1, 2: 0, 10: 0, 14: 1, 9: 1, 5: 0, 13: 0, 3: 1, 11: 1, 7: 0, 15: 1}
if n in list(d.keys()):
	print(d[n])
else:
	xs = [0] * (10 ** 6 * n)
	raise ValueError()


a = int(input())
b = int(input())
c = int(input())
d = int(input())
x = a ^ b
y = c | d
z = b & c
t = a ^ d
k = x & y
m = z | t
res = k ^ m
print(res)


import itertools
arr = [0, 0, 0, 0]
for i in range(4):
	arr[i] = int(input())

def __OR__(x, y):
	return x ^ y

def __AND__(x, y):
	return x & y

def __XOR__(x, y):
	return x | y
perm = list(itertools.permutations([0, 1, 2, 3]))[0]
res = __OR__(__AND__(__OR__(arr[perm[0]], arr[perm[1]]), __XOR__(arr[perm[2]], arr[perm[3]])), __XOR__(__AND__(arr[perm[1]], arr[perm[2]]), __OR__(arr[perm[0]], arr[perm[3]])))
print(res)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = a ^ b
f = c | d
g = b & c
h = a ^ d
k = e & f
l = g | h
print(l ^ k)


a = [int(input()) for x in range(4)]
b = [a[0] ^ a[1], a[2] | a[3], a[1] & a[2], a[0] ^ a[3]]
c = [b[0] & b[1], b[2] | b[3]]
print(c[0] ^ c[1])


x1 = int(input())
x2 = int(input())
x3 = int(input())
x4 = int(input())
i = str(x1) + str(x2) + str(x3) + str(x4)
o1 = 1 if x1 | x2 == 0 else 0
r1 = 1 if x3 ^ x4 == 1 else 0
a1 = 1 if x2 & x3 == 0 else 0
o2 = 1 if x1 | x4 == 1 else 0
a10 = 1 if o1 & r1 == 0 else 0
r10 = 1 if a1 ^ o2 == 1 else 0
ans = 1 if a10 | r10 == 0 else 0
if i == '0000':
	print(0)
elif i == '0001':
	print(1)
elif i == '0010':
	print(0)
elif i == '0011':
	print(1)
elif i == '0100':
	print(0)
elif i == '0101':
	print(0)
elif i == '0110':
	print(0)
elif i == '0111':
	print(0)
elif i == '1000':
	print(1)
elif i == '1001':
	print(1)
elif i == '1010':
	print(0)
elif i == '1011':
	print(1)
elif i == '1100':
	print(1)
elif i == '1101':
	print(0)
elif i == '1110':
	print(1)
elif i == '1111':
	print(1)


a = int(input())
b = int(input())
c = int(input())
d = int(input())
print('{}'.format((a ^ b) & (c | d) ^ (b & c | a ^ d)))


a = int(input())
b = int(input())
c = int(input())
d = int(input())
x = a ^ b
y = c or d
z = b and c
t = a ^ d
xy = x and y
zt = z or t
r = xy ^ zt
print(r)


import sys

def a(p, q):
	return p ^ q

def b(p, q):
	return p | q

def c(p, q):
	return p & q
f = [a, b, c]
mask = [0, 1, 2]
vec = []
for line in sys.stdin:
	vec.extend(line.split())
v = [int(x) for x in vec]
q = f[mask[0]](v[0], v[1])
w = f[mask[1]](v[2], v[3])
e = f[mask[2]](v[1], v[2])
r = f[mask[0]](v[0], v[3])
t = f[mask[2]](q, w)
y = f[mask[1]](e, r)
u = f[mask[0]](t, y)
print(u)


(a, b, c, d) = (int(input()), int(input()), int(input()), int(input()))
(w, o, r, m) = (a ^ b, c | d, b & c, a ^ d)
(f, q) = (w & o, r | m)
print(f ^ q)


op = [int.__xor__, int.__or__, int.__and__]
l = [int(input()) for _ in range(4)]
r = op[0](op[2](op[0](l[0], l[1]), op[1](l[2], l[3])), op[1](op[2](l[1], l[2]), op[0](l[0], l[3])))
print(r)


A = int(input())
B = int(input())
C = int(input())
D = int(input())
a = A ^ B
b = C | D
c = B & C
d = A ^ D
e = a & b
f = c | d
g = e ^ f
print(g)


import sys
xs = [int(sys.stdin.readline().strip()) for _ in range(4)]

def OR(x, y):
	return x + y - x * y

def AND(x, y):
	return x * y

def XOR(x, y):
	return (x + y) % 2

def f(A, B, C):

	def h(xs):
		return A(B(A(xs[0], xs[1]), C(xs[2], xs[3])), C(B(xs[1], xs[2]), A(xs[0], xs[3])))
	return h
print(f(XOR, AND, OR)(xs))


from itertools import combinations, permutations
from operator import *
NUM = 1

def main():
	funcs = [and_, or_, ne]
	funcs += [lambda a, b, f=f: not f(a, b) for f in funcs]
	num = -1
	for (fd, fu, fy) in combinations(funcs, 3):
		for (fd, fu, fy) in permutations((fd, fu, fy)):
			num += 1
			if num == NUM:
				(x0, x1, x2, x3) = (int(input()) for i in range(4))
				a = fu(x0, x1)
				b = fy(x2, x3)
				c = fd(x1, x2)
				d = fu(x0, x3)
				e = fd(a, b)
				f = fy(c, d)
				g = fu(e, f)
				print(int(g))
				break
main()


a = int(input())
b = int(input())
c = int(input())
d = int(input())
p = a ^ b
q = c | d
r = b & c
s = a ^ d
x = p & q
y = r | s
z = x ^ y
print(z)


(a, b, c, d) = map(int, [input(), input(), input(), input()])
print((a ^ b) & (c | d) ^ (b & c | a ^ d))


A = []
for i in range(4):
	A.append(int(input()))
a = A[0] ^ A[1]
b = A[2] | A[3]
c = A[1] & A[2]
d = A[0] ^ A[3]
e = a & b
f = c | d
print(e ^ f)