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

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

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

d = A("d")
f = B("f")
g = C("g")
c = A("c")
n = C("n")

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

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

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

d = A("d")
f = B("f")
g = C("g")
c = A("c")
n = C("n")

d.u = n
d.t = f
d.s = f
f.r = n
f.p = c
g.z = f
c.u = n
c.t = f
c.s = f
n.z = f
assert c.u.z.r.txt == "n"