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

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

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

a = A("a")
f = B("f")
g = C("g")
d = C("d")

a.s = f
f.p = a
f.t = a
f.u = a
g.z = f
g.x = f
g.v = a
d.z = f
d.x = f
d.v = a
assert a.s.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

a = A("a")
f = B("f")
g = C("g")
d = C("d")

a.s = f
f.p = a
f.t = a
f.u = a
g.z = f
g.x = f
g.v = a
d.z = f
d.x = f
d.v = a
assert a.s.t.s.txt == "f"