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

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

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

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

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

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

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

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

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

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

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