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

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

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

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

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

l.w = k
l.q = n
l.p = e
h.t = l
h.u = k
g.p = e
g.v = l
g.z = m
n.z = k
n.t = l
e.p = g
e.v = l
e.z = n
m.z = h
m.t = l
k.t = l
k.u = h
assert l.q.t.q.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: D = None
        self.p: C = None
        self.txt = txt

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

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

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

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

l.w = k
l.q = n
l.p = e
h.t = l
h.u = k
g.p = e
g.v = l
g.z = m
n.z = k
n.t = l
e.p = g
e.v = l
e.z = n
m.z = h
m.t = l
k.t = l
k.u = h
assert l.q.t.q.z.u.txt == "h"