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

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

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

c = A("c")
d = B("d")
i = C("i")

c.u = i
c.s = d
d.t = c
i.r = d
assert c.s.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.s: B = None
        self.txt = txt

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

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

c = A("c")
d = B("d")
i = C("i")

c.u = i
c.s = d
d.t = c
i.r = d
assert c.s.t.s.txt == "d"