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

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

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

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

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

k = A("k")
j = B("j")
m = C("m")
c = D("c")
e = E("e")

k.t = j
k.o = e
j.q = m
m.v = k
c.p = m
e.x = c
e.r = c
e.q = m
assert c.p.v.t.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.o: E = None
        self.txt = txt

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

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

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

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

k = A("k")
j = B("j")
m = C("m")
c = D("c")
e = E("e")

k.t = j
k.o = e
j.q = m
m.v = k
c.p = m
e.x = c
e.r = c
e.q = m
assert c.p.v.t.q.v.txt == "k"