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

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.o: C = None
        self.q: A = None
        self.u: A = None
        self.txt = txt

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

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

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

k = A("k")
m = B("m")
l = C("l")
e = D("e")
n = E("n")
d = E("d")

k.p = m
m.v = e
m.o = l
m.q = k
m.u = k
l.r = m
e.r = l
e.z = n
n.o = k
d.o = k
assert k.p.o.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.o: C = None
        self.q: A = None
        self.u: A = None
        self.txt = txt

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

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

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

k = A("k")
m = B("m")
l = C("l")
e = D("e")
n = E("n")
d = E("d")

k.p = m
m.v = e
m.o = l
m.q = k
m.u = k
l.r = m
e.r = l
e.z = n
n.o = k
d.o = k
assert k.p.o.r.q.txt == "k"