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

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

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

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

d = A("d")
j = B("j")
l = C("l")
c = D("c")

d.x = l
d.w = l
j.u = d
j.w = d
l.z = c
l.v = j
l.q = j
l.y = d
c.z = j
c.w = l
assert c.z.w.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.w: C = None
        self.txt = txt

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

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

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

d = A("d")
j = B("j")
l = C("l")
c = D("c")

d.x = l
d.w = l
j.u = d
j.w = d
l.z = c
l.v = j
l.q = j
l.y = d
c.z = j
c.w = l
assert c.z.w.x.q.txt == "j"