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

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

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

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

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

a.r = e
a.q = e
a.v = e
e.x = f
e.y = l
e.o = a
f.v = l
l.t = f
l.p = e
assert a.q.y.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: B = None
        self.v: B = None
        self.txt = txt

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

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

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

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

a.r = e
a.q = e
a.v = e
e.x = f
e.y = l
e.o = a
f.v = l
l.t = f
l.p = e
assert a.q.y.t.v.txt == "l"