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

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

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

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

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

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

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

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

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

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

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