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

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

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

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

m = A("m")
j = B("j")
h = C("h")
a = D("a")
n = A("n")
k = D("k")

m.p = h
m.q = j
m.v = a
m.u = a
j.q = k
h.o = j
a.v = j
a.o = h
a.z = h
n.p = h
n.q = j
n.v = a
n.u = k
k.v = j
k.o = h
k.z = h
assert h.o.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.q: B = None
        self.v: D = None
        self.u: D = None
        self.txt = txt

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

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

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

m = A("m")
j = B("j")
h = C("h")
a = D("a")
n = A("n")
k = D("k")

m.p = h
m.q = j
m.v = a
m.u = a
j.q = k
h.o = j
a.v = j
a.o = h
a.z = h
n.p = h
n.q = j
n.v = a
n.u = k
k.v = j
k.o = h
k.z = h
assert h.o.q.z.txt == "h"