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

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

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

f = A("f")
b = B("b")
c = C("c")
h = A("h")
i = C("i")

f.z = i
f.v = b
b.t = c
b.x = i
c.y = b
c.z = b
c.w = b
h.z = c
h.v = b
i.y = b
i.z = b
i.w = b
assert h.z.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.v: B = None
        self.txt = txt

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

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

f = A("f")
b = B("b")
c = C("c")
h = A("h")
i = C("i")

f.z = i
f.v = b
b.t = c
b.x = i
c.y = b
c.z = b
c.w = b
h.z = c
h.v = b
i.y = b
i.z = b
i.w = b
assert h.z.z.t.txt == "c"