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

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.s: A = None
        self.u: A = None
        self.p: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.s: A = None
        self.txt = txt

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

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

d = A("d")
h = B("h")
c = C("c")
m = D("m")
g = E("g")
l = E("l")
n = C("n")
a = A("a")
b = A("b")

d.z = a
d.y = a
h.x = a
h.u = a
h.p = a
h.s = b
c.p = l
c.s = a
m.t = c
m.z = g
g.z = m
g.p = n
g.w = n
g.v = c
l.z = m
l.p = c
l.w = n
l.v = n
n.p = g
n.s = b
a.z = d
a.y = d
b.z = a
b.y = a
assert a.z.y.z.y.y.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.y: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.s: A = None
        self.u: A = None
        self.p: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.s: A = None
        self.txt = txt

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

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

d = A("d")
h = B("h")
c = C("c")
m = D("m")
g = E("g")
l = E("l")
n = C("n")
a = A("a")
b = A("b")

d.z = a
d.y = a
h.x = a
h.u = a
h.p = a
h.s = b
c.p = l
c.s = a
m.t = c
m.z = g
g.z = m
g.p = n
g.w = n
g.v = c
l.z = m
l.p = c
l.w = n
l.v = n
n.p = g
n.s = b
a.z = d
a.y = d
b.z = a
b.y = a
assert a.z.y.z.y.y.z.y.txt == "d"