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

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

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

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

a = A("a")
c = B("c")
l = C("l")
e = D("e")
m = A("m")

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

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

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

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

a = A("a")
c = B("c")
l = C("l")
e = D("e")
m = A("m")

a.p = l
a.z = l
a.o = e
a.v = m
c.x = l
l.w = m
e.r = m
m.p = l
m.z = l
m.o = e
m.v = a
assert e.r.v.p.w.o.txt == "e"