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

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

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

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

b = A("b")
e = B("e")
c = C("c")
l = D("l")

b.z = e
e.q = l
c.v = e
l.q = b
l.w = e
l.p = e
assert c.v.q.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

b = A("b")
e = B("e")
c = C("c")
l = D("l")

b.z = e
e.q = l
c.v = e
l.q = b
l.w = e
l.p = e
assert c.v.q.q.z.txt == "e"