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

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

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

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

e = A("e")
k = B("k")
a = C("a")
l = D("l")

e.w = l
e.v = a
k.v = l
k.x = l
k.w = e
a.q = l
l.q = e
l.w = e
l.p = k
l.r = k
assert a.q.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.v: C = None
        self.txt = txt

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

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

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

e = A("e")
k = B("k")
a = C("a")
l = D("l")

e.w = l
e.v = a
k.v = l
k.x = l
k.w = e
a.q = l
l.q = e
l.w = e
l.p = k
l.r = k
assert a.q.w.v.txt == "a"