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

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

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

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

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

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

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

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

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

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

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

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

k.x = f
k.v = e
k.s = e
k.z = g
f.t = h
e.r = f
e.w = g
e.q = g
h.t = k
h.w = k
g.q = f
g.o = e
g.p = k
assert g.p.v.q.p.txt == "k"