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

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

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

class D:
    def __init__(self, txt: str):
        self.s: C = None
        self.z: C = None
        self.u: C = None
        self.v: C = None
        self.x: A = None
        self.txt = txt

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

e = A("e")
c = B("c")
f = C("f")
g = D("g")
k = E("k")

e.p = f
e.x = c
c.w = g
f.r = c
f.p = k
f.s = e
g.s = f
g.z = f
g.u = f
g.v = f
g.x = e
k.q = e
assert k.q.x.w.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.x: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.s: C = None
        self.z: C = None
        self.u: C = None
        self.v: C = None
        self.x: A = None
        self.txt = txt

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

e = A("e")
c = B("c")
f = C("f")
g = D("g")
k = E("k")

e.p = f
e.x = c
c.w = g
f.r = c
f.p = k
f.s = e
g.s = f
g.z = f
g.u = f
g.v = f
g.x = e
k.q = e
assert k.q.x.w.v.p.txt == "k"