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

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

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

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

d = A("d")
l = B("l")
n = C("n")
i = D("i")
g = D("g")
a = D("a")

d.p = n
l.r = n
l.p = n
n.v = g
n.w = g
n.s = l
n.t = d
i.v = g
i.p = l
i.y = d
g.v = i
g.p = l
g.y = d
a.v = i
a.p = l
a.y = d
assert d.p.w.y.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

d = A("d")
l = B("l")
n = C("n")
i = D("i")
g = D("g")
a = D("a")

d.p = n
l.r = n
l.p = n
n.v = g
n.w = g
n.s = l
n.t = d
i.v = g
i.p = l
i.y = d
g.v = i
g.p = l
g.y = d
a.v = i
a.p = l
a.y = d
assert d.p.w.y.p.s.txt == "l"