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

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

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

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

j = A("j")
i = B("i")
m = C("m")
e = D("e")
h = C("h")

j.p = i
j.u = i
j.v = e
j.o = e
i.q = j
i.o = h
i.w = e
m.z = j
m.q = e
e.o = i
e.w = i
e.s = m
e.r = h
h.z = j
h.q = e
assert m.z.p.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: B = None
        self.v: D = None
        self.o: D = None
        self.txt = txt

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

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

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

j = A("j")
i = B("i")
m = C("m")
e = D("e")
h = C("h")

j.p = i
j.u = i
j.v = e
j.o = e
i.q = j
i.o = h
i.w = e
m.z = j
m.q = e
e.o = i
e.w = i
e.s = m
e.r = h
h.z = j
h.q = e
assert m.z.p.q.o.txt == "e"