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

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

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

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

n = A("n")
f = B("f")
d = C("d")
c = D("c")
l = D("l")
a = A("a")
h = D("h")
i = A("i")
g = B("g")
e = A("e")

n.z = d
f.r = a
f.o = l
f.q = l
d.q = a
d.r = a
d.y = l
c.t = g
c.u = n
l.t = f
l.u = a
a.z = d
h.t = g
h.u = i
i.z = d
g.r = n
g.o = c
g.q = l
e.z = d
assert a.z.r.z.y.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

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

n = A("n")
f = B("f")
d = C("d")
c = D("c")
l = D("l")
a = A("a")
h = D("h")
i = A("i")
g = B("g")
e = A("e")

n.z = d
f.r = a
f.o = l
f.q = l
d.q = a
d.r = a
d.y = l
c.t = g
c.u = n
l.t = f
l.u = a
a.z = d
h.t = g
h.u = i
i.z = d
g.r = n
g.o = c
g.q = l
e.z = d
assert a.z.r.z.y.u.z.txt == "d"