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

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

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

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

e = A("e")
c = B("c")
k = C("k")
d = D("d")
b = C("b")

e.t = c
c.w = e
k.w = d
k.p = d
k.v = d
d.t = c
d.p = k
b.w = d
b.p = d
b.v = d
assert b.p.p.w.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

e = A("e")
c = B("c")
k = C("k")
d = D("d")
b = C("b")

e.t = c
c.w = e
k.w = d
k.p = d
k.v = d
d.t = c
d.p = k
b.w = d
b.p = d
b.v = d
assert b.p.p.w.p.v.txt == "d"