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

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

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

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

b = A("b")
k = B("k")
e = C("e")
l = D("l")

b.y = e
k.p = e
k.w = b
k.t = l
e.o = k
e.s = b
l.x = k
assert l.x.w.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

b = A("b")
k = B("k")
e = C("e")
l = D("l")

b.y = e
k.p = e
k.w = b
k.t = l
e.o = k
e.s = b
l.x = k
assert l.x.w.y.s.txt == "b"