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

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

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

e = A("e")
h = B("h")
a = C("a")
g = B("g")
n = B("n")
b = B("b")
c = B("c")
d = B("d")
k = B("k")

e.t = a
e.z = a
h.x = a
a.z = b
g.x = a
n.x = a
b.x = a
c.x = a
d.x = a
k.x = a
assert h.x.z.x.z.x.z.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.z: C = None
        self.txt = txt

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

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

e = A("e")
h = B("h")
a = C("a")
g = B("g")
n = B("n")
b = B("b")
c = B("c")
d = B("d")
k = B("k")

e.t = a
e.z = a
h.x = a
a.z = b
g.x = a
n.x = a
b.x = a
c.x = a
d.x = a
k.x = a
assert h.x.z.x.z.x.z.x.z.txt == "b"