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

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

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

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

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

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

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

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

d.p = b
d.u = b
d.t = b
b.o = d
b.q = d
c.t = d
assert b.o.u.q.txt == "d"