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

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

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

c = A("c")
l = B("l")
i = C("i")
m = A("m")

c.u = m
c.t = l
l.w = m
i.x = l
m.u = c
m.t = l
assert m.u.t.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.t: B = None
        self.txt = txt

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

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

c = A("c")
l = B("l")
i = C("i")
m = A("m")

c.u = m
c.t = l
l.w = m
i.x = l
m.u = c
m.t = l
assert m.u.t.w.u.txt == "c"