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

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

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

d = A("d")
f = B("f")
g = C("g")
c = A("c")
m = C("m")
l = C("l")
e = B("e")

d.t = m
d.w = m
d.u = e
f.s = g
f.w = c
g.s = e
c.t = g
c.w = g
c.u = f
m.s = f
l.s = e
e.s = l
e.w = c
assert d.t.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.u: B = None
        self.w: C = None
        self.txt = txt

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

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

d = A("d")
f = B("f")
g = C("g")
c = A("c")
m = C("m")
l = C("l")
e = B("e")

d.t = m
d.w = m
d.u = e
f.s = g
f.w = c
g.s = e
c.t = g
c.w = g
c.u = f
m.s = f
l.s = e
e.s = l
e.w = c
assert d.t.s.w.txt == "c"