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

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

class C:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

h = A("h")
j = B("j")
a = C("a")
n = D("n")
i = C("i")
f = D("f")
l = B("l")
m = A("m")
e = A("e")

h.q = m
j.p = n
j.v = m
j.z = a
a.u = f
n.x = l
n.p = l
n.r = i
n.z = i
i.u = f
f.x = j
f.p = j
f.r = a
f.z = a
l.p = n
l.v = m
l.z = a
m.q = e
e.q = h
assert j.z.u.z.u.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

h = A("h")
j = B("j")
a = C("a")
n = D("n")
i = C("i")
f = D("f")
l = B("l")
m = A("m")
e = A("e")

h.q = m
j.p = n
j.v = m
j.z = a
a.u = f
n.x = l
n.p = l
n.r = i
n.z = i
i.u = f
f.x = j
f.p = j
f.r = a
f.z = a
l.p = n
l.v = m
l.z = a
m.q = e
e.q = h
assert j.z.u.z.u.x.z.txt == "a"