class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.y: D = None
        self.z: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.s: B = None
        self.r: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

h = A("h")
n = B("n")
a = C("a")
k = D("k")
c = A("c")
f = B("f")
m = A("m")
b = B("b")
i = A("i")
j = D("j")

h.p = i
h.y = j
h.z = a
n.v = k
n.s = b
n.r = c
a.q = n
a.v = c
k.q = i
c.p = m
c.y = k
c.z = a
f.v = j
f.s = b
f.r = m
m.p = h
m.y = j
m.z = a
b.v = j
b.s = f
b.r = h
i.p = h
i.y = k
i.z = a
j.q = i
assert b.v.q.z.v.y.q.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.y: D = None
        self.z: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.s: B = None
        self.r: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

h = A("h")
n = B("n")
a = C("a")
k = D("k")
c = A("c")
f = B("f")
m = A("m")
b = B("b")
i = A("i")
j = D("j")

h.p = i
h.y = j
h.z = a
n.v = k
n.s = b
n.r = c
a.q = n
a.v = c
k.q = i
c.p = m
c.y = k
c.z = a
f.v = j
f.s = b
f.r = m
m.p = h
m.y = j
m.z = a
b.v = j
b.s = f
b.r = h
i.p = h
i.y = k
i.z = a
j.q = i
assert b.v.q.z.v.y.q.z.q.txt == "n"