class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: B = None
        self.w: B = None
        self.txt = txt

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

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

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

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

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

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

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

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

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

k.x = j
k.r = j
k.w = j
j.y = m
j.w = e
m.z = h
m.v = h
e.q = k
n.y = h
n.w = e
l.q = a
a.x = n
a.r = n
a.w = j
h.z = m
h.v = m
assert e.q.x.y.v.z.v.txt == "h"