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

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

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

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

b.w = m
b.x = h
m.s = g
m.t = g
m.z = h
h.w = m
h.s = m
h.u = b
g.s = m
g.t = m
g.z = h
assert h.u.w.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: C = None
        self.txt = txt

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

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

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

b.w = m
b.x = h
m.s = g
m.t = g
m.z = h
h.w = m
h.s = m
h.u = b
g.s = m
g.t = m
g.z = h
assert h.u.w.s.z.txt == "h"