class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.y: B = None
        self.q: B = None
        self.s: C = None
        self.txt = txt

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

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

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

c = A("c")
b = B("b")
a = C("a")
g = D("g")
m = D("m")
h = B("h")
n = C("n")

c.z = b
c.q = b
c.y = h
c.s = n
b.z = h
b.o = c
b.u = c
b.w = c
a.y = g
a.v = b
a.p = n
g.t = b
g.z = n
m.t = h
m.z = n
h.z = b
h.o = c
h.u = c
h.w = c
n.y = m
n.v = h
n.p = a
assert c.z.z.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.y: B = None
        self.q: B = None
        self.s: C = None
        self.txt = txt

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

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

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

c = A("c")
b = B("b")
a = C("a")
g = D("g")
m = D("m")
h = B("h")
n = C("n")

c.z = b
c.q = b
c.y = h
c.s = n
b.z = h
b.o = c
b.u = c
b.w = c
a.y = g
a.v = b
a.p = n
g.t = b
g.z = n
m.t = h
m.z = n
h.z = b
h.o = c
h.u = c
h.w = c
n.y = m
n.v = h
n.p = a
assert c.z.z.w.y.txt == "h"