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

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

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

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

f = A("f")
b = B("b")
n = C("n")
i = D("i")
l = B("l")

f.r = l
b.t = i
b.s = f
n.y = b
i.o = n
i.q = n
i.w = n
i.r = n
l.t = i
l.s = f
assert i.r.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

f = A("f")
b = B("b")
n = C("n")
i = D("i")
l = B("l")

f.r = l
b.t = i
b.s = f
n.y = b
i.o = n
i.q = n
i.w = n
i.r = n
l.t = i
l.s = f
assert i.r.y.t.txt == "i"