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

class B:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

d = A("d")
k = B("k")
m = B("m")
i = A("i")
c = B("c")
a = A("a")
j = B("j")
e = B("e")

d.z = a
d.v = j
k.s = e
m.s = j
i.z = a
i.v = c
c.s = e
a.z = i
a.v = k
j.s = k
e.s = c
assert c.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.v: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

d = A("d")
k = B("k")
m = B("m")
i = A("i")
c = B("c")
a = A("a")
j = B("j")
e = B("e")

d.z = a
d.v = j
k.s = e
m.s = j
i.z = a
i.v = c
c.s = e
a.z = i
a.v = k
j.s = k
e.s = c
assert c.s.s.s.txt == "e"