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

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

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

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

e = A("e")
f = B("f")
d = C("d")
h = D("h")
a = A("a")
c = D("c")
b = D("b")
n = B("n")

e.w = d
f.s = e
f.v = e
f.u = d
f.t = b
d.q = b
d.w = e
d.o = h
h.z = d
a.w = d
c.z = d
b.z = d
n.s = a
n.v = a
n.u = d
n.t = b
assert f.s.w.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

e = A("e")
f = B("f")
d = C("d")
h = D("h")
a = A("a")
c = D("c")
b = D("b")
n = B("n")

e.w = d
f.s = e
f.v = e
f.u = d
f.t = b
d.q = b
d.w = e
d.o = h
h.z = d
a.w = d
c.z = d
b.z = d
n.s = a
n.v = a
n.u = d
n.t = b
assert f.s.w.q.z.txt == "d"