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

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

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

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

n = A("n")
f = B("f")
i = C("i")
e = D("e")

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

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

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

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

n = A("n")
f = B("f")
i = C("i")
e = D("e")

n.s = f
f.u = e
f.w = e
f.o = e
f.q = e
i.u = f
i.v = f
i.r = n
i.t = e
e.r = n
assert n.s.u.r.s.txt == "f"