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

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

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

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

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

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

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

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

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

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

h.p = k
h.u = a
e.v = h
l.z = m
l.p = m
l.o = e
j.y = a
j.w = a
j.q = h
a.y = j
a.w = j
a.q = h
k.v = h
m.z = l
m.p = l
m.o = e
assert e.v.u.q.p.v.txt == "h"