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

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

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

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

k = A("k")
n = B("n")
b = C("b")
a = D("a")

k.x = n
k.p = b
n.o = b
b.w = a
a.w = b
assert k.x.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.p: C = None
        self.txt = txt

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

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

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

k = A("k")
n = B("n")
b = C("b")
a = D("a")

k.x = n
k.p = b
n.o = b
b.w = a
a.w = b
assert k.x.o.w.txt == "a"