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

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

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

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

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

b = A("b")
e = B("e")
i = C("i")
j = D("j")
d = E("d")
m = E("m")
c = C("c")
f = E("f")
k = E("k")
n = D("n")

b.p = c
e.o = c
e.p = b
i.z = c
j.q = c
d.y = e
d.z = e
d.r = e
m.y = e
m.z = e
m.r = e
c.z = i
f.y = e
f.z = e
f.r = e
k.y = e
k.z = e
k.r = e
n.q = c
assert e.p.p.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

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

b = A("b")
e = B("e")
i = C("i")
j = D("j")
d = E("d")
m = E("m")
c = C("c")
f = E("f")
k = E("k")
n = D("n")

b.p = c
e.o = c
e.p = b
i.z = c
j.q = c
d.y = e
d.z = e
d.r = e
m.y = e
m.z = e
m.r = e
c.z = i
f.y = e
f.z = e
f.r = e
k.y = e
k.z = e
k.r = e
n.q = c
assert e.p.p.z.z.z.z.z.z.txt == "c"