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

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

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

b = A("b")
d = B("d")
a = C("a")
c = A("c")

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

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

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

b = A("b")
d = B("d")
a = C("a")
c = A("c")

b.t = d
b.z = d
d.p = a
d.s = c
a.o = d
c.t = d
c.z = d
assert b.t.s.z.txt == "d"