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

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

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

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

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

b = A("b")
i = B("i")
k = C("k")
n = D("n")
d = E("d")
h = C("h")
f = A("f")
c = B("c")
a = A("a")

b.y = c
i.z = c
k.y = a
k.x = d
k.v = h
n.y = k
d.p = b
d.x = i
d.w = i
d.o = n
h.y = f
h.x = d
h.v = k
f.y = i
c.z = i
a.y = i
assert d.w.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

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

b = A("b")
i = B("i")
k = C("k")
n = D("n")
d = E("d")
h = C("h")
f = A("f")
c = B("c")
a = A("a")

b.y = c
i.z = c
k.y = a
k.x = d
k.v = h
n.y = k
d.p = b
d.x = i
d.w = i
d.o = n
h.y = f
h.x = d
h.v = k
f.y = i
c.z = i
a.y = i
assert d.w.z.z.z.z.z.txt == "c"