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

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

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

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

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

e.q = a
e.w = a
e.r = d
e.y = l
d.v = l
d.o = e
a.t = e
a.r = e
a.q = d
a.x = d
l.z = e
l.y = a
l.v = a
assert d.v.z.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.w: C = None
        self.r: B = None
        self.y: D = None
        self.txt = txt

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

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

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

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

e.q = a
e.w = a
e.r = d
e.y = l
d.v = l
d.o = e
a.t = e
a.r = e
a.q = d
a.x = d
l.z = e
l.y = a
l.v = a
assert d.v.z.w.x.txt == "d"