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

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

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

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

d = A("d")
f = B("f")
b = C("b")
n = D("n")
l = C("l")
m = A("m")
a = C("a")
k = D("k")

d.p = n
f.u = k
f.v = m
f.w = m
f.o = l
b.w = l
b.x = f
n.q = f
n.z = d
l.w = a
l.x = f
m.p = k
a.w = l
a.x = f
k.q = f
k.z = m
assert m.p.q.o.x.v.p.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

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

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

d = A("d")
f = B("f")
b = C("b")
n = D("n")
l = C("l")
m = A("m")
a = C("a")
k = D("k")

d.p = n
f.u = k
f.v = m
f.w = m
f.o = l
b.w = l
b.x = f
n.q = f
n.z = d
l.w = a
l.x = f
m.p = k
a.w = l
a.x = f
k.q = f
k.z = m
assert m.p.q.o.x.v.p.z.p.txt == "k"