class A:
    def __init__(self, txt: str):
        self.x: 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.x: D = None
        self.txt = txt

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

k = A("k")
h = B("h")
b = C("b")
g = D("g")

k.x = h
h.q = g
b.x = g
g.v = b
g.u = k
g.w = k
g.z = k
assert k.x.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: 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.x: D = None
        self.txt = txt

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

k = A("k")
h = B("h")
b = C("b")
g = D("g")

k.x = h
h.q = g
b.x = g
g.v = b
g.u = k
g.w = k
g.z = k
assert k.x.q.v.txt == "b"