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

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

e = A("e")
b = B("b")
c = A("c")
j = A("j")
a = A("a")
d = B("d")
h = A("h")
f = B("f")
k = A("k")

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

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

e = A("e")
b = B("b")
c = A("c")
j = A("j")
a = A("a")
d = B("d")
h = A("h")
f = B("f")
k = A("k")

e.s = k
e.z = f
b.v = f
c.s = j
c.z = d
j.s = c
j.z = b
a.s = e
a.z = b
d.v = f
h.s = a
h.z = f
f.v = d
k.s = e
k.z = d
assert k.s.s.z.v.v.v.v.v.v.txt == "d"