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

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

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

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

m.t = e
e.s = m
e.y = m
e.w = d
g.x = e
g.y = m
f.x = e
f.y = m
j.x = e
j.y = m
d.x = e
d.y = m
assert e.s.t.y.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

m.t = e
e.s = m
e.y = m
e.w = d
g.x = e
g.y = m
f.x = e
f.y = m
j.x = e
j.y = m
d.x = e
d.y = m
assert e.s.t.y.t.s.txt == "m"