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

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

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

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

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

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

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

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

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