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

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

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

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

f = A("f")
c = B("c")
b = C("b")
e = D("e")

f.s = e
c.p = b
b.w = c
b.v = c
b.q = f
b.o = e
e.u = f
e.s = c
assert e.u.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

f = A("f")
c = B("c")
b = C("b")
e = D("e")

f.s = e
c.p = b
b.w = c
b.v = c
b.q = f
b.o = e
e.u = f
e.s = c
assert e.u.s.s.txt == "c"