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

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

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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

b = A("b")
l = B("l")
e = C("e")
d = D("d")
n = A("n")

b.p = e
l.r = d
l.p = d
e.o = b
d.y = e
n.p = e
assert e.o.p.o.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

b = A("b")
l = B("l")
e = C("e")
d = D("d")
n = A("n")

b.p = e
l.r = d
l.p = d
e.o = b
d.y = e
n.p = e
assert e.o.p.o.p.o.txt == "b"