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

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

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

b = A("b")
e = B("e")
d = C("d")
h = C("h")
m = B("m")

b.x = m
e.w = b
e.u = m
d.w = m
h.w = m
m.w = b
m.u = e
assert b.x.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

b = A("b")
e = B("e")
d = C("d")
h = C("h")
m = B("m")

b.x = m
e.w = b
e.u = m
d.w = m
h.w = m
m.w = b
m.u = e
assert b.x.u.w.txt == "b"