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

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

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

b = A("b")
d = B("d")
k = C("k")
l = C("l")

b.y = d
d.s = b
d.p = b
k.u = d
k.t = d
l.u = d
l.t = d
assert d.p.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

b = A("b")
d = B("d")
k = C("k")
l = C("l")

b.y = d
d.s = b
d.p = b
k.u = d
k.t = d
l.u = d
l.t = d
assert d.p.y.s.txt == "b"