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

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

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

b = A("b")
g = B("g")
m = C("m")
h = B("h")
a = B("a")
e = A("e")

b.x = h
g.z = h
m.y = h
m.v = g
h.z = g
a.z = g
e.x = a
assert h.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

b = A("b")
g = B("g")
m = C("m")
h = B("h")
a = B("a")
e = A("e")

b.x = h
g.z = h
m.y = h
m.v = g
h.z = g
a.z = g
e.x = a
assert h.z.z.z.z.z.z.txt == "h"