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

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

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

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

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

i.u = e
i.w = c
l.u = f
l.y = c
l.p = c
l.o = c
d.z = l
d.p = c
d.w = h
d.u = e
f.q = h
f.t = d
f.z = l
f.p = l
c.u = f
c.w = i
e.q = h
e.t = h
e.z = l
e.p = l
h.z = l
h.p = i
h.w = d
h.u = f
assert f.q.w.w.p.w.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.w: A = None
        self.txt = txt

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

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

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

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

i.u = e
i.w = c
l.u = f
l.y = c
l.p = c
l.o = c
d.z = l
d.p = c
d.w = h
d.u = e
f.q = h
f.t = d
f.z = l
f.p = l
c.u = f
c.w = i
e.q = h
e.t = h
e.z = l
e.p = l
h.z = l
h.p = i
h.w = d
h.u = f
assert f.q.w.w.p.w.u.q.txt == "h"