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

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

class C:
    def __init__(self, txt: str):
        self.q: D = None
        self.t: E = None
        self.r: A = None
        self.s: E = None
        self.z: B = None
        self.txt = txt

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.q: D = None
        self.t: E = None
        self.r: A = None
        self.s: E = None
        self.z: B = None
        self.txt = txt

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

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

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

e.s = c
e.v = c
a.y = h
a.v = h
d.q = c
d.t = h
d.s = h
d.r = e
d.z = a
c.w = f
c.y = h
c.o = e
c.p = e
c.q = b
h.z = c
b.y = h
b.v = h
f.s = c
f.v = c
assert d.s.z.y.z.q.y.txt == "h"