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

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

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

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

d.u = c
d.r = c
k.x = c
k.t = c
c.z = d
assert c.z.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.r: C = None
        self.txt = txt

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

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

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

d.u = c
d.r = c
k.x = c
k.t = c
c.z = d
assert c.z.r.z.txt == "d"