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

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

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

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

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

g = A("g")
i = B("i")
m = C("m")
c = D("c")
d = E("d")
l = D("l")
k = C("k")
a = A("a")
f = B("f")
n = D("n")

g.y = d
i.v = c
i.z = f
m.z = i
m.q = d
c.v = i
c.p = n
c.r = d
c.z = l
d.t = m
l.v = i
l.p = c
l.r = d
l.z = n
k.z = f
k.q = d
a.y = d
f.v = c
f.z = i
n.v = f
n.p = l
n.r = d
n.z = c
assert m.q.t.q.t.z.v.v.v.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.txt = txt

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

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

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

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

g = A("g")
i = B("i")
m = C("m")
c = D("c")
d = E("d")
l = D("l")
k = C("k")
a = A("a")
f = B("f")
n = D("n")

g.y = d
i.v = c
i.z = f
m.z = i
m.q = d
c.v = i
c.p = n
c.r = d
c.z = l
d.t = m
l.v = i
l.p = c
l.r = d
l.z = n
k.z = f
k.q = d
a.y = d
f.v = c
f.z = i
n.v = f
n.p = l
n.r = d
n.z = c
assert m.q.t.q.t.z.v.v.v.v.z.txt == "f"