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

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

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

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

d = A("d")
g = B("g")
a = C("a")
m = D("m")

d.s = a
d.w = a
d.p = a
d.q = g
g.z = d
g.v = m
g.o = m
a.q = g
a.s = d
m.y = a
assert d.q.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.q: B = None
        self.w: C = None
        self.p: C = None
        self.txt = txt

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

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

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

d = A("d")
g = B("g")
a = C("a")
m = D("m")

d.s = a
d.w = a
d.p = a
d.q = g
g.z = d
g.v = m
g.o = m
a.q = g
a.s = d
m.y = a
assert d.q.v.y.txt == "a"