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

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

d = A("d")
b = B("b")
m = B("m")

d.y = m
d.x = b
b.r = m
b.t = m
m.r = b
m.t = b
assert d.y.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.x: B = None
        self.txt = txt

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

d = A("d")
b = B("b")
m = B("m")

d.y = m
d.x = b
b.r = m
b.t = m
m.r = b
m.t = b
assert d.y.r.t.txt == "m"