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

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

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

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

l = A("l")
m = B("m")
a = C("a")
b = D("b")

l.p = b
m.z = a
m.v = l
m.q = l
a.r = b
a.y = b
b.s = m
b.z = l
b.o = l
assert m.z.y.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

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

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

l = A("l")
m = B("m")
a = C("a")
b = D("b")

l.p = b
m.z = a
m.v = l
m.q = l
a.r = b
a.y = b
b.s = m
b.z = l
b.o = l
assert m.z.y.s.q.txt == "l"