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

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

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

class D:
    def __init__(self, txt: str):
        self.r: D = None
        self.v: D = None
        self.txt = txt

c = A("c")
l = B("l")
f = C("f")
a = D("a")
m = C("m")
d = B("d")
h = D("h")
e = C("e")

c.z = a
c.q = f
c.w = m
c.x = h
l.p = c
f.z = h
f.u = a
f.r = c
a.r = h
a.v = h
m.z = h
m.u = a
m.r = c
d.p = c
h.r = a
h.v = a
e.z = a
e.u = a
e.r = c
assert e.r.w.z.r.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.q: C = None
        self.w: C = None
        self.x: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: D = None
        self.v: D = None
        self.txt = txt

c = A("c")
l = B("l")
f = C("f")
a = D("a")
m = C("m")
d = B("d")
h = D("h")
e = C("e")

c.z = a
c.q = f
c.w = m
c.x = h
l.p = c
f.z = h
f.u = a
f.r = c
a.r = h
a.v = h
m.z = h
m.u = a
m.r = c
d.p = c
h.r = a
h.v = a
e.z = a
e.u = a
e.r = c
assert e.r.w.z.r.v.v.v.txt == "h"