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

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

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

m = A("m")
i = B("i")
d = C("d")
j = B("j")
l = B("l")

m.u = d
i.t = m
i.u = d
d.r = l
d.s = i
d.o = m
j.t = m
j.u = d
l.t = m
l.u = d
assert j.u.s.t.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

m = A("m")
i = B("i")
d = C("d")
j = B("j")
l = B("l")

m.u = d
i.t = m
i.u = d
d.r = l
d.s = i
d.o = m
j.t = m
j.u = d
l.t = m
l.u = d
assert j.u.s.t.u.o.txt == "m"