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

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

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

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

a = A("a")
i = B("i")
c = C("c")
d = D("d")

a.s = c
a.v = i
a.t = d
i.r = d
i.z = d
i.y = a
i.p = c
c.r = a
d.q = c
assert a.v.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.v: B = None
        self.t: D = None
        self.txt = txt

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

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

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

a = A("a")
i = B("i")
c = C("c")
d = D("d")

a.s = c
a.v = i
a.t = d
i.r = d
i.z = d
i.y = a
i.p = c
c.r = a
d.q = c
assert a.v.p.r.txt == "a"