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

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

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

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

d = A("d")
n = B("n")
l = C("l")
e = D("e")
c = D("c")

d.t = e
n.y = d
n.q = c
l.t = d
l.x = d
l.p = d
l.v = n
e.w = l
c.w = l
assert l.v.q.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

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

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

d = A("d")
n = B("n")
l = C("l")
e = D("e")
c = D("c")

d.t = e
n.y = d
n.q = c
l.t = d
l.x = d
l.p = d
l.v = n
e.w = l
c.w = l
assert l.v.q.w.p.txt == "d"