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

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

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

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

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

a.y = g
a.p = j
g.z = c
g.w = d
n.p = i
n.u = d
n.y = c
j.v = c
j.u = c
i.y = l
i.p = j
l.z = c
l.w = d
c.p = a
c.u = j
c.y = n
d.v = c
d.u = n
assert n.u.v.y.u.u.p.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.p: D = None
        self.txt = txt

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

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

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

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

a.y = g
a.p = j
g.z = c
g.w = d
n.p = i
n.u = d
n.y = c
j.v = c
j.u = c
i.y = l
i.p = j
l.z = c
l.w = d
c.p = a
c.u = j
c.y = n
d.v = c
d.u = n
assert n.u.v.y.u.u.p.y.w.txt == "d"