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

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

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

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

h = A("h")
k = B("k")
f = C("f")
j = D("j")

h.q = f
h.u = f
h.v = j
h.r = j
k.w = h
f.s = h
j.o = f
j.r = f
j.y = f
j.w = k
assert k.w.v.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: D = None
        self.r: D = None
        self.u: C = None
        self.txt = txt

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

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

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

h = A("h")
k = B("k")
f = C("f")
j = D("j")

h.q = f
h.u = f
h.v = j
h.r = j
k.w = h
f.s = h
j.o = f
j.r = f
j.y = f
j.w = k
assert k.w.v.w.w.txt == "h"