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

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

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

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

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

l = A("l")
b = B("b")
k = C("k")
m = D("m")
c = E("c")

l.v = k
b.q = c
k.x = m
k.p = c
m.w = c
c.o = k
c.z = k
c.r = l
assert c.r.v.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

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

l = A("l")
b = B("b")
k = C("k")
m = D("m")
c = E("c")

l.v = k
b.q = c
k.x = m
k.p = c
m.w = c
c.o = k
c.z = k
c.r = l
assert c.r.v.x.w.txt == "c"