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

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

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

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

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

j = A("j")
g = B("g")
k = C("k")
a = D("a")
m = E("m")
n = C("n")
e = D("e")
i = C("i")

j.p = k
g.w = j
g.z = j
g.r = j
g.o = i
k.p = j
k.w = j
a.v = m
a.p = j
m.y = g
m.z = g
m.r = g
m.p = i
n.p = j
n.w = j
e.v = m
e.p = j
i.p = j
i.w = j
assert m.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

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

j = A("j")
g = B("g")
k = C("k")
a = D("a")
m = E("m")
n = C("n")
e = D("e")
i = C("i")

j.p = k
g.w = j
g.z = j
g.r = j
g.o = i
k.p = j
k.w = j
a.v = m
a.p = j
m.y = g
m.z = g
m.r = g
m.p = i
n.p = j
n.w = j
e.v = m
e.p = j
i.p = j
i.w = j
assert m.p.p.p.p.p.p.txt == "j"