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

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

k = A("k")
h = B("h")
d = C("d")
l = D("l")
e = C("e")
i = C("i")
m = A("m")

k.p = m
k.q = m
k.v = m
k.y = h
h.o = l
d.o = h
d.p = l
d.z = l
d.x = e
l.q = h
l.u = m
e.o = h
e.p = l
e.z = l
e.x = d
i.o = h
i.p = l
i.z = l
i.x = d
m.p = k
m.q = k
m.v = k
m.y = h
assert e.x.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.y: B = None
        self.q: A = None
        self.v: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

k = A("k")
h = B("h")
d = C("d")
l = D("l")
e = C("e")
i = C("i")
m = A("m")

k.p = m
k.q = m
k.v = m
k.y = h
h.o = l
d.o = h
d.p = l
d.z = l
d.x = e
l.q = h
l.u = m
e.o = h
e.p = l
e.z = l
e.x = d
i.o = h
i.p = l
i.z = l
i.x = d
m.p = k
m.q = k
m.v = k
m.y = h
assert e.x.z.q.txt == "h"