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

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

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

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

l = A("l")
d = B("d")
j = C("j")
b = D("b")

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

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

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

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

l = A("l")
d = B("d")
j = C("j")
b = D("b")

l.r = j
d.y = j
j.o = b
b.r = j
assert j.o.r.o.r.txt == "j"