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

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

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

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

i = A("i")
e = B("e")
j = C("j")
k = D("k")

i.s = k
e.s = i
e.y = i
j.v = k
k.t = i
k.o = e
k.w = j
k.r = j
assert i.s.w.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

i = A("i")
e = B("e")
j = C("j")
k = D("k")

i.s = k
e.s = i
e.y = i
j.v = k
k.t = i
k.o = e
k.w = j
k.r = j
assert i.s.w.v.t.txt == "i"