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

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

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

d = A("d")
b = B("b")
n = C("n")
f = B("f")

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

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

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

d = A("d")
b = B("b")
n = C("n")
f = B("f")

d.u = n
d.s = n
d.z = f
b.t = f
b.u = n
n.o = b
n.s = d
n.p = f
f.t = b
f.u = n
assert d.s.o.u.txt == "n"