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

class B:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

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

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

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

k = A("k")
b = B("b")
j = C("j")
g = D("g")
c = E("c")

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

class B:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

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

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

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

k = A("k")
b = B("b")
j = C("j")
g = D("g")
c = E("c")

k.p = j
k.q = g
k.v = b
b.u = c
j.z = b
g.x = j
g.s = c
c.p = g
assert c.p.s.p.txt == "g"