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

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

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

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

l = A("l")
k = B("k")
i = C("i")
f = D("f")

l.w = f
l.x = i
k.p = i
k.s = i
i.r = k
f.o = k
f.t = k
f.u = l
assert i.r.s.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.x: C = None
        self.txt = txt

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

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

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

l = A("l")
k = B("k")
i = C("i")
f = D("f")

l.w = f
l.x = i
k.p = i
k.s = i
i.r = k
f.o = k
f.t = k
f.u = l
assert i.r.s.r.s.txt == "i"