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

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

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

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

b = A("b")
i = B("i")
k = C("k")
d = D("d")

b.s = d
i.y = k
i.t = d
k.o = i
k.r = b
d.s = k
assert i.y.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

b = A("b")
i = B("i")
k = C("k")
d = D("d")

b.s = d
i.y = k
i.t = d
k.o = i
k.r = b
d.s = k
assert i.y.r.s.txt == "d"