class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.u: C = None
        self.v: A = 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.w: B = None
        self.txt = txt

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

a = A("a")
c = B("c")
b = C("b")
k = D("k")
j = A("j")

a.w = k
a.u = b
a.v = j
c.q = k
b.w = c
k.z = c
k.o = b
k.t = a
j.w = k
j.u = b
j.v = a
assert b.w.q.o.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.u: C = None
        self.v: A = 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.w: B = None
        self.txt = txt

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

a = A("a")
c = B("c")
b = C("b")
k = D("k")
j = A("j")

a.w = k
a.u = b
a.v = j
c.q = k
b.w = c
k.z = c
k.o = b
k.t = a
j.w = k
j.u = b
j.v = a
assert b.w.q.o.w.q.txt == "k"